Skip to content

Instantly share code, notes, and snippets.

@tong
tong / MUChatRoom.hx
Created February 4, 2014 09:31
Jabber/XMPP muc server component example
package jabber.component;
import jabber.stream.PacketCollector;
/**
*/
class HistoryMessage extends xmpp.Message {
public var nick(default,null) : String;
public function new( nick : String, body : String, from : String, stamp : String ) {
super( null, body );
@tong
tong / GY521.cpp
Created March 29, 2014 16:05
Arduino-GY521
#include "Arduino.h"
#include <Wire.h>
#include "GY521.h"
void gy521_setup() {
int error;
uint8_t c;
@tong
tong / disktree-signet-dev.svg
Last active September 21, 2015 23:38
disktree-signet-dev
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tong
tong / sfxr.c
Last active September 29, 2015 16:08
SFXR, C++ original
//#include <stdio.h>
//#include <stdarg.h>
//#include <stdlib.h>
//#include <time.h>
#include <math.h>
#include <SDL/SDL.h>
#include <neko.h>
#define rnd(n) (rand()%(n+1))
@tong
tong / C2DMessenger.hx
Last active October 1, 2015 14:08
C2DM test script
package android;
/**
Android Cloud 2 Device Messenger.
*/
class C2DMessenger {
public static inline var C2DM_URL_LOGIN = "https://www.google.com/accounts/ClientLogin";
public static inline var C2DM_URL_SEND = "https://android.apis.google.com/c2dm/send";
@tong
tong / Index.hx
Last active October 3, 2015 13:58
SASL-MD5 remote computation for XMPP clients
import jabber.sasl.MD5Calculator;
using Lambda;
/**
Simple, remote SASL-MD5 calculator for XMPP clients
*/
class Index {
static var passwords = {
tong : 'test'
@tong
tong / subl-color-schemes
Created October 3, 2015 19:07
Subl color schemes
# Subl color schemes
## GoldenDragon
#191919
#66cccc
#AEAEAE
#3B3A32
#2D2D2D
#FFE792
@tong
tong / bosh-proxy.php
Created May 22, 2012 09:03
PHP HTTP proxy for XMPP/BOSH connections using CORS
<?php
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Credentials: true ");
header("Access-Control-Allow-Methods: OPTIONS, GET, POST");
header("Access-Control-Allow-Headers: Content-Type, Depth, User-Agent, X-File-Size, X-Requested-With, If-Modified-Since, X-File-Name, Cache-Control");
$url = "http://example.com/http-bind"; // URI of the HTTP/BOSH gate to the XMPP server
$postdata = file_get_contents('php://input');
@tong
tong / haxe-completion.sh
Last active December 14, 2015 05:49
Haxe shell completion script
#!bash
#
# Haxe bash completion
#
__haxe_commands() {
echo "-cp -js -swf -as3 -neko -php -cpp -cs -java -python -xml -main -lib -D -v -debug -dce -swf-version -swf-header -swf-lib -swf-lib-extern -java-lib -net-lib -net-std -c-arg -x -resource -prompt -cmd --flash-strict --no-traces --gen-hx-classes --next --each --display --no-output --times --no-inline --no-opt --php-front --php-lib --php-prefix --remap --interp --macro --eval --wait --connect --cwd -version --help-defines --help-metas -help --help"
}
_haxe_complete() {
@tong
tong / WebSocketUtil.hx
Created March 5, 2013 09:55
Haxe/Sys websocket handshake util
package sys.net;
import haxe.crypto.Sha1;
import haxe.io.BytesInput;
import haxe.io.Output;
class WebSocketUtil {
public static inline var MAGIC_STRING = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";