Skip to content

Instantly share code, notes, and snippets.

View Stanley's full-sized avatar

Stanisław Wasiutyński Stanley

View GitHub Profile
function irb( input ){
jQuery.ajaxSetup({
async: false
});
var baseUrl = "http://tryruby.hobix.com/irb";
var params = {cmd: "!INIT!IRB!"};
jQuery.get( baseUrl, params);
module Rack
class ChromeFrame
def initialize(app, options={})
@app = app
@options = options
end
def call(env)
@Stanley
Stanley / couch_foo.rb
Created April 26, 2010 19:38
Sample ruby CouchDB libraries
# CRUD
CouchFoo::Base.set_database(:host => "http://localhost:5984", :database => "krug")
class Address < CouchFoo::Base
property :number, Integer
property :street, String
property :postcode
end
require 'em-proxy'
Proxy.start(:host => "127.0.0.1", :port => 8080) do |conn|
@start = Time.now
@data = Hash.new("")
conn.server :prod, :host => "db.wasiutynski.net", :port => 80 # production, will render resposne
conn.server :test, :host => "127.0.0.1", :port => 5984 # testing, internal only
conn.on_data do |data|
// Author: Stanisław Wasiutyński
// Date: 14.07.2010
(function($){
$.fn.big_preview = function(img_url, opts) {
var defaults = {
on_wait: "Please wait...",
show_all: true,
show_all_label: "Click to fit image to screen",
curl -X PUT localhost:5984/test &&
curl -X PUT localhost:5984/test/_design/demo -d @view.json &&
curl -X PUT localhost:5984/test/1 -d '{"foo": "foo"}' &&
curl localhost:5984/test/_design/demo/_view/two
var http = require('http');
var couchdb = http.createClient(5984, 'localhost');
// PUT method works correctly
// var request = couchdb.request('PUT', '/test/test', {
// POST returns 415: {"error":"bad_content_type","reason":"Content-Type must be application/json"}
var request = couchdb.request('POST', '/test', {
"host": "localhost",
"Content-Type": "multipart/related;boundary=\"frontier\""
});
var http = require('http'),
couchdb = http.createClient(5984, 'localhost'),
uuid = require('node-uuid');
var id = uuid().replace(/-/g, '');
var request = couchdb.request('PUT', '/test/'+id +'?batch=ok', {
"host": "localhost",
"Content-Type": "multipart/related;boundary=\"frontier\""
});
TypeError: Bad argument.
at Buffer.toString (buffer.js:263:26)
at Object.readFileSync (fs.js:126:33)
at Object..js (module.js:292:44)
at Module.load (module.js:219:31)
at Function._load (module.js:186:10)
at require (module.js:231:19)
at getDefaultParser (/home/github/jsdom/lib/jsdom/browser/index.js:175:23)
at Object.browserAugmentation (/home/github/jsdom/lib/jsdom/browser/index.js:199:33)
at Object.jsdom (/home/github/jsdom/lib/jsdom.js:33:25)