What is sync.Pool in golang and How to use it
sync.Pool (1/2)
Many Go libraries include custom thread-safe free lists, like this:
var objPool = make(chan *Object, 10)
func obj() *Object {
select {
What is sync.Pool in golang and How to use it
sync.Pool (1/2)
Many Go libraries include custom thread-safe free lists, like this:
var objPool = make(chan *Object, 10)
func obj() *Object {
select {
ruby -rwebrick -e'WEBrick::HTTPServer.new(Port: 8000, DocumentRoot: Dir.pwd).start' |
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 |
['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 |
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 |
#! /usr/bin/env ruby | |
require 'bundler' | |
paths = Bundler.load.specs.map(&:full_gem_path) | |
system("ack '#{ARGV[0]}' #{paths.join(' ')}") |
;; 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 |
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) |
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.
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.