Skip to content

Instantly share code, notes, and snippets.

View scott2449's full-sized avatar
🍕
🍔🌭🌮🍟

Scott Rahner scott2449

🍕
🍔🌭🌮🍟
  • Dow Jones
  • New Jersey
View GitHub Profile
@scott2449
scott2449 / executor service
Created February 21, 2011 17:37
executor service
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
timer = Executors.newScheduledThreadPool(2);
timer.scheduleAtFixedRate(new Runnable() {
public void run() {
}
}, 0, 300, TimeUnit.SECONDS);
}
@scott2449
scott2449 / Gdl.g
Created February 28, 2011 20:00
antlr grammar to support google partial data api
grammar Gdl;
options{
output=AST;
}
start : fieldlist;
fieldlist : field (COMMA field)* -> field*;
field : STRING L fieldlist R -> ^(STRING fieldlist)
| STRING ;
@scott2449
scott2449 / sample.java
Created February 28, 2011 20:08
sample 'json' data structure in java
TestNode node = new TestNode("what","the","foo",new TestNode[]{
new TestNode("are", "you", "there",new TestNode[]{
new TestNode("are", "you", "there"),new TestNode
("yes", "i","am")
})
,new TestNode("yes", "i", "am")},new TestNode[]{
new TestNode("crap","this","works")
}
);
@scott2449
scott2449 / result.js
Created February 28, 2011 20:09
result of the walked AST
{
name:what,
id:the,
othernodes:{
name:crap
},
nodes:{
other:there,
nodes:{
id:you,
@scott2449
scott2449 / sample.js
Created February 28, 2011 21:02
a node experiment
//server.js
var http = require('http'); //http lib used to build the 'client'
var express = require('express'); //express helps us build the 'server' a bit faster
var app = express.createServer(); //used for serving up the main template and the js model
//app.get('/models/data.js', function(req, res){ res.sendfile(__dirname + '/models/data.js') }) //serve up the model when requested specifically
app.use(express.staticProvider(__dirname + '/models')); //using static provide middleware to serve whole model directory
app.get('/panic', function(req, res){ //perform all this logic when /panic is requested
@scott2449
scott2449 / EnhancedJsonRestStore.js
Created April 25, 2011 13:22
EnhancedJsonRestStore
dojo.declare("custom.EnhancedJsonRestStore", dojox.data.JsonRestStore, {
"-chains-": {
constructor: "manual"
},
constructor : function(options) {
dojo.safeMixin(this,options);
this.service = dojox.rpc.JsonRest.services[options.target] || dojox.rpc.Rest(options.target, true, null, options.getRequest);
@scott2449
scott2449 / ref.js
Created April 26, 2011 02:55
ref.js
//...
var target = defaultObject || it;
//=================================================================================================================================================
// BEGIN - Customizations to produce real RESTful URIs instead from representation hierarchy instead of the shameless excuse for URIs dojo is producing
//=================================================================================================================================================
var targUrl = prefix.substring(0, prefix.length - 1);;
var stack = new Array();
var crawler = target;
if( crawler.__parent && crawler.__parent.id ){
String signed_request = "-BcQzSUqk_dIsNtuurd4kawKsrO2J_WqyL7vDteT3yU.eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImV4cGlyZXMiOjEzMTI5OTkyMDAsImlzc3VlZF9hdCI6MTMxMjk5NDY0OCwib2F1dGhfdG9rZW4iOiIxODM4OTk2NzUwMTEzMDN8Mi5BUUNKX2Y3NlJWamlRQ2FDLjM2MDAuMTMxMjk5OTIwMC4xLTUxMzA1MDY4NnxfYXduR2NoaUdsMkkyNXFOQlpHREpYNnhrdmciLCJ1c2VyIjp7ImNvdW50cnkiOiJ1cyIsImxvY2FsZSI6ImVuX1VTIiwiYWdlIjp7Im1pbiI6MjF9fSwidXNlcl9pZCI6IjUxMzA1MDY4NiJ9";
String rawpayload = signed_request.split("\\.")[1];
String signature = signed_request.split("\\.")[0].replace("-", "+").replace("_", "/").trim();
String facebookSecret = "3035c2fd47ddbff344d55fb878d2cfa7";
BASE64Decoder decoder = new BASE64Decoder();
//Ouput payload
System.out.println(new String(decoder.decodeBuffer(rawpayload.replace("-", "+").replace("_", "/").trim())));
@scott2449
scott2449 / dog.js
Created June 19, 2012 18:45 — forked from sandeep45/dog.js
example of inheriting EventEmitter in node
var emitter = require('events').EventEmitter;
var util = require('util');
var dog = function(){};
//dog.prototype = {
// name: "i am a dog",
//};
// 1st way of inheriting
//dog.prototype.__proto__ = new emitter();
@scott2449
scott2449 / config
Created March 20, 2015 15:27
consul setup
#/etc/consul.d/config.json
{
"server" : true,
"node_name" : "ep-server",
"bootstrap_expect" : 1,
"data_dir" : "/tmp/consul",
"ports" : {
"dns" : 53
}
}