Skip to content

Instantly share code, notes, and snippets.

@dolzenko
dolzenko / irb_benchmark.rb
Created January 8, 2014 14:34
Automatic benchmarking in IRB (based on irb_callbacks gem code)
require 'benchmark'
module IRB
def self.before_eval
end
def self.after_eval
end
def self.around_eval(&block)
@timing = Benchmark.measure do
block.call
end
@dolzenko
dolzenko / ack-gems
Created September 5, 2013 15:31 — forked from AndrewRadev/ack-gems
#! /usr/bin/env ruby
require 'bundler'
paths = Bundler.load.specs.map(&:full_gem_path)
system("ack '#{ARGV[0]}' #{paths.join(' ')}")
@robfig
robfig / .emacs
Last active June 13, 2023 16:08
Emacs integration with goimports - https://github.com/bradfitz/goimports. Every time you save your Go code, 1. Add missing imports (standard library only), 2. Remove unnecessary imports, 3. Go fmt
;; OSX - Update the PATH to match that from the shell
(defun set-exec-path-from-shell-PATH ()
(let ((path-from-shell
(replace-regexp-in-string "[[:space:]\n]*$" ""
(shell-command-to-string "$SHELL -l -c 'echo $PATH'"))))
(setenv "PATH" path-from-shell)
(setq exec-path (split-string path-from-shell path-separator))))
(when (equal system-type 'darwin) (set-exec-path-from-shell-PATH))
;; Go mode
@dolzenko
dolzenko / hows.rb
Last active December 16, 2015 15:59
require 'stamp'
require 'text-table'
def how(ts)
hour = (ts.to_f / 3600).floor
hour % 24 + ((hour / 24 + 4).floor % 7) * 24
end
from = Time.utc(2013, 4, 7)
to = Time.utc(2013, 4, 7 + 7)
@ryansobol
ryansobol / gist:5252653
Last active November 4, 2025 18:51
15 Questions to Ask During a Ruby Interview

Originally published in June 2008

When hiring Ruby on Rails programmers, knowing the right questions to ask during an interview was a real challenge for me at first. In 30 minutes or less, it's difficult to get a solid read on a candidate's skill set without looking at code they've previously written. And in the corporate/enterprise world, I often don't have access to their previous work.

To ensure we hired competent ruby developers at my last job, I created a list of 15 ruby questions -- a ruby measuring stick if you will -- to select the cream of the crop that walked through our doors.

What to expect

Candidates will typically give you a range of responses based on their experience and personality. So it's up to you to decide the correctness of their answer.

@dolzenko
dolzenko / gist:5143663
Last active December 14, 2015 20:28
BigDecimal simple inspect
BigDecimal.class_eval do
def inspect
to_s
end
end
while :; do gulp build; inotifywait --quiet --event modify --event create --event move --event delete --exclude '#' --recursive . ; done
# Watches for all events for all files under current folder ignoring Emacs backup files
@dolzenko
dolzenko / irb-tricks.rb
Last active October 13, 2015 03:27
IRB tricks
# Sessions
irb(main):001:0> s = "mystring"
=> "mystring"
irb(main):002:0> irb s
irb#1(mystring):001:0> size
=> 8
> IRB::ReadlineInputMethod::HISTORY.to_a # prints session history
@dolzenko
dolzenko / bid_parser.py
Last active July 21, 2017 14:51
Parse Google BidRequest/BidResponse with Python
import bidding_pb2
rq = bidding_pb2.BidResponse()
f = open('bid_response.bin', "rb")
rq.ParseFromString(f.read())
print(rq)
f.close()
rq = bidding_pb2.BidRequest()
f = open('bid_request.bin', "rb")
-- Primer on representing non-printable characters in Lua code
function assert_equal(a, b)
if a ~= b then
error(a .. ' is not equal to ' .. b)
end
end
-- Escape sequences in string use decimal character codes, i.e.
assert_equal('\97\98\99', 'abc')