Skip to content

Instantly share code, notes, and snippets.

@joachimkainz
joachimkainz / gist:3165148
Created July 23, 2012 18:17
encrypt/decrypt with node.js
var SECRET = 'R4@DtoelECf0',
CIPHER = 'aes-256-cbc',
crypto = require('crypto'),
cipher = crypto.createCipher(CIPHER, SECRET),
decipher = crypto.createDecipher(CIPHER, SECRET);
function encrypt(message) {
var crypted = cipher.update(message, 'utf8', 'hex');
return crypted + cipher.final('hex');
@joachimkainz
joachimkainz / gist:2732566
Created May 19, 2012 22:18
Home directory on node
function getHome() {
return process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'];
}
@joachimkainz
joachimkainz / gist:2661267
Created May 11, 2012 17:42
iPhone Metas for the Site-Manager
defaults.metas = [
{
"name":"description",
"content":"Some useful description"
},
{
"name":"apple-mobile-web-app-capable",
"content":"yes"
},
{
@joachimkainz
joachimkainz / gist:2655406
Created May 10, 2012 19:45
Selecting the current time in Oracle
SELECT TO_CHAR(SYSDATE, 'DD-Mon-YYYY') FROM Dual;
@joachimkainz
joachimkainz / gist:2533908
Created April 29, 2012 06:02
convert arguments to array
var args = Array.prototype.slice.call(arguments);
@joachimkainz
joachimkainz / gist:2002240
Created March 8, 2012 17:33
Add to PhoneGap's AppDelegate in - (void) webViewDidFinishLoad:(UIWebView*) theWebView to prevent the scrolling that reveals the app as a hybrid app
theWebView.scrollView.bounces = NO;
@joachimkainz
joachimkainz / gist:1526919
Created December 28, 2011 07:15
asynchronous "rm -rf" for Node.js
function rmrf(dir, callback) {
fs.stat(dir, function(err, stats) {
if (err) {
return callback(err);
}
if (!stats.isDirectory()) {
return fs.unlink(dir, callback);
}
@joachimkainz
joachimkainz / gist:1447687
Created December 8, 2011 17:19
Basic JavaScript Type Tests
function isNumeric(x) {
return x === +x;
}
function isString(x) {
return Object.prototype.toString.call(x) == '[object String]';
}
@joachimkainz
joachimkainz / gist:1357460
Created November 11, 2011 07:44
kill all queries in mongo
db.currentOP().inprog.forEach(function(v){if (v.op == "query") { db.killOP(v.opid);}});