Skip to content

Instantly share code, notes, and snippets.

@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?
function(doc) {
if (doc.content) {
var html = new XML('<foo>bar</foo>');
emit('bar', 1);
}
}
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
@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')
@karmi
karmi / couchapp.html
Created November 27, 2010 16:47 — forked from jchris/couchapp.html
<!DOCTYPE html>
<html>
<!-- This should be the simplest possible jQuery based CouchApp. Install by uploading to a design document in Futon or putting in _attachments/index.html and running `couchapp push` -->
<head><title>Tiny CouchApp</title></head>
<body>
<h1>Tiny CouchApp</h1>
<ul id="databases"></ul>
</body>
<script src="/_utils/script/jquery.js"></script>
<script src="/_utils/script/jquery.couch.js"></script>
@karmi
karmi / aliases_and_mapping.sh
Created January 26, 2011 09:05 — forked from vhyza/elasticsearch_mapping.sh
Mappings for different languages in ElasticSearch indices
# Setup
curl -X DELETE 'http://localhost:9200/news_cs/'
curl -X DELETE 'http://localhost:9200/news_en/'
# Create Czech and English indices (databases)
curl -X PUT 'http://localhost:9200/news_cs/'
curl -X PUT 'http://localhost:9200/news_en/'
# Create mapping for Czech documents
curl -X PUT 'http://localhost:9200/news_cs/_mapping' -d '
curl -XPUT ${host}/_template/template_mail -d '
{
"template" : "*",
"settings" : {
"number_of_shards" : 3,
"number_of_replicas" : 1
},
"mappings" : {
"mail" : {
"_index" : { "enabled" : true },
# ========================================
# Testing multiple analyzers per field
# ========================================
# Setup
curl -s -X DELETE 'http://localhost:9200/news_test/'
# Create index with settings and mapping
curl -s -X PUT 'http://localhost:9200/news_test' -d '
{
module Tire
module Scroll
DEFAULT_SCROLL_DURATION = '1m'
class Scroll
attr_reader :search, :total, :remaining, :counter
def initialize(indices=nil, options={}, &block)
@search = Tire::Search::Search.new(indices, options, &block)
@options = options
@karmi
karmi / Gemfile
Last active August 4, 2021 13:53 — forked from rkh/Gemfile
Sinatra + EventSource JavaScript Streaming
source "http://rubygems.org/"
gem "sinatra", "~> 1.3.0"
gem "thin"