Skip to content

Instantly share code, notes, and snippets.

View auth
var http = require('http');
http.createServer(function (req, res) {
if (!authorized(req, res, ['admin'])) {
res.statusCode = 401;
res.end("You don't have permissions");
}
res.statusCode = 200;
res.end('Welcome back!');
@oren
oren / gist:6980348
Created Oct 14, 2013
testling issue
View gist:6980348
on iMac:
$ browserify test.js | testling
events.js:72
throw er; // Unhandled 'error' event
^
Error: spawn ENOENT
at errnoException (child_process.js:980:11)
at Process.ChildProcess._handle.onexit (child_process.js:771:34)
View gist:6803198
diff --git a/tests/models/listing_test.js b/tests/models/listing_test.js
index 14c3d14..c04b7a6 100644
--- a/tests/models/listing_test.js
+++ b/tests/models/listing_test.js
@@ -10,6 +10,7 @@ var dict = {
'Name': 'CPK',
'HeadingText': 'Restaurants',
'PrimaryCollection': 'food',
+ 'Personalization.TotalNotes': '10'
};
View router.js
// The server's main routes function
//
// Supports the following end-points:
// POST /push
// POST /register
// POST /register.php
// GET /health
// GET /health.txt
function router(config, req, res) {
@oren
oren / simulator.js
Created Jul 17, 2012
functional test
View simulator.js
// Elphi System Simulator in Node.js
// TODO: check failure case
// 0) request times
// 0) server hangs
// 0) HTTP request timeouts where we never get a response
// 1) no api
// 2) no proxy on
// 3) plugs unresponsive
View gist:999737
goal:
-----
return an array of names that start with j and sorted by id
["josh", "jordan"]
arr = [{name: 'jordan',id: 3}, {name: 'josh',id: 1}, {name: 'rob',id: 5}]
1)
arr.select!{ |a| a[:name][/\Aj/] }
View gist:878569
Sinatra project structure
app.rb # require sinatra, haml, vendor'd gems, models/init, routes/init, helpers/init
helpers/
init.rb # Requires each helper file
helper1.rb # Related helper methods
models/
init.rb # Require sequel, set up the DB; require each model, in controlled order
View gist:855818
[2011-03-04 13:58:31] GEM_PATH="/home/oren/.rvm/gems/ruby-1.9.2-p180:/home/oren/.rvm/gems/ruby-1.9.2-p180@global:/home/oren/.rvm/gems/ruby-1.9.2-p180@global" GEM_HOME="/home/oren/.rvm/gems/ruby-1.9.2-p180" "/home/oren/.rvm/rubies/ruby-1.9.2-p180/bin/ruby" "/home/oren/.rvm/src/rubygems-1.5.2/setup.rb"
RubyGems 1.5.2 installed
=== 1.5.2 / 2011-02-10
NOTE: RubyGems 1.5.0 and 1.5.1 have a broken <tt>gem update --system</tt>.
To upgrade you'll need to use the manual upgrade recipe. Using sudo/su as
appropriate:
View gist:855932
qa.rb
-----
default_environment['PATH']='$HOME/.rvm/bin:$PATH'
set :application_directory, "test_project"
set :rails_env, "qa"
set :main_server, 'ogolan'
server "#{main_server}", :web, :app, :db, :primary => true
set :deploy_to, "/srv/#{application_directory}"
View .rvmrc issue
.rvmrc don't change ruby/gemset:
capdeploy@cms:~$ cd /srv/media_qa/current
+ cd /srv/media_qa/current
+ builtin cd /srv/media_qa/current
+ local result=0
+ __rvm_project_rvmrc
+ local cwd
+ cwd=/srv/media_qa/current
+ :