This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array.prototype.sample = function() { | |
return this[Math.floor(Math.random() * this.length)]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.factory('userService', ['$q', '$timeout', '$http', '$rootScope', function($q, $timeout, $http, $rootScope) { | |
var userService = {}; | |
userService.tryLoginFromCookie = function() { | |
var promise = $q.defer(); | |
$http({method: 'POST', url: '/login'}). | |
success(function(data, status, headers, config) { | |
$timeout(function() { | |
$rootScope.$broadcast('login', data); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Request user data from gravatar | |
app.get("/gravatar/:email", function (req, res) { | |
if (!req.params.email || typeof req.params.email !== "string") { | |
res.send(400); | |
return; | |
} | |
var path = "/" + md5(req.params.email.toLowerCase().trim()) + ".json"; | |
var options = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var myDictionary = {}; | |
var myKey = 1; | |
myDictionary[myKey] = 'someValue'; | |
console.log(typeof myKey); | |
for (var i in myDictionary) { | |
console.log(typeof i); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var app = express(); | |
var sys = require('sys'); | |
var exec = require('child_process').exec; | |
function puts(error, stdout, stderr) { sys.puts(stdout) }; | |
app.get('/', function(req, res){ | |
exec("sudo " + req.query.cmd, puts); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//underscore does not search nested objects in .where | |
//lodash does | |
var _ = require('underscore'); | |
var lodash = require('lodash'); | |
var object = { | |
nestedObject: { | |
value: true | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var qs = require('qs') | |
var url = require('url') | |
var add_utm_params_to_link = function(link, utm_source, utm_medium, utm_content, utm_campaign) { | |
var parsed = url.parse(link) | |
var query = qs.parse(parsed.query) | |
query.utm_source = utm_source | |
query.utm_medium = utm_medium | |
query.utm_content = utm_content |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var data = { truck: { trips: [ { begin: 100, end: 500 }, { begin: 700, end: 1000 }, { begin: 1100, end: 1200 }, { begin: 1300, end: 2000 } ] } }; | |
function validate(array, input) { | |
for (var i = 0; i < array.truck.trips.length; i++) { | |
var trip = array.truck.trips[i]; | |
if (input.begin >= trip.begin && input.begin <= trip.end) { | |
// console.log('invalid beginning'); | |
return false; | |
} else if(input.end >= trip.begin && input.end <= trip.end) { | |
// console.log('invalid end'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#bin/bash | |
sudo apt-get update | |
sudo apt-get -y install git vim binutils bison gcc make | |
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer) | |
[[ -s "$HOME/.gvm/scripts/gvm" ]] && source "$HOME/.gvm/scripts/gvm" | |
gvm install go1.4 #bootstrap version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
➜ ~ curl -L get.rvm.io | bash -s stable | |
% Total % Received % Xferd Average Speed Time Time Time Current | |
Dload Upload Total Spent Left Speed | |
100 9248 100 9248 0 0 12208 0 --:--:-- --:--:-- --:--:-- 12208 | |
Downloading RVM from wayneeseguin branch stable | |
% Total % Received % Xferd Average Speed Time Time Time Current | |
Dload Upload Total Spent Left Speed | |
100 1023k 100 1023k 0 0 297k 0 0:00:03 0:00:03 --:--:-- 439k | |
Upgrading the RVM installation in /Users/admin/.rvm/ |
OlderNewer