Skip to content

Instantly share code, notes, and snippets.

View kylegibson's full-sized avatar

Kyle Gibson kylegibson

View GitHub Profile
@kylegibson
kylegibson / btcguild.py
Created June 3, 2011 20:15
Script to display/email btcguild bitcoin miner progress on current round, and detect any idle workers
#!/usr/bin/python
# https://gist.github.com/gists/1007083
# Donate: 1BdWJEUCkm6on231iX2ThXZHXZDfQny69R
from __future__ import division
import json
import urllib2
from smtplib import SMTP
from email.mime.text import MIMEText
from cStringIO import StringIO
from pprint import pprint
@kylegibson
kylegibson / gist_scrape.php
Created October 9, 2011 18:54
PHP script to scrape data from a gist page
<?
function get_gist_url($id) {
$data = file_get_contents("https://gist.github.com/$id");
$pos1 = strpos($data, "/raw/$id");
$pos2 = strpos($data, "\"", $pos1);
$url = substr($data, $pos1, $pos2-$pos1);
return "https://gist.github.com$url";
}
$url = get_gist_url($_GET["id"]);
ob_start('ob_gzhandler');
@kylegibson
kylegibson / VirtualBox-4.0.8-VBoxSVC-daemonize-pidfile.patch
Created October 10, 2011 17:11
Patch file for VirtualBox 4.0.8 to correctly pass start parameters onto spawned daemon process
--- VirtualBox-4.0.8_OSE/src/VBox/Main/src-server/xpcom/server.cpp 2011-05-16 12:33:47.000000000 -0400
+++ VirtualBox-4.0.8_OSE.fix/src/VBox/Main/src-server/xpcom/server.cpp 2011-05-18 18:01:04.784596001 -0400
@@ -712,15 +712,23 @@
}
}
-static nsresult vboxsvcSpawnDaemonByReExec(const char *pszPath)
+static nsresult vboxsvcSpawnDaemonByReExec(const char *pszPath, bool bAutoShutdown, const char *pszPidFile)
{
PRFileDesc *readable = nsnull, *writable = nsnull;
@kylegibson
kylegibson / php-fastcgi.sh
Created October 10, 2011 19:41
php fast-cgi sysvinit script
#!/bin/bash
BIND=/tmp/php-fcgi.sock
USER=frozen
PHP_FCGI_CHILDREN=10
PHP_FCGI_MAX_REQUESTS=300
PHP_CGI=/usr/bin/php-cgi
PHP_CGI_NAME=$(basename $PHP_CGI)
PHP_CGI_ARGS="- USER=$USER PATH=/usr/bin PHP_FCGI_CHILDREN=$PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS=$PHP_FCGI_MAX_REQUESTS $PHP_CGI -b $BIND"
RETVAL=0
@kylegibson
kylegibson / update_bitcoin_prices.sh
Created October 12, 2011 04:12
Bash script to scrape current bitcoin exchange prices and update a local json file
#!/bin/bash
BTC_PATH=$1
REMOTE_URL=http://bitcoincharts.com/t/weighted_prices.json
wget -q -O $BTC_PATH.temp $REMOTE_URL
test $? -ne 0 && exit
test ! -e $BTC_PATH.temp && exit
test $(stat -c%s $BTC_PATH.temp) -lt 600 && exit
mv $BTC_PATH{.temp,}
dateTimeFormat: gregorian
events:
- title: Jamestown founded
start: May 14 1607
- title: Mayflower Compact
start: Nov 11 1620
- title: English Civil War
start: 1642
@kylegibson
kylegibson / timetests.py
Created March 13, 2012 05:59 — forked from mahmoudimus/nose-timetests.py
Nose plugin to time tests
"""This plugin provides test timings to identify which tests might be
taking the most. From this information, it might be useful to couple
individual tests nose's `--with-profile` option to profile problematic
tests.
This plugin is heavily influenced by nose's `xunit` plugin.
Add this command to the way you execute nose::
--with-test-timer
> pip uninstall pyyaml
Exception:
Traceback (most recent call last):
File "/home/kyle/testenv/lib/python2.6/site-packages/pip-1.1-py2.6.egg/pip/basecommand.py", line 104, in main
status = self.run(options, args)
File "/home/kyle/testenv/lib/python2.6/site-packages/pip-1.1-py2.6.egg/pip/commands/uninstall.py", line 41, in run
requirement_set.uninstall(auto_confirm=options.yes)
File "/home/kyle/testenv/lib/python2.6/site-packages/pip-1.1-py2.6.egg/pip/req.py", line 862, in uninstall
req.uninstall(auto_confirm=auto_confirm)
File "/home/kyle/testenv/lib/python2.6/site-packages/pip-1.1-py2.6.egg/pip/req.py", line 461, in uninstall
import pyev
def run_every_5_seconds(watcher, revents):
print 'foo'
loop = pyev.default_loop()
run_every_5_seconds_loop = loop.timer(0, 5, run_every_5_seconds)
run_every_5_seconds_loop.start()
loop.start()
import pyev
class FiveSecondTimer(object):
def __init__(self, data):
self.data = data
def __call__(self, watch, revents):
print 'foo', data
loop = pyev.default_loop()