Skip to content

Instantly share code, notes, and snippets.

@psyho
psyho / master-election
Created March 14, 2011 21:14
master election using zookeeper
#!/usr/bin/env ruby
require "rubygems"
require "zookeeper"
def log(msg)
puts "[#{Process.pid}] #{msg}"
end
def debug(obj)
@psyho
psyho / index.html
Created August 3, 2011 16:44
inline edit and dirty detection
<!DOCTYPE HTML>
<html xmlns:ng="http://angularjs.org">
<head>
<title>Inline Edit</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.js" type="text/javascript"></script>
<script src="http://code.angularjs.org/0.9.18/angular-0.9.18.min.js" type="text/javascript" ng:autobind></script>
<style type="text/css">
.dirty {
@psyho
psyho / partials.html
Created August 24, 2011 17:55
caching partials in angular
<!doctype html>
<html xmlns:ng="http://angularjs.org">
<script src="http://code.angularjs.org/angular-0.9.19.min.js" ng:autobind></script>
<script type="text/javascript">
// this is the service generated by partials.rb
angular.service('partials', function() {
return {
'/foo': 'Foo template',
'/bar': 'Bar template'
@psyho
psyho / Gemfile
Created November 2, 2012 11:20
Typhoeus 0.4.2 Memory Leak
source :rubygems
# no leak in version 0.3.3
# gem 'typhoeus', '0.3.3'
# memory leaking very fast (1Mb/s) in version 0.4.2
gem 'typhoeus', '0.4.2'
@psyho
psyho / notatki
Created April 10, 2013 22:12
Notatki z SCKRK #40 - Lean Coffee
Tematy:
* sckrk workshops (4)
- warsztaty z security
* open data (4)
- jak uwalniać dane z miasta
* why we fail in tdd and what we do about it (7)
* ddd-krk (7)
- nowy meetup dla ludzi z DDD
* formuła spotkań (3)
- co poza reading club i lean coffee
@psyho
psyho / bogus-minitest.rb
Created May 11, 2013 08:56
Bogus.have_received in minispec
require 'minitest/autorun'
require 'set' # bummer, I forgot to require set in Bogus
require 'bogus'
class Foo
def bar(x, y)
end
end
module Bogus
@psyho
psyho / foo_spec.rb
Created April 29, 2014 15:08
How to combine Bogus and rspec-mocks (or other mocking library) in one project
require 'spec_helper'
class Foo
def initialize(bar)
@bar = bar
end
def foo
@bar.bar
end
@psyho
psyho / core.clj
Last active October 15, 2015 07:46
Property-based testing dojo
(ns dojo.core
(:require [clojure.test.check :as tc]
[clojure.test.check.generators :as gen]
[clojure.test.check.properties :as prop]
[clojure.test :refer :all]))
(def balls identity)
(defn add-ball [rack ball] (conj rack ball))