Skip to content

Instantly share code, notes, and snippets.

View adomado's full-sized avatar

AdoMado.com adomado

View GitHub Profile
@adomado
adomado / nodejs_recipe.rb
Created October 20, 2011 10:23 — forked from chris/nodejs_recipe.rb
Chef recipe to install node.js on Engine Yard AppCloud
#
# Cookbook Name:: nodejs
# Recipe:: default
#
# Build and install node.js
#
if ['app','app_master','solo'].include?(node[:instance_role])
version_tag = "v0.4.8"
source_base_dir = "/data/nodejs"
@adomado
adomado / gist:1241736
Created September 26, 2011 06:49
Bash script (goes in ~/.bashrc) to display git branch name
############### GIT ################
function parse_git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo "("${ref#refs/heads/}")"
}
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
@adomado
adomado / gist:1226159
Created September 19, 2011 08:41
Example mongodb script
db = connect("localhost:27017/test");
var cursor = db.unicorns.find({gender : "m"});
var total = 0;
while(cursor.hasNext()) {
var obj = cursor.next();
total += (obj.hits || 0);
}
print(total);
@adomado
adomado / content_script.js
Created August 5, 2011 16:15
Myshaadi.in app
(function(config) {
var MyShaadi = {
auth : function(username, password, successCb, errorCb) {
var endpoint = "http://myshaadi.in/api/users/index.php?action=authenticateUser&resp_type=jsonp&username=" +
username + "&password=" + password;
$j.ajax({
url : endpoint,
dataType : "jsonp",
@adomado
adomado / hello_world.js
Created June 27, 2011 09:32
Hello World App - AdoMado Apps Platform
/**
*
* Boilerplate code, used internally by the platform
*
* Notice the **config** variable being passed into the self-executing anonymous function.
*
* **config.api** object is an instance of the IJAppApi.v1 class.
* Any public methods present in the [IJAppApi.v1](../api/v1.html) can be called on config.api object
*
*/
@adomado
adomado / mapreduce.js
Created May 8, 2011 06:39
Simple MapReduce with Javascript
var Job = {
data : [
"We are glad to see you here. This site is dedicated to",
"poetry and to the people who make poetry possible",
"poets and their readers. FamousPoetsAndPoems.com is",
"a free poetry site. On our site you can find a large",
"collection of poems and quotes from over 631 poets",
"Read and Enjoy Poetry",
"I, too, sing America",
@adomado
adomado / gist:943909
Created April 27, 2011 08:20
FBNotificationWatcher_without_jQuery.proxy
var FBNotificationWatcher = new JS.Class({
initialize : function(timeout) {
this.url = "http://foo/return/json";
this.getNotifications(); // initiate the first fetch
},
getNotifications : function() {
var url = this.url;
var Foo = {
init : function() {
Foo.getLocation(Foo.showLocation, this);
},
showLocation : function(data) {
console.log("In showLocation callback => " + JSON.stringify(data));
},
var FBFeed = new JS.Class({
include : Storage,
initialize: function(callingContext, feedUrl, feedReadyCallback) {
this.feedReadyCallback = feedReadyCallback;
this.callingContext = callingContext;
this.getFeed(feedUrl, feedReadyCallback);
},
$(function() {
// Model
window.FeedItemModel = Backbone.Model.extend({
initialize : function(id, graph) {
this.id = id;
this.graph = graph;
},