Skip to content

Instantly share code, notes, and snippets.

View krekoten's full-sized avatar

Marian Krekoten krekoten

  • Lviv, Ukraine
  • 12:16 (UTC +02:00)
View GitHub Profile
const window = Dimensions.get('window')
const styles = StyleSheet.create({
containerStyle: {
overflow: 'hidden',
width: window.width,
height: window.width / 2
},
contentContainerStyle: {
borderRadius: window.width,
width: window.width * 2,

Keybase proof

I hereby claim:

  • I am krekoten on github.
  • I am krekoten (https://keybase.io/krekoten) on keybase.
  • I have a public key ASCzazLorWv2-JO6OYcsbs_c030huC7eD9S6868bAW6N1Ao

To claim this, I am signing this object:

@krekoten
krekoten / singleton
Created May 7, 2013 18:59
singleton of immediate values
$ ruby -e "5.instance_exec { p self }"
5
$ bin/topaz_untranslated.py -e "5.instance_exec { p self }"
-e:1:in `instance_exec': can't define singleton (TypeError)
from -e:1:in `<main>'
@krekoten
krekoten / collection_presenter.rb
Created December 2, 2011 12:47
Presenters, they are objects rock stars recently :)
class CollectionPresenter < Presenter
def to_hash
@model.inject(Hash.new { |h, k| h[k] = [] }) do |hash, element|
element_hash = Presenter.factory(element, options).to_hash
hash[element_hash.keys.first.to_s.pluralize.to_sym] << element_hash.values.first
hash
end
end
end
@krekoten
krekoten / config.ru.rb
Created September 16, 2011 08:38 — forked from brianmario/config.ru.rb
minimal rails3 app
require'action_controller'
run(r=ActionDispatch::Routing::RouteSet.new)
r.draw{root :to=>->e{[200,{'Content-Type'=>'text/html'},["Hello"]]}}
#twitter size rails3 app :)
def tip(msg); puts; puts msg; puts "-"*100; end
#
# 30 Ruby 1.9 Tips, Tricks & Features:
# http://www.igvita.com/2011/02/03/new-ruby-19-features-tips-tricks/
#
tip "Upgrading to Ruby 1.9 is simple: rvm install 1.9.2 && rvm --default 1.9.2"
tip "Ruby 1.9 supports named captures in regular expressions!"
@krekoten
krekoten / surprise.txt
Created December 20, 2010 18:46
Very interesting ruby 1.9 behavior
# Ruby 1.9.2
ruby-1.9.2-p0 > class O; end
nil
ruby-1.9.2-p0 > O.new(1,2,3)
#<O:0x00000100a9fcf8>
# Ruby 1.8.7
irb(main):001:0> class O; end
@krekoten
krekoten / reader_test.rb
Created October 17, 2010 21:00
Benchmark test for different ways to create reader method
require 'benchmark'
class A
def initialize
@etag = 'ETag'
end
def etag
@etag
end
# A couple years ago the Rails community discovered the joys of factory
# builders as an alternative to fixtures. Rails developers have had
# bad experience with fixtures since a long time due to several reasons
# including misuse.
#
# This misuse is often characterized by a huge ammount of factories,
# causing a lot of data to maintain and dependence between tests. In my
# experience working (and rescueing) different applications, 80% of these
# factories are used only by 20% of tests (which are usually tests that
# need a huge ammount of data to test different scenarios).
class Proc
def <<(other)
case other
when Proc
Proc.new do |*args|
call(other.call(*args))
end
else
call(other)
end