Skip to content

Instantly share code, notes, and snippets.

[59] pry(main)> Date.parse("22-07-2013").to_time
=> 2013-07-22 00:00:00 +0200
[60] pry(main)> Date.parse("22-07-2013").to_time.utc
=> 2013-07-21 22:00:00 UTC
vs
[61] pry(main)> Date.parse("22-07-2013").to_datetime
@teamon
teamon / Gemfile
Last active December 19, 2015 19:08
source 'https://rubygems.org'
source 'http://rails-assets.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
#!/bin/sh
# Usage
# $ cat Gemfile.lock | hipchat
# $ rake middleware 2>&1 | hipchat
curl -XPOST "http://api.hipchat.com/v1/rooms/message?format=json&auth_token=TOKEN" -d "room_id=ROOM&from=zsh&message_format=text&message=/code%20$(cat)"
@teamon
teamon / bundler_gem_bench.rb
Last active December 19, 2015 11:08
shell vs code
require "tempfile"
require "bundler/cli"
require 'benchmark'
def run
$stdout = StringIO.new;
10.times do
Dir.mktmpdir do |dir|
yield(dir)
end
@teamon
teamon / .zshrc
Created July 4, 2013 14:27 — forked from anonymous/.zshrc
function loc {
s=$(git stash)
localeapp pull && git commit -am "Pulled new translations from localeapp"
if [ ! "$s" = "No local changes to save" ]; then git stash pop; fi
}
@teamon
teamon / logstash_redis.rb
Last active December 18, 2015 03:29
logstash + rails + redis
# Gemfile
gem "logstasher"
# production.rb
config.logstasher.enabled = true
# config/initializers/logstash.rb
$logstasher_redis = Redis.new(:port => 9002)
@teamon
teamon / yell_ap.rb
Created June 5, 2013 15:16
Yell + Awesome Print
~ λ irb -r logger -r awesome_print -r yell
irb(main):001:0> Yell::Logger.send(:include, AwesomePrint::Logger)
=> Yell::Logger
irb(main):002:0> Yell::Logger.new(STDOUT).ap [1,2,3]
2013-06-05T17:15:35+02:00 [DEBUG] 27891 : [
[0] 1,
[1] 2,
[2] 3
]
=> true
@teamon
teamon / prof.rb
Created June 5, 2013 14:56
Profile rails controller with ruby-prof
# gem "ruby-prof"
around_filter :profiler
def profiler(&block)
data = RubyProf::Profile.profile(&block)
filepath = Rails.root.join("tmp", "profiler.html")
File.open(filepath, "w") do |f|
RubyProf::CallStackPrinter.new(data).print(f)
class A
class B extends A
class C extends B
class Foo[X] {
def x[T >: X] = 1
def y[T <: X] = 2
}
val foo = new Foo[B]
https://github.com/RyanScottLewis/jquery-cookie-rails
https://github.com/kclair/jquery-fancybox-rails
https://github.com/seamusabshere/jquery-mousewheel-rails