Skip to content

Instantly share code, notes, and snippets.

var MongoClient = require('mongodb').MongoClient;
function MongoSingle (addr, options, cb) {
if (addr === undefined && process.env.MONGO_URL !== undefined) addr = process.env.MONGO_URL;
if (options instanceof Function) {
cb = options;
options = null;
}
if (addr === undefined) {
@elbuo8
elbuo8 / doapi.sh
Created November 30, 2013 01:58
Simple script to get all the Ansible requirements for DigitalOcean
endpoints=(sizes regions images ssh_keys)
for i in "${endpoints[@]}"; do
url=`printf "https://api.digitalocean.com/%s/?client_id=%s&api_key=%s" $i $DO_CLIENT_ID $DO_API_KEY`
curl $url | python -mjson.tool
done
tarname = os.getcwd() + '/' + data['name'] + '.tgz'
tar = tarfile.open(tarname, 'w:gz')
for filename in os.listdir(os.getcwd()):
tar.add(filename)
tar.close()
print tarname
files = {'file': open(tarfile, 'rb')}
@elbuo8
elbuo8 / Sample data
Last active December 20, 2015 17:48
Trolololo
{
github: {
username: "elbuo8"
picture: "ballz",
languages: {"Java": 1, "Coffee": 3, "Python": 7, "Go": 1},
points: 75,
repos: 4,
followers: 7
},
stackoverflow: {
@elbuo8
elbuo8 / gist:5722666
Created June 6, 2013 16:01
Get dependencies in Jenkins
request = require 'request'
cheerio = require 'cheerio'
deps = ["git" ,
"github",
"ssh",
"monitoring",
"favorite",
"gravatar",
@invite = (email, agencyId, callback) ->
(app.get 'users').findOne {email: email}, (error, existingUser) ->
if existingUser
(app.get 'users').update {_id: existingUser._id},
{$addToSet:{agencies:agencyId}}, (error) ->
addToTeam agencyId, existingUser._id, (error) ->
console.log 'here'
app.EmailHandler.invite email, agencyId, ->
callback()
import sys
file = open(sys.argv[1])
for line in file:
cacheLine = line.strip().replace(' ', '')
if (len(cacheLine[:-1]) >= int(cacheLine[-1])):
print cacheLine[::-1][int(cacheLine[-1])]
extends layout
block content
div#form
input#userID(type='text', name='user', placeholder='enter username')
br
textarea(type='textarea', name='text', placeholder='enter tweet', id='tweet')
br
button#submitTweet(type='button') Tweet
var async = require('async'); //Dat speed
exports.loadAudioDefault = function(req, res)
{
//This route returns a json object with an array of all the MongoDB documents
//returned by the query. These documents are audio files.
this.db.collection('audio', function(err, collection)
{
var audio = {
'audio':[],
'settings':{
package main
import (
"fmt"
"io/ioutil"
"net/http"
"github.com/codegangsta/negroni"
jwt "github.com/dgrijalva/jwt-go"
"github.com/gorilla/mux"