Skip to content

Instantly share code, notes, and snippets.

View ksloan's full-sized avatar
🐛
Bug hunting

Kevin Sloan ksloan

🐛
Bug hunting
View GitHub Profile
import time
import win32api, win32con
VK_CODE = {'left_arrow':0x25,
'spacebar':0x20,
'right_arrow':0x27}
def press(x):
win32api.keybd_event(VK_CODE[x], 0,0,0)
win32api.keybd_event(VK_CODE[x],0 ,win32con.KEYEVENTF_KEYUP ,0)
@ksloan
ksloan / gist:6709216
Created September 26, 2013 02:48
Copy a file from one branch to another (that doesn't already exist in current branch)
touch <filename>;
git add <filename>;
git checkout <other branch> <filename>;
@ksloan
ksloan / gist:6813118
Created October 3, 2013 16:55
Include Time.ly upcoming event / agenda widget manually
<?php the_widget('Ai1ec_Agenda_Widget') ?>
@ksloan
ksloan / gist:6833044
Created October 4, 2013 21:26
Get event data from time.ly plugin event post
$event = Ai1ec_Events_Helper::get_event($post->ID);
@ksloan
ksloan / gist:6995003
Created October 15, 2013 17:08
load an img, with a backup src incase the primary doesn't exist
<img src="foo.jpg" onerror="this.src='error.jpg';">
@ksloan
ksloan / gist:9555060
Created March 14, 2014 19:33
fixed position scrolling after certain point
$(window).scroll(function(){
$("#theFixed").css("top",Math.max(0,250-$(this).scrollTop()));
});
@ksloan
ksloan / gist:11266683
Last active August 29, 2015 14:00
run mongod in background with log
sudo mongod --fork --logpath /var/log/mongodb.log
@ksloan
ksloan / gist:11266733
Created April 24, 2014 19:34
remove prefix from filenames
ls | while read f; do f_new=`echo $f | sed 's/prefix//'`; mv "'$f'" "'$f_new'"; done
@ksloan
ksloan / gist:11266769
Last active August 29, 2015 14:00
download an entire folder via ftp
wget -r 'ftp://user:pass@domain.com/path'
@ksloan
ksloan / gist:11266806
Created April 24, 2014 19:36
install android apk on emulator
# start the emulator manually and run...
adb install myapp.apk
# to reinstall...
adb install -r myapp.apk