Skip to content

Instantly share code, notes, and snippets.


Keybase proof

I hereby claim:

  • I am dolzenko on github.
  • I am dolzenko ( on keybase.
  • I have a public key ASAipUSRr1nXIPSfQHVNeEFTKKf7snq4L8dxWbcm7uQrcAo

To claim this, I am signing this object:

View The Three Go Landmines.markdown

There are three easy to make mistakes in go. I present them here in the way they are often found in the wild, not in the way that is easiest to understand.

All three of these mistakes have been made in Kubernetes code, getting past code review at least once each that I know of.

  1. Loop variables are scoped outside the loop.

What do these lines do? Make predictions and then scroll down.

func print(pi *int) { fmt.Println(*pi) }
dolzenko / gist:ba9f14c104a105ee46a13ced19a18332
Created Jul 15, 2016 — forked from marcinbunsch/gist:1044437
Rails production prompt change as a Rails initializer
View gist:ba9f14c104a105ee46a13ced19a18332
# Put this file in config/initializers/irb.rb
# Works in Rails 3.0+, should also work in 2.3
# Override the IRB, to provide the Rails environment in the prompt
module IRB
class << self
def setup_with_prompt_override(ap_path)
env = (Rails.env.to_sym == :production ? "\033[00;31mPRODUCTION\033[00m" : Rails.env)
dolzenko / gist:7c76d6b594ba6a2c68266b58bd83275b
Created Jul 15, 2016 — forked from kogakure/gist:3187467
Ruby: Colorized irb prompt for production: ~/.irbrc
View gist:7c76d6b594ba6a2c68266b58bd83275b
# .irbrc
if defined?(Rails) && Rails.production?
conf = IRB.conf[:PROMPT][IRB.conf[:PROMPT_MODE]]
red = "\033[0;31m"
reset = "\033[0m"
[:PROMPT_S, :PROMPT_C].each do |p|
conf[p].gsub!(/^(.*)$/, "#{red}\\1#{reset}")
conf[:PROMPT_I] = "#{red}%N(%m):%03n:%i (PRODUCTION) > #{reset}"
View gist:4fbb5f01831b972e2e4a mm-1 mm-2 mm-3 ms-1 ms-2 ms-3 ms-4 ms-5 ms-6 ms-7
View single-bad-thing-about-go.go
package main
import "fmt"
func f() (int, error) {
return 42, nil
func main() {
x := 3
dolzenko / mgmt-deps.rb
Last active Aug 29, 2015
Prints missing/unused Go deps for
View mgmt-deps.rb
require 'json'
require 'set'
myself = `go list`.strip
deps =
`go list ./...`.each_line do |dep|
pdeps = JSON.parse(`mgmt go list -json #{dep}`)
deps += pdeps['Deps']
deps += pdeps['TestImports'] if pdeps['TestImports']
dolzenko / sidekiq_paper_trail_middleware.rb
Created Dec 18, 2014
Make originator of change tracked with paper_trail available in Sidekiq background workers
View sidekiq_paper_trail_middleware.rb
module Acme
module Sidekiq
module PaperTrailMiddleware
class Client
# @param [Object]
# @param [Hash] job
def call(_, job, *)
job['whodunnit'] = ::PaperTrail.whodunnit
View run-webrick-in-current-dir.rb
ruby -rwebrick -e' 8000, DocumentRoot: Dir.pwd).start'
View net-http-debug-output.rb
module Net
class HTTP
alias_method '__initialize__', 'initialize'
def initialize(*args,&block)
__initialize__(*args, &block)
@debug_output = $stderr ### if ENV['HTTP_DEBUG']