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 / flair_parse.cfg
Last active Mar 26, 2018
scrape user flair to sqlite db from posts within a subreddit
View flair_parse.cfg
[reddit]
client_id = XXX
client_secret = XXX
unique_key = XXX
@mshock
mshock / keep_awake.ahk
Created May 31, 2016
AutoHotkey script to keep Windows from sleeping
View keep_awake.ahk
SetTimer,KeepAwake,480000 ;run every 8 minutes
return
KeepAwake:
{
MouseMove,0,0,0,R ; mouse pointer stays in place but sends a mouse event
}
return
^0::
@mshock
mshock / refresh_desktop.bat
Created Mar 10, 2016
get rid of annoying stuck context menu items in W2000-W7
View pig_latin.rb
def translate(str)
words = str.split(" ")
result_array = Array.new
words.each do |word|
if ( word.match(/^[aeiou]/) )
result_array.push( word + 'ay' )
else
done = false
consonants = ''
@mshock
mshock / sleepseconds.pl
Created Nov 22, 2013
get number of seconds to sleep for once a day scheduling by hour
View sleepseconds.pl
sub getsleep {
my ($thour) = @_;
return 0 unless $thour;
my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst )
= localtime(time);
my $dif = $thour - $hour - $min / 60 - $sec / 3600;
if ( $dif >= 0 ) {
return $dif * 3600;
@mshock
mshock / gdate.pl
Created Aug 21, 2013
Julian date number (JDN) to Gregorian calendar date Source: http://aa.usno.navy.mil/faq/docs/JD_Formula.php
View gdate.pl
sub gdate {
my $jdn = shift;
my $l= $jdn+68569;
my $n= int(4*$l/146097);
$l= int($l-(146097*$n+3)/4);
my $i = int(4000*($l+1)/1461001);
$l= int($l-1461*$i/4+31);
my $j = int(80*$l/2447);
my $k = int( $l - 2447 * $j/80);
$l = int($j/11);
@mshock
mshock / switchboard.pl
Created Jun 14, 2013
golf - switchboard - 141 characters
View switchboard.pl
#!perl -n
@z=/[^\n]/sg if/A/;
while(1) {
$i=index$_,'X';
($p,$t)=$i%2?($i-1,$i+1):($i-2,$i+2);
($z[$p],$z[$t])=($z[$t],$z[$p]);
s/X/ /
}
}{print@z
__DATA__
@mshock
mshock / pascal.pl
Last active Dec 18, 2015
golf - Pascal's Triangle (34 rows) - 61 chars
View pascal.pl
$z='1';
$r=$z;
for(0..32){
@d=split' ',$z;
unshift@d,0;
@n=();
while($#d!=-1){
push@n,($d[0]||0)+($d[1]||0);
shift@d
}
@mshock
mshock / switch_simple.pl
Created Apr 29, 2013
most basic CLI arg parsing for Perl scripts which use warnings and/or strict: perl -s script.pl -test
View switch_simple.pl
#! perl -ws
use strict;
our $test ||= '';
print $test;
@mshock
mshock / list_vols.bat
Created Apr 24, 2013
Windows cmd list disk volumes metadata
View list_vols.bat
echo list volume | diskpart
You can’t perform that action at this time.