Skip to content

Instantly share code, notes, and snippets.

View ravicious's full-sized avatar

Rafał Cieślak ravicious

View GitHub Profile
@ravicious
ravicious / keybase.md
Created October 4, 2015 12:02
Keybase.io verification

Keybase proof

I hereby claim:

  • I am ravicious on github.
  • I am ravicious (https://keybase.io/ravicious) on keybase.
  • I have a public key whose fingerprint is 0521 7C74 347E 6D6B 7882 728B FF5B 4F7D 53F3 19D9

To claim this, I am signing this object:

threads = concurrency_level.times.map { |i|
-> {
Thread.new do
begin
customers[i].buy_products([{quantity: 1, product: product}])
rescue Orders::CreateOrderService::Invalid
fail_occurred = true
end
end
}
@ravicious
ravicious / private_function.js
Created June 4, 2015 18:33
Private function example based on raganwald's "Classes are Expressions" http://raganwald.com/2015/06/04/classes-are-expressions.html Discussion: https://news.ycombinator.com/item?id=9660908
let Person = (() = > {
let firstNameProperty = Symbol('firstName'),
lastNameProperty = Symbol('lastName'),
renameProperty = Symbol('rename');
let rename = function(first, last) {
this[firstNameProperty] = first;
this[lastNameProperty] = last;
return this;
}
@ravicious
ravicious / hash_bench.rb
Created April 6, 2015 08:29
Hash[] vs Array#to_h
require 'benchmark/ips'
DEFAULT_CHARSET = ('a'..'z').to_a + (0..9).to_a
def random_symbol
charset = ('a'..'z')
random_string(charset).to_sym
end
def random_string(charset = DEFAULT_CHARSET)
; different approaches to constructing handlers in re-frame
; which one's better?
(register-handler
:cell-clicked
(fn [db _]
(dispatch [:change-cell-owner])
(dispatch [:change-current-player])))
(register-handler
@ravicious
ravicious / parens.md
Last active August 29, 2015 14:17
Real talk about dem brackets

Real talk about dem brackets

  • Steve Losh's great post A Modern Space Cadet.
    • Shift Parentheses section.
      • You might want to skip the last <autogen> rule, as it makes typing uppercased words by holding the shift key a pretty terrible experience.
    • Control/Escape section.
    • KeyRemap4MacBook is now Karabiner.
  • Using Linux? You can get pretty much the same results with xmodmap, just google around.
  • Shif parentheses can be done in a similar way, I'll post my xmodmap config for them when I get home.
@ravicious
ravicious / example_a.rb
Created January 13, 2015 21:06
Code examples for my comment under Henrik's post http://thepugautomatic.com/2015/01/exception-class/
begin
class_a_instance.do_something
class_b_instance.do_something
rescue A::NotEnoughMoney
log_error
cleanup
rescue B::NotEnoughMoney
just_send_email
end
import ddf.minim.*;
Minim minim;
AudioPlayer song;
PImage korwin;
float counter;
float rotateValue;
void setup()
{
#!/bin/sh
#
# xfce4
#
# Copyright (C) 1999, 2003 Olivier Fourdan ([email protected])
# Copyright (C) 2011 Guido Berhoerster ([email protected])
# Copyright (C) 2011 Jarno Suni ([email protected])
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
---- 28 sie 2013 16:38:12 ----
08-28 16:38:13.247 4102 4139 I InputDispatcher: Dropped event because input dispatch is disabled.
08-28 16:38:13.262 4102 4139 I InputDispatcher: Dropped event because input dispatch is disabled.
08-28 16:38:13.277 4102 4139 I InputDispatcher: Dropped event because input dispatch is disabled.
08-28 16:38:13.292 4102 4139 I InputDispatcher: Dropped event because input dispatch is disabled.