Skip to content

Instantly share code, notes, and snippets.

View lupomontero's full-sized avatar

Lupo Montero lupomontero

View GitHub Profile
(function () {
var a = 'not foo again';
var foo = function (b) {
// do something funky with a and b
};
window.myPlugin = foo;
}());
(function ($) {
var a = 'just-a-classname';
$.fn.myPlugin = function () {
$(this).addClass(a);
};
}(jQuery));
jQuery('a').myPlugin();
$(document).ready(function() {
// Declare variables to hold twitter API url and user name
var twitter_api_url = 'http://search.twitter.com/search.json';
var twitter_user = 'lupomontero';
// Enable caching
$.ajaxSetup({ cache: true });
// Send JSON request
// The returned JSON object will have a property called "results" where we find
<div id="tweet_container"></div>
@lupomontero
lupomontero / app.js
Last active October 11, 2015 03:38
Example nodejs server using express
#!/usr/bin/env node
var express = require('express');
var port = process.argv[2] || 8080;
var ip = process.argv[3] || '127.0.0.1';
var app = express();
app.set('views', __dirname + '/views');
app.set('view engine', 'hbs');
app.use(express.static(__dirname + '/public'));
@lupomontero
lupomontero / gist:3797396
Created September 28, 2012 01:04
Stopping the app (.openshift/action_hooks/stop)
#!/bin/bash
# The logic to stop your application should be put in this script.
kill `ps -ef | grep app.js | grep -v grep | awk '{ print $2 }'` > /dev/null 2>&1
exit 0
@lupomontero
lupomontero / gist:3797403
Last active October 11, 2015 03:38
Starting the app (.openshift/action_hooks/start)
#!/bin/bash
# The logic to start up your application should be put in this
# script. The application will work only if it binds to
# $OPENSHIFT_INTERNAL_IP:8080
HOME=$OPENSHIFT_DATA_DIR nohup $OPENSHIFT_DATA_DIR/nave/nave.sh use 0.10.33 \
$OPENSHIFT_REPO_DIR'app.js' $OPENSHIFT_INTERNAL_PORT $OPENSHIFT_INTERNAL_IP \
> $OPENSHIFT_LOG_DIR/app.log 2>&1 &
@lupomontero
lupomontero / gist:3797411
Last active October 11, 2015 03:38
Get nave if not present and install app's dependencies (.openshift/action_hooks/pre_build)
#!/bin/bash
# This is a simple script and will be executed on your CI system if
# available. Otherwise it will execute while your application is stopped
# before the build step. This script gets executed directly, so it
# could be python, php, ruby, etc.
NAVE=$OPENSHIFT_DATA_DIR/nave/nave.sh
# If `nave` doesn't exist we get it from GitHub.
if [ ! -f $NAVE ]; then
@lupomontero
lupomontero / gist:7233708
Created October 30, 2013 14:34
CouchDB error when adding proxy_authentication_handler to authentication_handlers in CouchDBX (http://janl.github.io/couchdbx/). Note that stacktrace shows paths starting with ""/Users/jan/Work/..." :-S
Marker - 30 Oct 2013 13:56:59
[error] [<0.110.0>] Uncaught error in HTTP request: {error,undef}
[info] [<0.110.0>] Stacktrace: [{couch_httpd_auth,
proxy_authentication_handler,
[{httpd,
{mochiweb_request,
[#Port<0.2980>,'GET',"/_utils/",
{1,1},
{8,
{"host",