Skip to content

Instantly share code, notes, and snippets.

View benhoskings's full-sized avatar

Ben Hoskings benhoskings

View GitHub Profile
class Foo
def done?
false
end
def indirect_done?
done?
end
end
describe "Foo#done?" do
@benhoskings
benhoskings / ruby-2-cert-issue-fix.sh
Last active March 21, 2016 18:30
Ruby 2.0 CA cert issue fix
# If you're having cert issues on ruby 2.0.0-p0, the issue is most likely that ruby can't
# find the required intermediate certificates. If you built it via rbenv/ruby-build, then
# the certs are already on your system, just not where ruby expects them to be.
# When ruby-build installs openssl, it installs the CA certs here:
~/.rbenv/versions/2.0.0-p0/openssl/ssl/cacert.pem
# Ruby is expecting them here:
$(ruby -ropenssl -e 'puts OpenSSL::X509::DEFAULT_CERT_FILE')
# Which for me, is this path:
@benhoskings
benhoskings / gist:8344953
Created January 10, 2014 00:46
Ben's guide to painless ruby switching with chruby
1) Latest brews.
$ brew update
2) Install packages.
$ brew install chruby ruby-install selecta
3) Load chruby when the shell inits.
echo >> ~/.zshrc
if [ -d /usr/local/opt/chruby ]; then
. /usr/local/opt/chruby/share/chruby/chruby.sh
class String
def normalize
mb_chars.normalize(:kd).gsub(/[^\x00-\x7f]/n, '').to_s
end
def normalize_for_display
mb_chars.normalize(:kd).
gsub('æ', 'ae').
gsub('ð', 'd').
gsub(/[^\x00-\x7f]/n, '').to_s
@benhoskings
benhoskings / gist:7192000
Created October 28, 2013 05:59
sublime config.py
{
"auto_complete_commit_on_tab": true,
"auto_complete_delay": 30,
"bold_folder_labels": true,
"caret_style": "wide",
"color_scheme": "Packages/User/Ben's Solarized (light).tmTheme",
"detect_indentation": false,
"detect_slow_plugins": false,
"dictionary": "Packages/Language - English/en_GB.dic",
"drag_text": false,
SELECT DISTINCT comments.id, comments.content_id, comments.created_at -- whatever fields you like
FROM comments
INNER JOIN (
SELECT comments.id, first_value(comments.id)
OVER (PARTITION BY content_id ORDER BY created_at DESC) comment_id
FROM comments
) chosen
ON chosen.comment_id = comments.id
> cabal install --only-dependencies && cabal build
Resolving dependencies...
All the requested packages are already installed:
Use --reinstall if you want to reinstall anyway.
setup: Run the 'configure' command first.
1 > ./dist/setup/setup configure
Configuring Presenter-1.0...
setup: At least the following dependencies are missing:
FindBin >=0.0.5,
class BabushkaProvisioner < Vagrant::Provisioners::Base
class Config < Vagrant::Config::Base
attr_accessor :args
attr_accessor :deps
def initialize
@deps = []
end
def dep(dep_spec, args = {})
@benhoskings
benhoskings / gist:6633784
Created September 20, 2013 05:55
sublime key bindings
[
{ "keys": ["super+shift+e"], "command": "use_selection_for_replace"},
{ "keys": ["alt+g"], "command": "next_result"},
{ "keys": ["super+v"], "command": "paste_and_indent"},
{ "keys": ["shift+super+v"], "command": "paste"},
{ "keys": ["super+l"], "command": "show_overlay", "args": {"overlay": "goto", "text": ":"} },
{ "keys": ["super+alt+f"], "command": "replace_next"},
{ "keys": ["super+ctrl+r"], "command": "reveal_in_side_bar"},
@benhoskings
benhoskings / gist:6619930
Created September 19, 2013 07:00
Pushing specific git branches
git_current_branch() {
cat "$(git rev-parse --git-dir 2>/dev/null)/HEAD" | sed -e 's/^.*refs\/heads\///'
}
alias gpthis='gp origin $(git_current_branch)'
alias gpthis!='gp --set-upstream origin $(git_current_branch)'