Skip to content

Instantly share code, notes, and snippets.

@mshock
mshock / restart_services.pl
Created May 15, 2012 14:55
restart Windows services
# /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 / tab.pl
Created May 15, 2012 15:18
shell tab emulation
#! /usr/bin/perl -w
use Term::ReadKey;
# make STDOUT hot
$| = 1;
$string = '';
$done = 0;
# get your dir listing
opendir($dh, '.');
@mshock
mshock / reconst_truth.pl
Created October 8, 2012 20:42
regex truth constant
# useful to implement in many scripts that need to verify user input from CLI or config files
use constant REGEX_TRUE => qr/^\s*(?:true|(?:t)|(?:y)|yes|(?:1))\s*$/i;
@mshock
mshock / ppm_list.csv
Last active October 11, 2015 11:57
workstation ppm list @ 2/26/2013
name version files size area
ANSIColor 3.00 0 0 perl
ActivePerl-CPAN-Config 1.0 2 1900 perl
ActivePerl-Config 1.3 2 17865 perl
ActivePerl-DocTools 2.4 13 63474 perl
ActivePerl-IIS-Config 1.0 0 0 perl
ActivePerl-PPM 4.14 64 622271 perl
ActiveState-PerlCritic 10.0 24 191887 perl
ActiveState-RelocateTree 1.4 4 29505 perl
ActiveState-Scineplex 1.1 7 86307 perl
@mshock
mshock / ppm_getmods.pl
Created October 11, 2012 20:50
ppm install missing modules from exported csv
#! perl -w
# read exported ppm csv list and install all missing modules
use strict;
# first make sure everything is up to date
print "updating all installed modules...\n";
print `ppm upgrade --install`;
print "\ndone\n\n";
@mshock
mshock / RoundSigFig.sql
Last active October 11, 2015 21:08
sql function - round float to sig fig
GO
CREATE FUNCTION RoundSigFig(@Number float, @Figures int)
RETURNS float
AS
BEGIN
DECLARE @Answer float;
SET @Answer = (
SELECT
@mshock
mshock / sql_julian.sql
Last active October 11, 2015 21:17
sql convert to julian
select (CONVERT([int],@Date_,(0))+(2415021))
@mshock
mshock / perltidy.conf
Created November 1, 2012 17:02
Perltidy options config file
# mshock's Perltidy options
# Perl Best Practices
# an abbreviation for the parameters in the book Perl Best Practices by Damian Conway:
# -l=78 -i=4 -ci=4 -st -se -vt=2 -cti=0 -pt=1 -bt=1 -sbt=1 -bbt=1 -nsfs -nolq
# -wbb="% + - * / x != == >= <= =~ !~ < > | & =
# **= += *= &= <<= &&= -= /= |= >>= ||= //= .= %= ^= x="
-pbp
@mshock
mshock / julianify.pl
Created February 9, 2013 00:11
Convert a Gregorian calendar date to Julian date number (JDN) in Perl faster, less overhead than using any Date packages from CPAN straight from the Wikipedia algorithm
sub julianify {
my ( $year, $month, $day ) = @_;
my $a = int( ( 14 - $month ) / 12 );
my $y = $year + 4800 - $a;
my $m = $month + 12 * $a - 3;
return
$day
+ int( ( 153 * $m + 2 ) / 5 )
+ 365 * $y
@mshock
mshock / gravatar.html
Created February 26, 2013 23:41
permalink to my gravatar image
<img src='
http://www.gravatar.com/avatar/ab623233b6a75fecb24a28b6cf2013b7.png
'
alt='cheshire_avatar'>