Skip to content

Instantly share code, notes, and snippets.

@mshock
mshock / keep_awake.ahk
Created May 31, 2016 22:07
AutoHotkey script to keep Windows from sleeping
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 / flair_parse.cfg
Last active March 26, 2018 18:35
scrape user flair to sqlite db from posts within a subreddit
[reddit]
client_id = XXX
client_secret = XXX
unique_key = XXX
@mshock
mshock / refresh_desktop.bat
Created March 10, 2016 00:48
get rid of annoying stuck context menu items in W2000-W7
tskill dwm
@mshock
mshock / pig_latin.rb
Created March 7, 2016 08:18
Pig Latin
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 / k3.js
Created October 29, 2015 02:39
k3kc stock monitor - Google Apps Script
var max_errors = 5;
var EMAIL = Session.getActiveUser().getEmail();
var scriptProperties = PropertiesService.getScriptProperties();
//scriptProperties.deleteAllProperties();
function myFunction() {
var current_stock = {};
var shop_url = 'http://www.k3kc.com/shop/';
var links = new Array();
@mshock
mshock / fizzbuzz.pl
Created April 27, 2015 00:14
fizzbuzz in Perl using a generator
#! perl -w
use strict;
use List::Gen;
my $range;
$range = cache gen {$_} range 1, 100;
sub fizzbuzz {
my ($range, $triggers) = @_;
@mshock
mshock / clippy.cow
Created April 25, 2015 19:55
display Clippy whenever last command doesn't return success
##
## Milk from Milk and Cheese
##
$the_cow = <<EOC;
$thoughts ___
$thoughts / \\
$thoughts / \\
/ \\
___ ___
/___\\ /___\\
#!/bin/bash
if ! [ -x "$(type -P iperf)" ]; then
echo "ERROR: script requires iperf"
echo "For Debian and friends get it with 'apt-get install iperf'"
echo "If you have it, perhaps you don't have permissions to run it, try 'sudo $(basename $0)'"
exit 1
fi
if [ "$#" -ne "2" ]; then
@mshock
mshock / default.rb
Last active August 29, 2015 14:15
chef recipe for basic apache install
package "apache2" do
action :install
end
service "apache2" do
action [ :enable, :start ]
end
execute "mv /etc/apache2/sites-enabled/default-000.conf /etc/apache2/sites-available/default-000.conf.disabled" do
only_if do
@mshock
mshock / move_by_size.gs
Last active August 29, 2015 14:12
backup and delete original files by size in target directory - cleanup reddit wallpaper stash populated by IFTTT
function wallpaper_cleanup() {
var folder = DriveApp.getFoldersByName("wallpapers").next();
var small_folder = DriveApp.getFoldersByName("small_wallpapers").next();
var files = folder.getFiles();
while (files.hasNext()) {
var file = files.next();
if (file.getSize() < 200000) {
file.makeCopy(small_folder);
file.setTrashed(true);
Logger.log(file.getName() + file.getSize());