Skip to content

Instantly share code, notes, and snippets.

@jeffomatic
jeffomatic / rustfmt-skip-children.sh
Last active February 5, 2023 04:57
rustfmt --skip-children emulation script
#!/bin/bash
#
# This script filters rustfmt output for format-on-save workflows in text
# editors.
#
# Usage:
#
# rustfmt-skip-children /path/to/source
#
# In particular, it:

Keybase proof

I hereby claim:

  • I am jeffomatic on github.
  • I am jeffomatic (https://keybase.io/jeffomatic) on keybase.
  • I have a public key whose fingerprint is 1357 9DF7 C2F5 E0E0 ACC9 30D0 591F 7F89 D640 ACFD

To claim this, I am signing this object:

@jeffomatic
jeffomatic / gist:5015296
Created February 22, 2013 17:51
Ruby load ruins whatever clever thing you were doing with alias_method
# base.rb
class Base
def foo
puts "BASE"
end
end
# derived.rb
@jeffomatic
jeffomatic / gist:4632923
Created January 25, 2013 08:54
In case rvm install is failing due to missing rubygems package
source $HOME/.rvm/scripts/rvm
rvm use ruby-1.9.3-p374
rvm rubygems 1.8.24
@jeffomatic
jeffomatic / gist:3849655
Created October 7, 2012 21:27
blog: accessing Rails helpers outside views, calling globally-accessible Helpers module
MyProj::Helpers.pluralize(1, 'person')
MyProj::Helpers.simple_format(string)
@jeffomatic
jeffomatic / gist:3849644
Created October 7, 2012 21:24
blog: accessing Rails helpers outside views, declaring globally-accessible Helpers module
# Put this into extra/my_proj/helpers.rb
module MyProj
module Helpers
extend ActionView::Helpers
end
end
@jeffomatic
jeffomatic / gist:3421955
Created August 22, 2012 03:10
Binary tree output 3
values: [3, 0, 2, 3, 0, 5, 7, 9, 7, 4, 4, 4, 4, 6, 8, 3, 6, 6, 3,
9, 3, 9, 1, 6, 7, 7, 3, 1, 7, 4, 7, 9, 8, 8, 6, 6, 0, 0, 3, 6, 1,
1, 0, 5, 3, 9, 5, 8, 4, 1, 0, 7, 9, 1, 6, 4, 0, 8, 8, 9, 7, 2, 9,
5, 8]
⌜·············3·⌝
⌜0···········⌝ ⌜3············⌝
0 ⌜·····2⌝ 3 ⌜·····5············⌝
⌜···1·⌝ 2 ⌜4·⌝ ⌜7·············⌝
⌜0·⌝ ⌜1·⌝ ⌜···4 ⌜4·⌝ ⌜······7 ⌜······9·⌝
0 ⌜0⌝ 1 ⌜1⌝ ⌜3·⌝ 4 ⌜4⌝ ⌜6·⌝ ⌜····8·⌝ ⌜9·⌝
@jeffomatic
jeffomatic / gist:3421950
Created August 22, 2012 03:09
Binary tree output 2
values: [4, 5, 0, 6, 2, 9, 7, 4, 1, 3, 8, 8, 2, 2, 7, 6, 8, 0, 0,
6, 9, 9, 0, 9, 3, 5, 6, 6, 2, 4, 0, 0, 0, 8, 7, 7, 0, 8, 6, 7, 7,
1, 7, 4, 1, 5, 6, 0, 9, 4, 0, 8, 0, 1, 0, 2, 9, 1, 4, 3, 5, 3, 4,
0, 1]
⌜··························4······⌝
⌜0·················⌝ ⌜····5····⌝
0 ⌜·····2····⌝ ⌜4·⌝ ⌜6··················⌝
⌜·········1·⌝ ⌜··3·⌝ 4 ⌜4⌝ ⌜·6 ⌜···········9·⌝
⌜0·⌝ ⌜1·⌝ ⌜2⌝ ⌜3⌝ 4 4⌝ ⌜5⌝ ⌜7······⌝ ⌜9·⌝
0 ⌜0·⌝ 1 ⌜1⌝ 2 2⌝ 3 3 4 5 5 ⌜···7 ⌜8·⌝ 9 ⌜9⌝
@jeffomatic
jeffomatic / gist:3421916
Created August 22, 2012 03:07
Binary tree output 1
values: [3, 9, 8, 5, 5, 0, 6, 3, 4, 4, 5, 0, 8, 3, 2, 7, 8, 3, 6,
4, 3, 7, 8, 4, 1, 5, 1, 5, 5, 0, 3, 5, 8, 8, 7, 0, 4, 5, 1, 0, 2,
7, 7, 2, 2, 9, 6, 2, 2, 0, 9, 9, 0, 2, 7, 8, 5, 2, 4, 1, 6, 1, 3,
9, 7]
⌜··················3·······································⌝
⌜0·⌝ ⌜······9·⌝
0 ⌜0········⌝ ⌜···················8·⌝ ⌜9⌝
0 ⌜···2·⌝ ⌜··········5·⌝ ⌜8·⌝ 9 9⌝
⌜1·⌝ ⌜2·⌝ ⌜3····⌝ ⌜5·······⌝ 8 ⌜8⌝ 9
⌜·1 ⌜1⌝ 2 ⌜2·⌝ 3 ⌜··4·⌝ 5 ⌜6···⌝ 8 8⌝
@jeffomatic
jeffomatic / gist:3421894
Created August 22, 2012 03:04
Binary tree insert, visualizer, and decomposition into doubly-linked cycle
# encoding: UTF-8
def tree_insert(root, v)
if !root[:v]
root.clear
root.merge!(
:v => v,
:p => nil,
:n => nil
)
elsif root[:v] > v