Skip to content

Instantly share code, notes, and snippets.

@dolzenko
dolzenko / jvmdump.bat
Created June 2, 2023 06:53 — forked from isapir/jvmdump.bat
Dump Threads and Heap for a JVM that runs as Service
:: if the service is run in Session 0 then open a console for that session and run it from there
:: e.g. %PsExec% -s -h -d -i 0 cmd.exe
:: set the paths for your environment
set PsExec=C:\Apps\SysInternals\PsExec.exe
set JAVA_HOME=C:\Apps\Java\jdk1.8.0_121
set DUMP_DIR=C:\temp
@echo off
@dolzenko
dolzenko / site.conf
Created March 28, 2023 06:19 — forked from paskal/site.conf
Nginx configuration for best security and modest performance. Full info on https://terrty.net/2014/ssl-tls-in-nginx/
# read more at https://terrty.net/2014/ssl-tls-in-nginx/
# latest version on https://gist.github.com/paskal/628882bee1948ef126dd/126e4d1daeb5244aacbbd847c5247c2e293f6adf
# security test score: https://www.ssllabs.com/ssltest/analyze.html?d=terrty.net
# your nginx version might not have all directives included, test this configuration before using in production against your nginx:
# $ nginx -c /etc/nginx/nginx.conf -t
server {
# public key, contains your public key and class 1 certificate, to create:
# (example for startssl)
# $ (cat example.com.pem & wget -O - https://www.startssl.com/certs/class1/sha2/pem/sub.class1.server.sha2.ca.pem) | tee -a /etc/nginx/ssl/domain.pem > /dev/null

Keybase proof

I hereby claim:

  • I am dolzenko on github.
  • I am dolzenko (https://keybase.io/dolzenko) on keybase.
  • I have a public key ASAipUSRr1nXIPSfQHVNeEFTKKf7snq4L8dxWbcm7uQrcAo

To claim this, I am signing this object:

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
dolzenko / gist:ba9f14c104a105ee46a13ced19a18332
Created July 15, 2016 11:09 — forked from marcinbunsch/gist:1044437
Rails production prompt change as a Rails initializer
# 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)
setup_without_prompt_override(ap_path)
env = (Rails.env.to_sym == :production ? "\033[00;31mPRODUCTION\033[00m" : Rails.env)
@dolzenko
dolzenko / gist:7c76d6b594ba6a2c68266b58bd83275b
Created July 15, 2016 11:09 — forked from kogakure/gist:3187467
Ruby: Colorized irb prompt for production: ~/.irbrc
# .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}")
end
conf[:PROMPT_I] = "#{red}%N(%m):%03n:%i (PRODUCTION) > #{reset}"
end
10.240.0.53 mm-1
10.240.0.55 mm-2
10.240.0.56 mm-3
10.240.0.21 ms-1
10.240.0.23 ms-2
10.240.0.29 ms-3
10.240.0.34 ms-4
10.240.0.36 ms-5
10.240.0.31 ms-6
10.240.0.32 ms-7
package main
import "fmt"
func f() (int, error) {
return 42, nil
}
func main() {
x := 3
@dolzenko
dolzenko / mgmt-deps.rb
Last active August 29, 2015 14:16
Prints missing/unused Go deps for https://github.com/bsm/mgmt
require 'json'
require 'set'
myself = `go list`.strip
deps = Set.new
`go list ./...`.each_line do |dep|
pdeps = JSON.parse(`mgmt go list -json #{dep}`)
deps += pdeps['Deps']
deps += pdeps['TestImports'] if pdeps['TestImports']
@dolzenko
dolzenko / sidekiq_paper_trail_middleware.rb
Created December 18, 2014 13:01
Make originator of change tracked with paper_trail available in Sidekiq background workers
module Acme
module Sidekiq
module PaperTrailMiddleware
class Client
# @param [Object]
# @param [Hash] job
def call(_, job, *)
job['whodunnit'] = ::PaperTrail.whodunnit
yield
end