Skip to content

Instantly share code, notes, and snippets.

@JakubOboza
JakubOboza / gist:1454977
Created December 10, 2011 11:48
Node.js File Upload
// from : http://www.componentix.com/blog/9/file-uploads-using-nodejs-now-for-real
var http = require("http");
var url = require("url");
var multipart = require("multipart");
var sys = require("sys");
var events = require("events");
var posix = require("posix");
var server = http.createServer(function(req, res) {
@JakubOboza
JakubOboza / installing-ghc7.2-osx10.7.md
Created December 10, 2011 12:14 — forked from beastaugh/installing-ghc7.2-osx10.7.md
Installing GHC 7.2 on Mac OS X 10.7 Lion

Installing GHC 7.2 on Mac OS X

This is a brief and bare-bones guide to getting GHC 7.2 and the cabal-install tool (the two basic things you'll need to do Haskell development) up and running on a new Mac OS X 10.7 install.

The instructions given here worked for me, but YMMV.

proxy_cache_path /var/www/cache levels=1:2 keys_zone=my-test-cache:8m max_size=5000m inactive=300m;
server {
location / {
proxy_pass http://127.0.0.1:3000;
proxy_cache my-test-cache;
proxy_cache_valid 200 302 60m;
proxy_cache_valid 404 1m;
}
}
@JakubOboza
JakubOboza / 0_README.md
Created January 18, 2012 11:13 — forked from netzpirat/0_README.md
Continuous CoffeeScript testing with Guard and Jasmine

Continuous CoffeeScript testing with Guard and Jasmine

This Gist shows how to set up a Rails project to practice BDD with CoffeeScript, Guard and Jasmine. You can see this setup in action on Vimeo

  • Install Gems with Bundler with bundle install
  • Define your guards with mate Guardfile
  • Initialize Jasmine with bundle exec jasmine init
  • Configure Jasmine with mate spec/support/yasmine.ym
  • Start Guard with bundle exec guard
@JakubOboza
JakubOboza / example.js
Created January 18, 2012 15:50
map over heavy tasks to not block event loop
mapHeavy([1,2,3,4,5,6], function(e){setTimeout(function(){console.log(e);}, 1000);});
mapHeavy([10,20,30,40,50,60], function(e){setTimeout(function(){console.log(e);}, 500);});
~/magellano/current$ bundle exec rake db:migrate --trace
Invalid gemspec in [/usr/local/lib/ruby/gems/1.9.1/specifications/json-1.6.1.gemspec]: invalid date format in specification: "2011-09-18 00:00:00.000000000Z"
Importer needs env to startup
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
undefined method `each' for nil:NilClass
/home/vagrant/magellano/shared/bundle/ruby/1.9.1/gems/actionpack-3.2.0/lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb:68:in `register_javascript_expansion'
/home/vagrant/magellano/shared/bundle/ruby/1.9.1/gems/actionpack-3.2.0/lib/action_view/railtie.rb:21:in `block (2 levels) in <class:Railtie>'
console.log("Oh hai")
function not_retarded_fib(n){
if(n < 3){
return 1;
}
var learn_dynamic_programming = [1,1];
for (var i = 2; i <= n; i++){
learn_dynamic_programming[i] = learn_dynamic_programming[i - 1] + learn_dynamic_programming[i - 2];
@JakubOboza
JakubOboza / gist:1780601
Created February 9, 2012 15:11
gravatar link generator
#!/usr/bin/env node
var email = process.argv[2];
var crypto = require('crypto');
function trim (str) {
var str = str.replace(/^\s\s*/, ''),
ws = /\s/,
i = str.length;
while (ws.test(str.charAt(--i)));
@JakubOboza
JakubOboza / request post node.js
Created February 10, 2012 00:01 — forked from alessioalex/request post node.js
request post node.js
var request = require('request'), default_headers, site_root = 'http://localhost:3000';;
default_headers = {
'User-Agent': 'Mozilla/5.0 (X11; Linux i686; rv:7.0.1) Gecko/20100101 Firefox/7.0.1',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language': 'en-us,en;q=0.5',
'Accept-Encoding': 'gzip, deflate',
'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
// 'Connection': 'keep-alive',
'Cache-Control': 'max-age=0'
@JakubOboza
JakubOboza / gist:1788925
Created February 10, 2012 11:33
guts out
var site_url = 'http://www.pudelek.pl/';
var default_headers = {
'User-Agent': 'Mozilla/5.0 (X11; Linux i686; rv:7.0.1) Gecko/20100101 Firefox/7.0.1',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language': 'en-us,en;q=0.5',
'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
'Cache-Control': 'max-age=0'
};