Skip to content

Instantly share code, notes, and snippets.

View KyleAMathews's full-sized avatar

Kyle Mathews KyleAMathews

View GitHub Profile
@KyleAMathews
KyleAMathews / gist:4653298
Created January 28, 2013 05:38
Response headers from Facebook group post AJAX call
Cache-Control:private, no-cache, no-store, must-revalidate
Connection:keep-alive
Content-Length:0
Content-Type:text/html; charset=utf-8
Date:Mon, 28 Jan 2013 05:37:01 GMT
Expires:Sat, 01 Jan 2000 00:00:00 GMT
P3P:CP="Facebook does not have a P3P policy. Learn why here: http://fb.me/p3p"
Pragma:no-cache
Set-Cookie:wd=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=.facebook.com; httponly
Set-Cookie:x-src=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=.facebook.com; httponly
@KyleAMathews
KyleAMathews / gist:3907225
Created October 17, 2012 18:31
python stacktrace
Traceback (most recent call last):
File "migrate.py", line 156, in <module>
_main(scripts, args.dryrun, args.checkrun)
File "migrate.py", line 84, in _main
fromlist=['titan.utilities.migrations'])
File "/usr/lib/python2.7/site-packages/titan/utilities/migrations/2_add_ygg_activity_schema.py", line 4, in <module>
from titan.yggdrasil import yggdrasil
File "/usr/lib/python2.7/site-packages/titan/yggdrasil/yggdrasil.py", line 8, in <module>
import paramiko
File "/usr/lib/python2.7/site-packages/paramiko/__init__.py", line 69, in <module>
@KyleAMathews
KyleAMathews / setup-statsd.sh
Created April 28, 2012 00:57 — forked from collegeman/setup-statsd.sh
Turn an Ubuntu 12.04 Amazon EC2 Micro instance into a StatsD/Bucky/Graphite server
# install git
sudo apt-get install g++ curl libssl-dev apache2-utils make
sudo apt-get install git-core
# download the Node source, compile and install it
cd /opt
git clone https://github.com/joyent/node.git
cd node
git checkout v0.6
./configure
@KyleAMathews
KyleAMathews / makeExpandingArea.coffee
Created November 29, 2011 22:28
jQuery plugin for making textareas auto-exapand. Based on article at http://www.alistapart.com/articles/expanding-text-areas-made-elegant/
$ = jQuery
$.fn.makeExpandingArea = () ->
@.each ->
container = $(@)
area = container.find('textarea')
span = container.find('span')
area.on 'input', ->
span.text(area.val())
@KyleAMathews
KyleAMathews / gist:1345969
Created November 7, 2011 19:54
My five line node.js/coffeescript/mongodb RESTful API
app.get '/groups', (req, res) ->
Group = mongoose.model 'group'
Group.find (err, groups) ->
if err then console.error err
res.json groups
@KyleAMathews
KyleAMathews / onchange.sh
Created May 12, 2011 01:00
Run an arbitrary command on any changes to an arbitrary file
#!/bin/bash
# Usage: onchange.sh COMMAND FILE
# On Ubuntu/Debian, you'll need to install the inotify-tools package.
COMMAND=$1
FILE=$2
# Run once initially.
$command $file
/**
* Implementation of hook_widget().
*/
function etherpad_widget(&$form, &$form_state, $field, $items, $delta = 0) {
$element['etherpad_url'] = array(
'#type' => 'value',
'#value' => (isset($items[$delta]['etherpad_url']) && !empty($form['nid']['#value'])) ? $items[$delta]['etherpad_url'] : $field['etherpad_url'] . etherpad_generate_padid($field['etherpad_url']),
);
$element['etherpad_text'] = array(
'#type' => 'value',
function etherpad_field_settings($op, $field) {
switch ($op) {
// Code removed.
case 'database columns':
return array(
'etherpad_url' => array('type' => 'varchar', 'length' => 1024, 'not null' => FALSE,),
'etherpad_text' => array('type' => 'text', 'not null' => TRUE, 'size' => 'big'),
'attributes' => array('type' => 'text', 'size' => 'medium', 'not null' => FALSE),// Then add auto-generate etherpad function.
);
}
@KyleAMathews
KyleAMathews / gist:665203
Created November 6, 2010 04:41
Create etherpad with this script
<?php
$padId = 'testingmoreplease';
$domain = "http://piratepad.net";
$ch = curl_init();
# for debugging
curl_setopt($ch, CURLOPT_HEADER, true);
#!/bin/sh
#
# Build a complete tar.gz archive of Drupal + Open Atrium
#
# This command expects to be run withing a CVS checkout of the Open Atrium
# project. It can only be run without arguments. It will generate a output file
# of the format openatrium-TAG.tar.gz in the current directory.
#
MAKE=$(cat <<EOF