Skip to content

Instantly share code, notes, and snippets.

@JakubOboza
JakubOboza / gist:2250602
Created March 30, 2012 10:18
erlang json resource for webmachine
%% @author Bryan Fink
%% @doc formjson_resource takes x-www-form-urlencoded data and
%% re-encodes it as JSON. The data is expected as query
%% parameters for a GET, and request body for a POST.
%%
%% ```
%% In: one=two&me=pope
%% Out: {"one":"two","me":"pope"}
%% '''
-module(formjson_resource).
@JakubOboza
JakubOboza / gist:2244199
Created March 29, 2012 22:03
infinite scroll shit
$(window).scroll(function(){
if($(window).scrollTop() == $(document).height() - $(window).height()){
handler();
}
});
function handler(){
alert('Pong');
}
9:40 joboza@admins-MacBook-Pro:~/Workspace/Ruby/webadapter/tmp λ cat lol.rb
# encoding: UTF-8
alias :λ :lambda
foo = λ { puts "fuck yeah" }
foo[]
class SkyFoo
def ✈
@JakubOboza
JakubOboza / run.sh
Created March 28, 2012 08:11
new_lambda.rb
# encoding: UTF-8
alias :λ :lambda
foo = λ { puts "fuck yeah" }
foo[]
@JakubOboza
JakubOboza / gist:2071805
Created March 18, 2012 12:59
mongodb push / pushall / pop
var document = { name: "jakub", surname: "oboza", games: []};
db.people.save(document);
var person = db.people.findOne({name: "jakub"});
person
{
"_id" : ObjectId("4f65da9d8199c991088c9ca4"),
"name" : "jakub",
"surname" : "oboza",
"games" : [ ]
}
<VirtualHost *:80>
ServerName web1.webadapter.migapps.com
RewriteEngine On
<Proxy balancer://londondc>
BalancerMember http://loadbalancer.webadapter.migapps.com
</Proxy>
ProxyPass / balancer://londondc/
So we had modeling done this way:
You use mongodb "like" relational db while editing and forming thing to publish and when you publish you are producing one document with embedded document.
like this
[Car] -> has many via dbrefs -> [Part]
produces
[CarSnapshot] -> has many via embedded doc -> [Part]
http://example.com/cgi-bin/toons_awk_web_service.sh/toons
// callback
fs.readFile('/tmp/largefile', function (err, data) {
if (err) throw err;
process_content(data);
});
// bloating
var data = fs.readFileSync("/tmp/largefile");
process_content(data);
@JakubOboza
JakubOboza / gist:2008958
Created March 9, 2012 22:05
faye as subdomain
upstream faye {
server 127.0.0.1:9292;
}
upstream webrick{
server 127.0.0.1:3000;
}
server {
listen 80 default;