Skip to content

Instantly share code, notes, and snippets.

View pirj's full-sized avatar
🚜
Relentless

Phil Pirozhkov pirj

🚜
Relentless
View GitHub Profile
$ ruby -v
ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.4.0]
$ ruby bench_erubis_slim_haml.rb
Rehearsal ---------------------------------------------------------------------------------------
empty loop 0.000000 0.000000 0.000000 ( 0.001055)
erubis 2.690000 0.000000 2.690000 ( 2.697228)
slim 4.200000 0.010000 4.210000 ( 4.196183)
haml 3.1.0.alpha.14 (Bleeding Edge) 19.660000 0.040000 19.700000 ( 19.681350)
haml (ugly) 3.1.0.alpha.14 (Bleeding Edge) 18.940000 0.070000 19.010000 ( 19.004186)
@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'
@avit
avit / backtick_attribute_syntax.rb
Last active December 10, 2015 01:38
Stupid ruby tricks for ActiveRecord query syntax. For amusement only.
module BacktickAttributeSyntax
extend self
# WARNING: this is a dangerous hack. Don't use it. It'll bite you if you ever
# accidentally call backticks outside of a model.
# Override backtick syntax to return an Arel attribute for use with
# predications like `.gteq` in the model. To use the original shell
# behaviour, (which should be very uncommon in ActiveRecord models), you can
@NILID
NILID / fibonacci.rb
Created September 5, 2012 14:34
fibonacci
def fib(n)a,b,s=0,1,[];n.times{s<<a;a,b=b,a+b};s end
p fib(33)
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, ...]
@vrybas
vrybas / how-do-i-pomodoro.md
Last active March 12, 2019 11:08
Vladimir Rybas - How do I Pomodoro

vrybas.github.io

How do I Pomodoro

I'm a big fan of Pomodoro time management technique, created by Francesco Cirillo in the 80's. In this post I'll describe what it is, how I use it (tools and their tweaks), and how it helps me to get through my day.

Interruptions

@henrik
henrik / commit-msg
Created September 10, 2009 18:25
Git commit-msg hook that automatically adds "Refs #123" when in the branch t123, "[#123]" when in the branch s123 etc.
#!/usr/bin/env ruby
#
# Git commit-msg hook. If your branch name is in the form "t123", automatically
# adds "Refs #123." to commit messages unless they mention "#123" already.
# Include "#close" or "#finish" to add "Closes #123."
#
# For Pivotal Tracker, branch names like "s123" adds "[#123]".
# Include "#close" or "#finish" to add "[Finishes #123]".
#
# If you include "#noref" in the commit message, nothing will be added to
@javiervidal
javiervidal / gist:1433880
Created December 5, 2011 15:05
To access url helpers (url_for, etc) from Rails console (Rails 3)
include Rails.application.routes.url_helpers
default_url_options[:host] = "localhost"
@gcarrion-gfrmedia
gcarrion-gfrmedia / 0000_packages.config
Created April 29, 2014 10:49
AWS Elastic Beanstalk Ruby 2.0/Puma Environment - .ebextensions tweaks and Sidekiq configuration. This is known to work fine with AWS Elastic Beanstalk 's 64bit Amazon Linux 2014.03 v1.0.1 running Ruby 2.0 (Puma) stack. Later stack versions might not work, but for that specific version works fine.
# Install Git needed for Git based gems
packages:
yum:
git: []
@tobym
tobym / redis_pubsub_demo.rb
Created April 1, 2010 16:50 — forked from pietern/redis_pubsub_demo.rb
Redis PubSub demo with EventMachine (chat service)
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
# - a browser with WebSocket support
#
# Usage:
# ruby redis_pubsub_demo.rb
#
top10Salaries :: FilePath -> IO ()
top10Salaries path = do
Just (h, t) <- uncons . T.lines <$> T.readFile path
let
split = T.splitOn ","
Just ind = elemIndex "Salary" $ split h
top10 :: [Int] = t
& map (\s -> read $ T.unpack $ split s !! ind)
& sortBy (flip compare)
& take 10