Skip to content

Instantly share code, notes, and snippets.

View ch1c0t's full-sized avatar

Anatoly Chernov ch1c0t

View GitHub Profile
@daveray
daveray / seesaw-repl-tutorial.clj
Created December 7, 2011 04:55
Seesaw REPL Tutorial
; A REPL-based, annotated Seesaw tutorial
; Please visit https://github.com/daveray/seesaw for more info
;
; This is a very basic intro to Seesaw, a Clojure UI toolkit. It covers
; Seesaw's basic features and philosophy, but only scratches the surface
; of what's available. It only assumes knowledge of Clojure. No Swing or
; Java experience is needed.
;
; This material was first presented in a talk at @CraftsmanGuild in
; Ann Arbor, MI.
@rkh
rkh / chat.rb
Created December 14, 2011 12:55
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
@stevekrenzel
stevekrenzel / gist:1505619
Created December 21, 2011 10:59
Instagram challenge solution
unshred = (shreddedImage, shredWidth) ->
{width, height} = shreddedImage
shreds = split shreddedImage, shredWidth
weights = cross shreds, (x, y) ->
if x == y
0
else
mean zipWith unzip(rightEdge(x)), unzip(leftEdge(y)), correlate
@jodosha
jodosha / adapter_test.rb
Last active August 11, 2019 03:12
MiniTest shared examples
require 'test_helper'
shared_examples_for 'An Adapter' do
describe '#read' do
before do
@adapter.write(@key = 'whiskey', @value = "Jameson's")
end
it 'reads a given key' do
@adapter.read(@key).must_equal(@value)
@heuristicfencepost
heuristicfencepost / sieve_actor.rb
Created January 6, 2012 02:34
Implementation of Sieve of Eratosthenes using actors, JRuby and Akka
require 'java'
require 'lib/akka-actor-1.2.jar'
require 'lib/scala-library.jar'
java_import 'akka.actor.Actors'
java_import 'akka.actor.UntypedActor'
java_import 'akka.actor.UntypedActorFactory'
module Sieve
@peterhellberg
peterhellberg / Guardfile
Created January 12, 2012 15:08
External JSON API testing (using minitest/spec, rest-client and yajl-ruby)
guard 'shell' do
watch(/relation_tree_spec\.rb/) { `clear && ruby relation_tree_spec.rb` }
end
@six8
six8 / gist:1732686
Created February 3, 2012 21:20
Javascript dependency graph resolution
// Dependency resolution, adapted from https://gist.github.com/1232505/f16308bc14966c8d003c2686b1c258ec41303c1f
function resolve(graph) {
var sorted = [], // sorted list of IDs ( returned value )
visited = {}; // hash: id of already visited node => true
// 2. topological sort
Object.keys(graph).forEach(function visit(name, ancestors) {
if (!Array.isArray(ancestors)) ancestors = [];
ancestors.push(name);
visited[name] = true;
@mbleigh
mbleigh / Gemfile
Created March 21, 2012 03:14
Non-Rails Rackup with Sprockets, Compass, Handlebars, Coffeescript, and Twitter Bootstrap
source "https://rubygems.org"
gem 'sprockets'
gem 'sprockets-sass'
gem 'sass'
gem 'compass'
gem 'bootstrap-sass'
gem 'handlebars_assets'
gem 'coffee-script'
@carlosantoniodasilva
carlosantoniodasilva / dup.rb
Created May 13, 2012 20:58
Ruby dup/clone behavior
class A
def initialize_dup(other)
puts 'init dup'
super
end
def initialize_clone(other)
puts 'init clone'
super
end
@jboner
jboner / latency.txt
Last active December 17, 2025 10:54
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD