Skip to content

Instantly share code, notes, and snippets.

@karmi
karmi / gist:707357
Created November 19, 2010 22:52 — forked from steida/gist:707352
var Change = function (id, doc) {
console.log('new change:', id);
this.id = id;
this.glyph = $('<p title="' + this.url() + '"></p>')
.css({ bottom: this.position() })
.click($.proxy(this.onGlyphClick, this));
this.changes_in_current_period += 1;
$('#changes .interval:last')
class AnnouncementsController < ApplicationController
def index
pagination_options = { :page => params[:page], :per_page => params[:per_page] }
@announcements = Announcement.by_admins( params[:archived], pagination_options )
end
end
function(doc) {
if (doc.content) {
var html = new XML('<foo>bar</foo>');
emit('bar', 1);
}
}
@karmi
karmi / Comments
Created November 5, 2009 08:48 — forked from jsuchal/Comments
# WebPage uses cache??? What the heck is cache in context of a webpage crawling process? It should only crawl pages. You need to inject some dummy cache to prevent caching.
Yeah, that's the assignment as I see it? The crawler crawls and caches stuff it has found and parsed. Your comments are cryptic .)
# thumnail generation is an expensive job, thus lazy-loading. But you are not saving already generated thumbnails in cache. :(
I guess it's pretty obvious the thumbnail stuff is just for illustration, isn't it? But yeah, definitely it should save the generated thumbnail in the cache! But guess what, probably in some hypothetic Thumbnail class? Not in WebPage class?
class Performer
attr_accessor :object, :method_to_call, :parameters_for_method
def initialize(object, method_to_call, *parameters_for_method)
@object, @method_to_call, @parameters_for_method = object, method_to_call, parameters_for_method
end
def perform
puts parameters_for_method.inspect
#!/usr/bin/env ruby
#
# Based on drbfs example by Kent Sibilev
require 'lib/fusefs'
# We're basically just passing all requests on to the local filesystem.
class UfsDirectory
def initialize(dir)
@dir = dir
class KubicekMiddleware
def initialize(app)
@app = app
end
def call(env)
#tohle se vola pred aplikaci
env["REQUEST_URI"]="/welcome"
#zavolame aplikaci
status, headers, response = @app.call(env)
# Czech version
# NOTE: We actually say "Rock-Scissors-Paper" ("Kámen-Nůžky-Papír"), in this order
Kámen
Papír
Nůžky
Raz...Dva...Tři!
Vy: Kámen
@karmi
karmi / gist:51455
Created January 24, 2009 14:38 — forked from lifo/gist:31208
inside('vendor') do
run "ln -s ~/Playground/Rails/rails rails"
end
run "rm public/index.html"
generate(:scaffold, "item name:string")
route "map.root :controller => 'items'"
rake("db:migrate", "development")
@karmi
karmi / init.rb
Created January 23, 2009 10:42 — forked from sr/init.rb
# A Sinatra App as a Rails Plugin
#
# In your Edge Rails app:
#
# ruby script/plugin install git://gist.github.com/50625.git
require 'sinatra/base'
class SinatraRailsPlugin < Sinatra::Base