Skip to content

Instantly share code, notes, and snippets.

View anotherjesse's full-sized avatar

Jesse Andrews anotherjesse

View GitHub Profile
@anotherjesse
anotherjesse / pups.py
Created July 5, 2009 18:55
experimenting with amqp from python
#!/usr/bin/env python
from amqplib import client_0_8 as amqp
import sys
class Pups:
def __init__(self, hostname):
self.conn = amqp.Connection(host="%s:5672" % hostname,
userid="guest",
password="guest",
@anotherjesse
anotherjesse / StompSender.php
Created July 5, 2009 22:40
using rabbitmq from php via amqp and stomp
<?php
/**
* Handles SENDs to STOMP
* Only tested with the rabbitmq stomp gateway and rabbitmq server 1.4.0
* Only supports sending message to stomp, no support for other commands
*
* Original source: http://code.google.com/p/simplisticstompclient/
*
* Changes: Added ability to specify host
@anotherjesse
anotherjesse / bot.py
Created July 25, 2009 02:08
exploring how to simulate lots of clients playing a game
#!/usr/bin/env python
# Stackless Bots
#
# Stackless is a version of python that allows "microthreads" (cooperative multitasking)
#
# OS X: http://www.stackless.com/binaries/stackless-2.6.2-macosx2009-06-09.dmg
# others: http://zope.stackless.com/download/sdocument_view
#
# This is an example of launch 250 bots that simulate a client and make HTTP requests
#!/bin/bash
echo "Flushing iptables..."
iptables -F
echo "SSH Allowed"
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
echo "allow from localhost"
iptables -A INPUT -i lo -j ACCEPT
Idea:
If /System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -I returns an SSID that is my MiFi, then make periodic requests to http://192.168.1.1/getStatus.cgi?dataType=TEXT to show my current status (up/down/signal strength) in firefox's statusbar.
function setTimeout(callback, ms) {
var _timer = Cc['@mozilla.org/timer;1']
.createInstance(Ci.nsITimer);
_timer.initWithCallback({notify: callback}, ms, Ci.nsITimer.TYPE_ONE_SHOT);
return _timer;
}
function clearTimeout(timer) {
timer.cancel();
}
% experimenting with erlang (using misultin) to build a crappy S3-like service
-module(s3).
-export([start/1, stop/0, handle_http/1]).
start(Port) ->
misultin:start_link([{port, Port}, {loop, fun(Req) -> handle_http(Req) end}]).
stop() ->
misultin:stop().
@anotherjesse
anotherjesse / .gitignore
Created October 21, 2009 08:12
s2 - stupid s3
*.pyc
*.beam
@anotherjesse
anotherjesse / gfm.rb
Created December 29, 2009 01:26 — forked from mojombo/gfm.rb
Github Flavored Markdown
require 'digest/md5'
def gfm(text)
# Extract pre blocks
extractions = {}
text.gsub!(%r{<pre>.*?</pre>}m) do |match|
md5 = Digest::MD5.hexdigest(match)
extractions[md5] = match
"{gfm-extraction-#{md5}}"
end
(?xi)
\b
( # Capture 1: entire matched URL
(?:
[a-z][\w-]+: # URL protocol and colon
(?:
/{1,3} # 1-3 slashes
| # or
[a-z0-9%] # Single letter or digit or '%'
# (Trying not to match e.g. "URI::Escape")