Skip to content

Instantly share code, notes, and snippets.

View jonatasnona's full-sized avatar
🇧🇷
Working from home

Jonatas Pedraza jonatasnona

🇧🇷
Working from home
View GitHub Profile
// database.js file
var client = require("mongodb").MongoClient;
client.connect('mongodb://127.0.0.1:27017/foodb', function (err, db) {
if (err) {
throw err;
}
exports.users = db.collection("users");
@jonatasnona
jonatasnona / hash.c
Created April 29, 2014 22:16 — forked from tonious/hash.c
#define _XOPEN_SOURCE 500 /* Enable certain library functions (strdup) on linux. See feature_test_macros(7) */
#include <stdlib.h>
#include <stdio.h>
#include <limits.h>
#include <string.h>
struct entry_s {
char *key;
char *value;
let s:N1 = [ '#141413' , '#aeee00' , 232 , 154 ] " blackestgravel & lime
let s:N2 = [ '#f4cf86' , '#45413b' , 222 , 238 ] " dirtyblonde & deepgravel
let s:N3 = [ '#8cffba' , '#242321' , 121 , 235 ] " saltwatertaffy & darkgravel
let s:N4 = [ '#666462' , 241 ] " mediumgravel
let s:I1 = [ '#141413' , '#0a9dff' , 232 , 39 ] " blackestgravel & tardis
let s:I2 = [ '#f4cf86' , '#005fff' , 222 , 27 ] " dirtyblonde & facebook
let s:I3 = [ '#0a9dff' , '#242321' , 39 , 235 ] " tardis & darkgravel
let s:V1 = [ '#e2e2e2' , '#4f3598' , 254 , 56 ] " blackestgravel & orange
# **postinstall.sh** is a script executed after Debian/Ubuntu has been
# installed and restarted. There is no user interaction so all commands must
# be able to run in a non-interactive mode.
#
# If any package install time questions need to be set, you can use
# `preeseed.cfg` to populate the settings.
### Setup Variables
# The version of Ruby to be installed supporting the Chef and Puppet gems
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
#!/bin/bash -e
sudo pip install redis
@jonatasnona
jonatasnona / gist1994877
Created March 7, 2012 19:00
Javascript: UserAgent
<script>
var ua = navigator.userAgent;
var checker = {
ios: ua.match(/(iPhone|iPod|iPad)/),
blackberry: ua.match(/BlackBerry/),
android: ua.match(/Android/),
windowsphone: ua.match(/Windows Phone/)
};
$(document).ready(function() {
@jonatasnona
jonatasnona / gist:1995269
Created March 7, 2012 19:20
GIT: Commiters Rank
git shortlog -s -n
@jonatasnona
jonatasnona / snippet.js
Created March 9, 2012 20:28 — forked from necolas/snippet.js
Optimised async loading of cross-domain scripts
/*
* Updated to use the function-based method described in http://www.phpied.com/social-button-bffs/
* Better handling of scripts without supplied ids.
*
* N.B. Be sure to include Google Analytics's _gaq and Facebook's fbAsyncInit prior to this function.
*/
(function(doc, script) {
var js,
fjs = doc.getElementsByTagName(script)[0],
@jonatasnona
jonatasnona / gist:2050388
Created March 16, 2012 14:48
Javascript: Sort an Array of Objects by Properties
// thanks to daniel walsh
// http://davidwalsh.name/array-sort
// http://dochub.io/#javascript and search for sort to see more details
// sort by age
var o = [{name : "Robin Van Persie", age: 28},
{name : "Theo Walcott", age : 22},
{name : "Bacary Sagna", age : 26}
].sort(function(obj1, obj2) {
return obj1.name - obj2.name;