Skip to content

Instantly share code, notes, and snippets.

View ryangraham's full-sized avatar
😝

Ryan Graham ryangraham

😝
View GitHub Profile
@ryangraham
ryangraham / model-tests-in-tornado.py
Created July 21, 2011 16:54 — forked from didip/model-tests-in-tornado.py
Example on how to tests your model classes in Tornado
import unittest, os, os.path, sys
import tornado.database
import tornado.options
from tornado.options import options
APP_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
sys.path.append(os.path.join(APP_ROOT, '..'))
# import your model module
import your.model as model
@ryangraham
ryangraham / markasread
Created August 9, 2011 21:24
Mark As Read with Google Apps Script
/* We're having a Read/Unread War in a shared Google Apps mailbox.
* I need to figure out how to put this on like a 10 second trigger...
*/
function whatthe() {
var threads = GmailApp.getInboxThreads(0, 20);
GmailApp.markThreadsRead(threads);
}
@ryangraham
ryangraham / poke_everyone.user.js
Created November 3, 2011 22:10 — forked from Eckankar/poke_everyone.user.js
Poke everyone on Facebook!
// ==UserScript==
// @name Poke everyone!
// @description Pokes everyone you specify.
// @author Sebastian Paaske Tørholm
// @include http://*.facebook.com/*
// @include https://*.facebook.com/*
// @match http://*.facebook.com/*
// @match https://*.facebook.com/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js
// @version 1.0
@ryangraham
ryangraham / gist:1468795
Created December 12, 2011 19:50
Casting an asio buffer
const unsigned char* buf=boost::asio::buffer_cast<const unsigned char*>(inbuf_.data());
std::cout << &inbuf_;
@ryangraham
ryangraham / gist:1478250
Created December 14, 2011 20:08
FTP in Lion
Start:
sudo -s launchctl load -w /System/Library/LaunchDaemons/ftp.plist
Stop:
sudo -s launchctl unload -w /System/Library/LaunchDaemons/ftp.plist
@ryangraham
ryangraham / gist:1603625
Created January 12, 2012 22:44
computeBlade
<configResolveClass cookie='1326408068/5e023770-a7d0-4a98-88cb-f0db0357109f' response='yes' classId='computeBlade'>
<outConfigs>
<computeBlade adminPower='policy' adminState='in-service' assignedToDn='org-root/ls-11' association='associated' availability='unavailable' availableMemory='8192' chassisId='1' checkPoint='discovered' connPath='A,B' connStatus='A,B' descr='' discovery='complete' dn='sys/chassis-1/blade-1' fltAggr='0' fsmDescr='' fsmFlags='' fsmPrev='TurnupSuccess' fsmProgr='100' fsmRmtInvErrCode='none' fsmRmtInvErrDescr='' fsmRmtInvRslt='' fsmStageDescr='' fsmStamp='2012-01-10T20:19:23.463' fsmStatus='nop' fsmTry='0' intId='32992' lc='undiscovered' lcTs='1970-01-01T01:00:00.000' lowVoltageMemory='not-applicable' managingInst='A' memorySpeed='not-applicable' mfgTime='not-applicable' model='N20-B6620-1' name='' numOfAdaptors='1' numOfCores='8' numOfCoresEnabled='8' numOfCpus='2' numOfEthHostIfs='3' numOfFcHostIfs='0' numOfThreads='16' operPower='on' operQualifier='' operState='ok' operability='o
@ryangraham
ryangraham / child.cpp
Created March 2, 2012 00:38
named pipe inheritance
class child
{
public:
child(char *cmd)
{
// Sec attr for the named pipe
SECURITY_ATTRIBUTES sa;
ZeroMemory(&sa,sizeof(sa));
sa.nLength = sizeof(sa);
sa.lpSecurityDescriptor = NULL;
@ryangraham
ryangraham / utf8bom.rb
Created March 22, 2012 02:39
prepend utf8 byte order mark (bom) and then rewrite file line by line
module UnfuckUnicode
def byteordermarkify(old,new)
File.open(new, 'w') do |out|
out << "\xEF\xBB\xBF"
File.foreach(old) do |line|
out << line
end
end
end
end
@ryangraham
ryangraham / logtailer.c
Created March 25, 2012 18:10
Messing around this morning...
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
typedef struct {
char *name;
FILE *file;
long inode;
@ryangraham
ryangraham / cookbooks.sh
Created March 26, 2012 21:53 — forked from dysinger/cookbooks.sh
Re-write Opscode Cookbooks as individual Git repos
#!/bin/bash
for cookbook in $(find * -type d -maxdepth 0); do
git clone ./ ../${cookbook}
cd ../${cookbook}
git remote rm origin
git filter-branch --subdirectory-filter ${cookbook} -- --all
git gc --aggressive
done