Skip to content

Instantly share code, notes, and snippets.

View adomado's full-sized avatar

AdoMado.com adomado

View GitHub Profile
@adomado
adomado / gist:879094
Created March 21, 2011 05:53
Blueprint error
0:35 ~/test_workspace/blueprint $ blueprint create warrior -S
# [blueprint] searching for Python packages
# [blueprint] searching for configuration files
Traceback (most recent call last):
$(function() {
// Model
window.FeedItemModel = Backbone.Model.extend({
initialize : function(id, graph) {
this.id = id;
this.graph = graph;
},
var FBFeed = new JS.Class({
include : Storage,
initialize: function(callingContext, feedUrl, feedReadyCallback) {
this.feedReadyCallback = feedReadyCallback;
this.callingContext = callingContext;
this.getFeed(feedUrl, feedReadyCallback);
},
var Foo = {
init : function() {
Foo.getLocation(Foo.showLocation, this);
},
showLocation : function(data) {
console.log("In showLocation callback => " + JSON.stringify(data));
},
@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;
@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 / 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 / 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 / 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 / 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\]"