Skip to content

Instantly share code, notes, and snippets.

View telamon's full-sized avatar
🙂
probing for lost signals

Tony Ivanov telamon

🙂
probing for lost signals
View GitHub Profile
@telamon
telamon / JoglInputSystemCustom.java
Created March 26, 2012 23:15
Custom JoglInputSystem
/**
* Suppress mouse events if they hit panel with id "glassPane"
* unless a MouseDragged gesture is in process to ensure that every MouseClickedEvent that hits
* will be followed by an MouseReleasedEvent even if it's coords do not overlap any other nifty elements.
*/
private final JoglInputSystem inputSystem = new JoglInputSystem() {
boolean niftyBusy=false;
@Override
public void mouseDragged(MouseEvent mouseEvent) {
@telamon
telamon / example.txt
Created March 4, 2012 13:21
Minified Sha256 implementation in javascript from: http://www.movable-type.co.uk/scripts/sha256.html
Taken from: http://www.movable-type.co.uk/scripts/sha256.html
Put into: http://closure-compiler.appspot.com/home
exports:
/**
* Generates SHA-256 hash of string
*
* @param {String} msg String to be hashed
* @param {Boolean} [utf8encode=true] Encode msg as UTF-8 before generating hash
@telamon
telamon / mylib.js
Created February 24, 2012 13:05
JavaScript web library pattern
(function(){ // Wrap everything up in a function
var count,person; // These become private to this wrapped scope, and do not clutter the global namespace.
count=0; // Modify private count var,
person= function(name){
this.name = name;
count++;
@telamon
telamon / gobmod.js
Created February 14, 2012 22:15
Quick'n'Dirty FlodJS implementation.
window.gobmod={};
window.gobmod.attachPlayer = function(elem){
elem = $(elem);
var player = new Element('a',{'class':'modplaybutton', href: '#'});
player.innerHTML='>'
elem.insert({top: player});
// Start playback
var startPlayback=function(){
@telamon
telamon / telnet.js
Created February 4, 2012 23:13
Telnet client in node
var net = require('net');
var client = net.connect(parseInt(process.argv[3]),process.argv[2],function(){
client.setEncoding('utf8');
console.log('Connected!!');
client.on('data',function(chunk){
console.log(chunk);
});
process.stdin.resume(); // Activate STDIN
process.stdin.setEncoding('utf8'); // Set it to string encoding
process.stdin.on('data',function(chunk){ // Pipe STDIN to Socket.out
@telamon
telamon / ArduinoExample.pde
Created October 10, 2011 23:32
Arduino+Processing Oscilloscope
#include "oscilloscope.h"
#define ANALOG_IN 0
void setup() {
Serial.begin(9600);
}
void loop() {
int val = analogRead(ANALOG_IN);
@telamon
telamon / socksproxy.js
Created August 5, 2011 12:42
Socks5 proxy implementation in Node.JS
// http://www.ietf.org/rfc/rfc1928.txt
// Tested with: curl http://www.google.se/ --socks5 1080 --proxy-user foo:bar
var States = {
CONNECTED:0,
VERIFYING:1,
READY:2,
PROXY: 3
};
@telamon
telamon / buffer_mapper.rb
Created June 1, 2011 13:38
BufferMapper provides lazy-loading bindings for a binary buffer
module Raumod::BufferMapper
# See http://ruby-doc.org/core/classes/String.html#M001112
# for map types.
def data_map;@data_map;end
def data;@data;end
def data_entry(method)
offset = data_map[method][:offset]
type = data_map[method][:type]
d = data[offset..-1].unpack(type)
@telamon
telamon / gravatar_helper.rb
Created May 24, 2011 17:37
Simple Gravatar helper for Rails
module GravatarHelper
def gravatar_tag(email,*args)
opts = args.extract_options!
opts[:class]||=""
opts[:class]+=" gravatar"
size = opts.delete(:size) || 80
require 'digest/md5'
default=""
@telamon
telamon / effect_rotate.js
Created May 24, 2011 16:46
Effect.Rotate patch for Scriptaculous
Element.getTransform= function (element){
var properties = [
'transform',
'WebkitTransform',
'MozTransform',
'msTransform',
'OTransform'
];
var p;
while (p = properties.shift()) {