Skip to content

Instantly share code, notes, and snippets.

@wbzyl
wbzyl / X-cz.txt
Created April 22, 2011 16:17 — forked from karmi/X-cz.txt
Playing with Language Classification with N-Grams in Ruby
Druhá světová válka
Z Wikipedie, otevřené encyklopedie
Druhá světová válka
Animace vývoje války v Evropě
Trvání: 1. září 1939 – 2. září 1945
Místo: Evropa, Středomoří, Afrika, Tichomoří, Jihovýchodní Asie, Čína, Střední východ
Výsledek: Vítězství Spojenců
Strany
@wbzyl
wbzyl / 2dqueries.js
Created May 10, 2011 10:51 — forked from glyphobet/2dqueries.js
Example showing that MongoDB uses native units for regular 2d queries, and radians for spherical 2d queries
> db.dropDatabase();
{ "dropped" : "test", "ok" : 1 }
>
> // These points are one degree apart, which (according to Google Maps) is about 110 km apart
> // at this point on the Earth.
> db.points.insert({location: [-122, 37]});
> db.points.insert({location: [-122, 38]});
> db.points.ensureIndex({location:"2d"});
>
>
@wbzyl
wbzyl / data-markdown.user.js
Created November 22, 2011 11:01 — forked from paulirish/data-markdown.user.js
*[data-markdown] - use markdown, sometimes, in your HTML
// ==UserScript==
// @name Use Markdown, sometimes, in your HTML.
// @author Paul Irish <http://paulirish.com/>
// @link http://git.io/data-markdown
// @match *
// ==/UserScript==
// If you're not using this as a userscript just delete from this line up. It's cool, homey.
@wbzyl
wbzyl / modal.html
Created December 9, 2011 08:12 — forked from makeusabrew/modal.html
Twitter Bootstrap - basic dialog box invocation via JavaScript
<!-- set up the modal to start hidden and fade in and out -->
<div id="myModal" class="modal hide fade">
<!-- dialog contents -->
<div class="modal-body">
Hello world!
</div>
<!-- dialog buttons -->
<div class="modal-footer">
<a href="#" class="btn primary">OK</a>
</div>
@wbzyl
wbzyl / chat.rb
Created January 4, 2012 22:42 — forked from rkh/chat.rb
Simple Chat Application using the Sinatra Streaming API
# coding: utf-8
require 'sinatra'
set server: 'thin', connections: []
get '/' do
halt erb(:login) unless params[:user]
erb :chat, locals: { user: params[:user].gsub(/\W/, '') }
end
get '/stream', provides: 'text/event-stream' do
@wbzyl
wbzyl / percolated-twitter.rb
Created January 11, 2012 21:09 — forked from karmi/percolated-twitter.rb
Reversed or “Real Time” Search in ElasticSearch
# Reversed or “Real Time” Search in ElasticSearch
# ====================================================================================
# You may have come across the term “realtime search” lately
# (eg. [here](http://engineering.socialcast.com/2011/05/realtime-search-solr-vs-elasticsearch/))
# and wondered what all the fuss is about.
#
# Well, the usual workflow with search engines goes like this:
#
# 1. You index some documents.
@wbzyl
wbzyl / minitest_spec_expectations.md
Created March 15, 2012 21:42 — forked from ordinaryzelig/minitest_spec_expectations.md
How to write MiniTest::Spec expectations

I'm a fan of MiniTest::Spec. It strikes a nice balance between the simplicity of TestUnit and the readable syntax of RSpec. When I first switched from RSpec to MiniTest::Spec, one thing I was worried I would miss was the ability to add matchers. (A note in terminology: "matchers" in MiniTest::Spec refer to something completely different than "matchers" in RSpec. I won't get into it, but from now on, let's use the proper term: "expectations").

Understanding MiniTest::Expectations

Let's take a look in the code (I'm specifically referring to the gem, not the standard library that's built into Ruby 1.9):

# minitest/spec.rb

module MiniTest::Expectations
@wbzyl
wbzyl / MathJax-jQuery.html
Created May 6, 2012 20:09 — forked from hidsh/MathJax-jquery.html
mathjax interactive preview
<html>
<head>
<meta charset=utf-8>
<title>Live Preview of MathJax Type Setting</title>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [['$','$'], ["\\(","\\)"]] } });
</script>
<script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
@wbzyl
wbzyl / latency.txt
Created May 31, 2012 13:23 — forked from jboner/latency.txt
Latency numbers every programmer should know
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns
Mutex lock/unlock 25 ns
Main memory reference 100 ns
Compress 1K bytes with Zippy 3,000 ns
Send 2K bytes over 1 Gbps network 20,000 ns
Read 1 MB sequentially from memory 250,000 ns
Round trip within same datacenter 500,000 ns
Disk seek 10,000,000 ns
@wbzyl
wbzyl / index.html
Created June 25, 2012 19:17 — forked from mbostock/.block
Rounded Rectangles (D3.js) / http://bl.ocks.org/2990659
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?1.29.1"></script>
</head>
<body>
<script type="text/javascript">
var mouse = [480, 250],
count = 0;