Skip to content

Instantly share code, notes, and snippets.

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 / gist:5143663
Last active December 14, 2015 20:28
BigDecimal simple inspect
BigDecimal.class_eval do
def inspect
to_s
end
end
@ryansobol
ryansobol / gist:5252653
Last active February 23, 2025 06:28
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 / 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)
@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 / 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(' ')}")
@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
['mysql2', 'sequel', 'pp'].each(&method(:require))
DB = Sequel.connect('mysql2://root@localhost/tmp')
DB.tables.each {|t| DB.drop_table(t) }
def t(name, columns, *rows)
DB.create_table(name) do
columns.each.with_index do |column, ind|
type = rows[0][ind].class.to_s
send type, column
end
module Net
class HTTP
alias_method '__initialize__', 'initialize'
def initialize(*args,&block)
__initialize__(*args, &block)
ensure
@debug_output = $stderr ### if ENV['HTTP_DEBUG']
end
end
ruby -rwebrick -e'WEBrick::HTTPServer.new(Port: 8000, DocumentRoot: Dir.pwd).start'