Skip to content

Instantly share code, notes, and snippets.

View aaronpk's full-sized avatar

Aaron Parecki aaronpk

View GitHub Profile
@aaronpk
aaronpk / x10proxy.php
Created June 23, 2011 18:43
x10 UDP proxy
#!/usr/bin/php
<?php
/*
* Send X10 commands to this proxy script like "!on A4" with the following function
*
* function send_x10_command($msg)
* {
* $udpstr = serialize(array('command'=>$msg));
* $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
@aaronpk
aaronpk / gist:1043323
Created June 23, 2011 19:03
SMS to IRC Gateway
<?php
require('tropo-webapi-php/tropo.class.php');
define('IRC_SERVER', 'example.com');
define('IRC_UDP_PORT', 51000);
$session = new Session();
// Read text from incoming SMS
$text = $session->getInitialText();
@aaronpk
aaronpk / gist:1071024
Created July 8, 2011 02:58
yay trig!
var G = google.maps.geometry.spherical;
var A = placeMarker.getPosition();
var B = event.latLng;
var radians = function(degrees) { return degrees * (Math.PI/180); };
// Compute the angle from A to B
var beta = G.computeHeading(A, B);
@aaronpk
aaronpk / gist:1098480
Created July 21, 2011 23:21
make it better
/*
* This regex should look for regexes like s/a/b and capture both 'a' and 'b' separately.
* It's not very good yet. You can make it better if you want.
* Ready? go.
*/
/^s\/(.+)\/(.+)/
@aaronpk
aaronpk / gist:1100613
Created July 22, 2011 22:48
Email-to-SMS gateway
<?php
require_once('php-mime-mail-parser/MimeMailParser.class.php');
require_once(dirname(__FILE__) . '/Regex.php');
require_once(dirname(__FILE__) . 'smsified.class.php');
// get the email from STDIN
$buffer = '';
while(!feof(STDIN))
$buffer .= fgets(STDIN);
@aaronpk
aaronpk / echo.php
Created October 3, 2011 17:26
Example IRC action for Loqi
<?php
/*
echo 'These are the variables defined by the environment'."\n";
echo '$action = '.$action."\n";
echo '$message = '.$message."\n";
echo '$nick = '.$nick."\n";
echo '$username = '.$username."\n";
echo '$channel = '.$channel."\n";
echo '$command_target = '.$command_target."\n";
echo '$params = '.$params."\n";
@aaronpk
aaronpk / date.php
Created October 3, 2011 17:28
Loqi's date command
<?php
$error[] = 'Sorry, I couldn\'t parse that';
$error[] = 'That doesn\'t look like a date';
$error[] = 'Hmm, no clue';
$error[] = 'What?';
$error[] = 'Sorry.';
$error[] = 'I give up';
$success[] = 'That looks like a unix timestamp!';
make
g++ -I. -I/home/web/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/i686-linux -I/home/web/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/ruby/backward -I/home/web/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1 -I../../../../ext/ruby_mapnik -D_FILE_OFFSET_BITS=64 -I/home/web/.rvm/gems/ruby-1.9.2-p290@Geoloqi-Developer-Site/gems/rice-1.4.2/ruby/lib/include -fPIC -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -fPIC -I/usr/include -I/usr/include -I/usr/include/freetype2 -I/usr/include/libxml2 -I/usr/include/postgresql -I/usr/include/gdal -DHAVE_JPEG -DBOOST_REGEX_HAS_ICU -ansi -Wall -pthread -ftemplate-depth-200 -DLINUX -DBOOST_SPIRIT_THREADSAFE -DMAPNIK_THREADSAFE -O3 -finline-functions -Wno-inline -DNDEBUG -DHAVE_CAIRO -DLIBTOOL_SUPPORTS_ADVISE -DHAVE_LIBXML2 -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -I/usr/include/libpng12 -I/usr/include/cairomm-1.0 -I/usr/lib/cairomm-1.0/include -I/usr/inc
{ "name" : "browser-proxy",
"version" : "1.0.0",
"dependencies" : { "hiredis" : "0.1.12",
"redis" : "0.6.6",
"hoptoad-notifier" : "0.1.3",
"socket.io" : "0.8.4",
"optimist" : "0.2.6" }
}
require 'socket'
s = UDPSocket.new
s.bind(nil, 43333)
while(true) do
text, sender = s.recvfrom(39)
puts
71.times{print "="}
puts
puts "Received message from " + sender[3].to_s + ":" + sender[1].to_s