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
// Should contain at least 1 number | |
// May contain upper character letters | |
// May contain only four special characters (#$@!) | |
var foo = /^(?:[0-9]+[a-zA-Z]|[a-zA-Z]+[0-9])[a-z0-9#$@!]*$/; |
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 http = require('http'); | |
var app = express(); | |
app.use( | |
function handleError(req, res, next) { | |
var domain = require('domain').create(); | |
res.on('close', function() { | |
domain.dispose(); |
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
// void turns any JavaScript expression to the primitive undefined | |
// Try the following in your browser's console or node REPL | |
// Outputs: undefined | |
console.log(void 0); | |
// Outputs: undefined | |
console.log(void 4); | |
// Outputs: undefined |
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
$("#file").replaceWith($("#file").clone()); |
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
/* | |
* Querying inside an array | |
* | |
* { | |
* "contents": [ | |
* "url": "" | |
* ] | |
* } | |
*/ | |
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 MyClass() { | |
//... | |
} | |
MyClass.prototype.method = function() { | |
//... | |
} | |
function MySubClass() { | |
//... |
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 | |
openssl genrsa -des3 -out server.key 2048 | |
openssl req -new -key server.key -out server.csr | |
cp server.key server.key.org | |
openssl rsa -in server.key.org -out server.key | |
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt | |
mv server.crt ssl.crt | |
mv server.key ssl.key | |
rm server.key.org server.csr |
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 re = /(?![\x00-\x7F]|[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3})./g; | |
var str = "カナダ假借字A�युनिकोड"; | |
str.replace(re, ""); // "A" |
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
!#/usr/bin/node | |
var _ = require('underscore'); | |
var duplicates, uniques, temp; | |
var original = [ | |
{"tags": [{_id: ObjectId(1), name: "tag1"}, {_id: ObjectId(2), name: "tag2"}, {_id: ObjectId(3), name: "tag3"}]}, | |
{"tags": [{_id: ObjectId(2), name: "tag2"}, {_id: ObjectId(4), name: "tag4"}, {_id: ObjectId(3), name: "tag3"}]}, | |
{"tags": [{_id: ObjectId(1), name: "tag1"}, {_id: ObjectId(3), name: "tag3"}, {_id: ObjectId(2), name: "tag2"}]} | |
]; |