Skip to content

Instantly share code, notes, and snippets.

@bithavoc
bithavoc / home.js
Created July 26, 2011 07:17
Sample pseudo action
// pseudo Loader: https://github.com/firebaseco/pseudo
// actions/home.js
var pseudo = require('pseudo')
pseudo.get('/', {
filters:['requireLogin'],
action:function(req, res) {
var greeting = this.customContext // use custom context bound values
// render some view for the home page
@bithavoc
bithavoc / gist:1196206
Created September 5, 2011 23:58
Upstart Configuration File to run a Node.JS App on a Production Service
#!upstart
description "Website at 0.0.0.0:80"
author "Johan<johan@firebase.co>"
start on runlevel 3
stop on shutdown
script
cd /home/ec2-user/website/ #path to the folder with app.js file
export NODE_ENV=production #which environment?
@bithavoc
bithavoc / nodejs_asymm_crypto_sample.js
Created October 20, 2011 02:17
Asymmetric Encryption Sample in Node.js: Encrypt and Decrypt using Password as a key(SECRET_KEY) / Triple-DES
/*
Asymmetric Encryption Sample in Node.js: Encrypt and Decrypt using Password as a key(SECRET_KEY)
Algorithm: des-ede3-cbc (Three key Triple-DES EDE in CBC mode)
johan@firebase.co
@thepumpkin
*/
var assert = require('assert')
var crypto = require('crypto')
var Buffer = require('buffer').Buffer
{
"name": "firebase",
"version": "0.0.1-27",
"scripts": {
"start": "node app.js"
},
"domains": [
"firebase.co"
],
"subdomain": "firebase",
@bithavoc
bithavoc / hello.d
Created March 30, 2012 19:26
ThePumpkinLearningD
#!/usr/bin/rdmd
import std.stdio;
void main() {
writeln("Hello World!");
}
DEBUG: Error: Hello Error
at Object.<anonymous> (/Users/thepumpkin/Projects/testCarapace/app.js:38:7)
at Module._compile (module.js:446:26)
at Object..js (module.js:464:10)
at Module.load (module.js:353:31)
at Function._load (module.js:311:12)
at Array.0 (module.js:484:10)
at EventEmitter._tickCallback (node.js:190:38)
{
"process": {
"pid": 30482,
"uid": 501,
"gid": 20,
"cwd": "/Users/thepumpkin/Projects/testCarapace",
"execPath": "/usr/local/bin/node",
"version": "v0.6.18",
"argv": [
"node",
@bithavoc
bithavoc / file.md
Created November 24, 2012 18:13 — forked from guilleiguaran/file.md
Why Google V8 is not suited for integration into servers

Why Google V8 is not suited for integration into servers

06/09/2010

Last time I studied the ability to embed javascript in nginx using the library Google V8 Javascript Engine , it should be noted, was no easy task, as all that complicated the classic "Hello World!", reflected in the documentation is extremely sketchy. Because V8 developed primarily for Chrome, then this left a significant imprint on him and, to paraphrase Henry Ford's statement about the color of the machine, it can be said that the V8 will work well in any application, provided that this program is called Chrome.

First of all, V8 does not know how to handle memory allocation errors - it just ends the process. This is acceptable for such a browser like Chrome, which displays each page in a separate process, and the crash of one process does not affect the other pages, but for the server to process in one process thousands of simultaneous connections, it does not fit. While V8 allows you to set your own error handler memory allocation, howe

@bithavoc
bithavoc / command.sh
Last active December 10, 2015 23:08
Creating and Executing Fauna Commands
echo "Updating Command Definition"
curl https://rest.fauna.org/v0/commands/reply_message -X PUT -u AQAAS6hRHMAAAABB9FVmsAAAXH9CRKgC6N801bp80lKB1g: -d '{ "comment": "Reply a Message", "actions":[{"method":"POST", "path":"/v0/instances", "body":{ "class":"message", "data":{ "body":"$body" } } }]}'
echo "Invoking Command (now using a user Token)"
curl https://rest.fauna.org/v0/commands/reply_message -X POST -u AQIAT9qymjAAAABJd3D_AAAAAEH0VWawAAABAEbK2k9gAABuUBqDLSjdEsmvUUWrxE_zAAAAAAAAAA: -d '{ "body": "My message" }'
@bithavoc
bithavoc / command definition.js
Last active December 10, 2015 23:30
Command with Fauna Sub Requests
// POST /commands result
{
"resource" : {
"ref" : "commands/reply_message",
"ts" : 1357900098422864,
"name" : "reply_message",
"comment" : "Reply a Message",
"actions" : [ {
"method" : "POST",
"path" : "/v0/instances",