Skip to content

Instantly share code, notes, and snippets.

View benjaminws's full-sized avatar

Benjamin W. Smith benjaminws

View GitHub Profile
x = function()
y = function()
local table = 5
end
local old_table = table
y()
table.insert(old_table, 4)
assert(table == old_table and table ~= 5)
end
x()
The program 'curl' is currently not installed. You can install it by typing:
apt-get install curl
#!/usr/bin/env node
var sys = require('sys');
var stomp = require('stomp');
// Set debug to true for more verbose output.
// login and passcode are optional (required by rabbitMQ)
var stomp_args = {
port: 61613,
host: 'localhost',
client.on('connected', function() {
num = num || 1000;
for (var i = 0; i < num; i++) {
txn = client.begin();
client.send({
'destination': queue,
'body': 'Testing' + i,
'persistent': 'true',
'transaction': txn
}, receipt);
#!/usr/bin/env node
var stomp = require('stomp');
var num = process.argv[2];
// Set to true if you want a receipt
// of all messages sent.
var receipt = false;
var stomp_args = {
port: 61613,
host: 'localhost',
debug: false,
login: 'guest',
passcode: 'guest',
};
@benjaminws
benjaminws / gist:856552
Created March 5, 2011 18:01
What I'm working on
>>> tu.search_friends(['twitter', 'cleveland', 'benjaminws', 'python'])
[{'status': 'CPython is on mercurial now, so you can come contribute...', 'name': 'Benjamin Peterson', 'matches': ['python'], 'static_location': 'Minnesota, USA', 'coords': None, 'user': 'gutworth', 'geo': None}, {'status': '@benjaminws it is going to kick intergalactic ass', 'name': 'Alfredo Deza', 'matches': ['benjaminws'], 'static_location': 'Atlanta Georgia', 'coords': None, 'user': 'alfredodeza', 'geo': None}, {'status': 'The Python mercurial transition is complete! Now the real work begins. http://bit.ly/eFYmar Special thanks to @birkenfeld and @djco', 'name': 'Michael Foord', 'matches': ['python'], 'static_location': 'Northampton, UK', 'coords': None, 'user': 'voidspace', 'geo': None}, {'status': '@benjaminws I stand corrected', 'name': 'Alfredo Deza', 'matches': ['benjaminws'], 'static_location': 'Atlanta Georgia', 'coords': None, 'user': 'alfredodeza', 'geo': None}, {'status': '@benjaminws if it is not \\s+(documented|tested)\\s+
@benjaminws
benjaminws / distance.js
Created March 9, 2011 04:46
distance between two points
function distance(lat1,lon1,lat2,lon2) {
var R = 6371; // km (change this constant to get miles)
var dLat = (lat2-lat1) * Math.PI / 180;
var dLon = (lon2-lon1) * Math.PI / 180;
var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
Math.cos(lat1 * Math.PI / 180 ) * Math.cos(lat2 * Math.PI / 180 ) *
Math.sin(dLon/2) * Math.sin(dLon/2);
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
var d = R * c;
if (d>1) return Math.round(d)+"km";
#include <string.h>
#include <stdio.h>
#include "handler.h"
void handle_request(int sockfd, const char *request)
{
char *res = "HTTP 200 OK\r\n\r\n";
char file_buf[1024];
char url[1024];
Selected and implied templates:
pecan#base Template for creating a basic Pecan project
Variables:
egg: test_app
package: test_app
project: test_app
Creating template base
Traceback (most recent call last):
File "bin/pecan", line 9, in <module>