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
# set up password less logins | |
cat ~/.ssh/id_rsa.pub | ssh [email protected] "cat >> ~/.ssh/authorized_keys" |
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
(function() { | |
var text = []; | |
$('.list-group .list-group-item').each(function(index, listGroupItem) { | |
text.push($(listGroupItem).find('.list-group-item-number').text() + ' - ' + $(listGroupItem).find('.list-group-item-name .js-navigation-open').text()); | |
}); | |
console.log(text.join("\n")); | |
})(); |
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 | |
# Make executable | |
chmod +x $0; | |
########### | |
# Helpers # | |
########### | |
# test availability of the command |
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/sh | |
wget https://phantomjs.googlecode.com/files/phantomjs-1.9.0-linux-x86_64.tar.bz2 | |
tar xjf phantomjs-1.9.0-linux-i686.tar.bz2 | |
sudo ln -s /usr/local/share/phantomjs-1.9.0-linux-x8664/bin/phantomjs /usr/local/share/phantomjs; sudo ln -s /usr/local/share/phantomjs-1.9.0-linux-x8664/bin/phantomjs /usr/local/bin/phantomjs; sudo ln -s /usr/local/share/phantomjs-1.9.0-linux-x86_64/bin/phantomjs /usr/bin/phantomjs |
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 foo = document.querySelectorAll('a'); | |
foo.map(function(i, v) { | |
var m = v.getAttribute('href'); | |
var c = m && m.match(/(?:watch\?v=([-_a-zA-Z0-9]+))/); | |
return c && c[1]; | |
}); |
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
function createKey(len) { | |
var out = [], rand; | |
len = len || 20; | |
while(len > 0) { | |
rand = Math.round(Math.random() * 123); | |
if ((rand > 47 && rand < 58) || (rand > 64 && rand < 91) || (rand > 96 && rand < 123)) { | |
out.push(rand); | |
len--; | |
} | |
} |
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
(function() { var i = 0;var arr = [];while(i < 16) { arr.push('abcdefghjkmnpqrstuvwyzABCDEFGHJKLMNPQRSTUVWXYZ123456789#$%&*~'[Math.floor(Math.random() * 61)]); ++i; } console.log(arr.join('')); })(); |
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
description "Upstart script to run a nodejs app as a service" | |
author "Louis Chatriot" | |
env NODE_BIN=/usr/local/bin/node | |
env APP_DIR=/path/to/app/dir | |
env SCRIPT_FILE="scriptfile.js" # Entry point for the nodejs app | |
env LOG_FILE=/path/to/logfile.log | |
env RUN_AS="anyuser" # Upstart can only be run nicely as root, need to drop privileges | |
env SERVER_ENV="anything" # Usual apps can be run in different environments (development, test, production ...) | |
# I typically use the environment variable NODE_ENV (see below) |
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
#example upstart script | |
description "Example upstart script" | |
author "detj" | |
# Environment variables | |
env LOG_FILE=/home/debjeet/test.log | |
env NODE_ENV="production" | |
start on filesystem or runlevel [2345] | |
stop on runlevel [016] |
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 | |
#Set up a fresh system | |
#NODE_VERSION="0.10.31" | |
#MONGO_VERSION="2.6.4" | |
ENVIRONMENT="production" | |
#Set up a base tmp directory for installation | |
mkdir -p ~/tmp |