Skip to content

Instantly share code, notes, and snippets.

mshock

  • San Francisco, CA
Block or report user

Report or block mshock

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mshock
mshock / restart_services.pl
Created May 15, 2012
restart Windows services
View restart_services.pl
# /usr/bin/perl
# child process to background
# poll windows services and re-enable + start them
use Win32::Service;
use Win32::OLE;
use strict;
# set logfile location
my $logfile = 'log.txt';
@mshock
mshock / choose.pl
Created May 15, 2012
golf - n choose p
View choose.pl
# current solution:
<>=~/,/;$r=++$_+$`;while($c++-$'){$_=$r/$c*$_-$_}print
######################################################
=pod
All of my scratch getting to this point:
<>=~/,/;$r=++$_+$`;while($c++-$'){$_=$_*$r/$c-$_}print
while
View grep_regex.pl
#!/usr/bin/perl
$/ = undef;
$file = <DATA>;
$/ = "\n";
$lines_up = 2;
$lines_down = 1;
$pattern = 'bbb';
@mshock
mshock / tab.pl
Created May 15, 2012
shell tab emulation
View tab.pl
#! /usr/bin/perl -w
use Term::ReadKey;
# make STDOUT hot
$| = 1;
$string = '';
$done = 0;
# get your dir listing
opendir($dh, '.');
@mshock
mshock / doc_vars.pl
Created May 15, 2012
neat documentation variables hack
View doc_vars.pl
my %const = map { s/\s+//; $_ }
map { split /\s*=>\s*/ }
grep { /=>/ }
map { split /\n/ } << '=cut';
=pod
This module uses the following constants:
bang_eth => 1
@mshock
mshock / csv_compare.sh
Created May 15, 2012
CSV column compare, one liner
View csv_compare.sh
perl -F, -ape'$_<($x=length$F[i])and$_=$x' file.csv
@mshock
mshock / SendEmail.pm
Last active Oct 4, 2015
module for sending e-mail with built-in example
View SendEmail.pm
#! perl -w
# framework for e-mail module for importing
package SendEMail;
use strict;
use Net::SMTP;
use Exporter 'import';
our @EXPORT = qw(send_email);
@mshock
mshock / copyfiles.pl
Created May 15, 2012
generate remote copy batch files
View copyfiles.pl
#! /usr/bin/perl -w
# chop up list of all files into several batch scripts for xfers
$remote_dir = $ARGV[1];
$local_temp = $ARGV[3];
$local_target = $ARGV[2];
if(scalar(@ARGV)){
@mshock
mshock / filter_sort.pl
Created May 15, 2012
filter and sort by value file containing rows of key = value
View filter_sort.pl
#! /usr/bin/perl
# filter rows to ones containing search_value
# sort the rows by search_value
# usage: filter_sort.pl file search_value
$search_value = $ARGV[1];
open (F, '<', $ARGV[0]);
@lines;
for(<F>) {
if (m/$search_value\s*=\s*(\d+)/) {
@mshock
mshock / alarm_sched.pl
Created May 15, 2012
alarm scheduling framework
View alarm_sched.pl
#! /usr/bin/perl
$SIG{ALRM} = \&ten_min_task;
alarm (600);
while (1) {
# run in between task here
#sleep 1; print "foo\n";
}
You can’t perform that action at this time.