Skip to content

Instantly share code, notes, and snippets.

View derekkraan's full-sized avatar

Derek Kraan derekkraan

View GitHub Profile
@derekkraan
derekkraan / keybase.md
Created July 5, 2023 10:55
keybase.md

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@derekkraan
derekkraan / opentelemetry_honeycomb_sampler.ex
Created June 22, 2023 09:31
Sampler for Opentelemetry / Honeycomb
defmodule Opentelemetry.CodeCodeShipSampler do
@behaviour :otel_sampler
@impl :otel_sampler
def setup(_sampler_opts) do
[]
end
@impl :otel_sampler
def description(_sampler_config) do
<?xml version="1.0" encoding="UTF-8"?>
<response>
<meta>
<results type="integer">1</results>
<offset type="integer">0</offset>
<filters type="array"/>
</meta>
<trainings type="array">
<training>
<id type="integer">123</id>
<?xml version="1.0" encoding="UTF-8"?>
<response>
<meta>
<results type="integer">24030</results>
<offset type="integer">0</offset>
<filters type="array"/>
</meta>
<trainings type="array">
<training>
<id type="integer">123</id>
@derekkraan
derekkraan / rebase.rb
Created August 26, 2013 12:19
Cherry pick unique commits from a branch onto another branch. Useful if you've merged master into your branch and then rebased your branch on master. That can be a clusterfuck if git doesn't recognize the commits that you merged in from master anymore.
hashes = ["41ae018", "610f707", "7cd4577", "7d8de28", "df6a0d6", "891e049", "45e6aff", "5546b80", "12df477", "674b60f", "9b04f92", "77e00b7", "b5525c7", "a0cda26", "ec974af", "31ce76c", "e5166d1", "4ff48a4", "1db308b", "efed886", "c0b1984", "8ddc684", "406fa59", "9a68945", "fb70cb1", "2bf804d", "3caef0c", "e12d122", "f3afee3", "e0acb79", "98580dc", "5e80380", "ca59dc6", "d16a9a4", "d416a98", "2d73dd8", "57cd6b1", "438ea0a", "a32f919", "35abe8d"]
current_hash = if ARGV.first.nil?
`git log --pretty=format:'%h' -n 1`
else
ARGV.first
end
current_index = hashes.index(current_hash)
if current_index
def test_with_cleaner(example)
if $truncate
DatabaseCleaner.clean_with :truncation
$truncate = false
end
if example.metadata[:js].blank?
DatabaseCleaner.start
end
@derekkraan
derekkraan / gist:6228744
Last active December 21, 2015 01:38
Cherry-pick many commits
# cherry-pick many commits
# call with one (optional) argument: the short-hash of the commit in the list that you want to start *after*
# eg:
# $ ruby rebase.rb
# (half of the commits apply, but then you have to fix one manually; the last commit you applied is abc123)
# $ ruby rebase.rb abc123
# (the rest of the commits are cherry-picked)
hashes = ["41ae018", "610f707"]
current_hash = ARGV.first
@derekkraan
derekkraan / shift.rb
Created November 26, 2012 21:07
Move all files with number greater than argument
def new_filename(num, filename)
if num.to_i < 9
"_0#{num.to_i+1}#{filename}"
elsif num.to_i < 99
"_#{num.to_i+1}#{filename}"
else
"#{num.to_i+1}#{filename}"
end
end