Skip to content

Instantly share code, notes, and snippets.

View releu's full-sized avatar
🕶️
I may be slow to respond.

Jan Bernacki releu

🕶️
I may be slow to respond.
View GitHub Profile
testjknkjn
@releu
releu / gist:1167435
Created August 24, 2011 06:41
thin init.d
#!/bin/bash
### BEGIN INIT INFO
# Provides: thin
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: S 0 1 6
# Short-Description: thin initscript
# Description: thin
### END INIT INFO
ru:
ui:
notice:
friends_count: "Вас добавло в друзья %{count} человек"
I18n.t("ui.notice.friends_count", :count => 3)
@releu
releu / gist:1391678
Created November 24, 2011 15:59
Sax
class Epay::BankXMLCatcher
BANK = 'bank'
include XML::SaxParser::Callbacks
attr_reader :bank_xml
def initialize
@bank_xml = ""
@in_bank = false
@releu
releu / resume.md
Created December 31, 2011 03:19
Резюме
@releu
releu / gist:1564460
Created January 5, 2012 09:45
Project Euler #2
class Array
def sum
inject(0) { |s, i| s + i }
end
end
array = [1, 2]
while array.last < 4000000
array << array[-2, 2].sum
end
@releu
releu / gist:1781413
Created February 9, 2012 17:28
test markdown

tratata

def foo
end
@releu
releu / likable.rb
Created February 18, 2012 19:50
Likable
module Models
module Likable
extend ActiveSupport::Concern
def liked?(record)
$redis.sismember redis_key, record.id
end
def likes_count
$redis.scard redis_key
@releu
releu / fiber.rb
Created March 6, 2012 19:19
test fibers
process = Fiber.new do
i = 0
loop do
puts "process_#{i = i.next}"
sleep 0.1
Fiber.yield
end
end
loop do
>> a
=> "Something like this\n\n<div class=\"gistable\" data-gist-at=\"1988392\"></div>\n\n#ruby #fiber"
>> a.split(' ')
=> ["Something", "like", "this", "<div", "class=\"gistable\"", "data-gist-at=\"1988392\"></div>", "#ruby", "#fiber"]
>> a.split(/ /)
=> ["Something", "like", "this\n\n<div", "class=\"gistable\"", "data-gist-at=\"1988392\"></div>\n\n#ruby", "#fiber"]