Skip to content

Instantly share code, notes, and snippets.

Avatar

Ben Hoskings benhoskings

View GitHub Profile
@benhoskings
benhoskings / gist:3f9062dc20961291a230
Created Oct 6, 2014
英語の練習のオススメ
View gist:3f9062dc20961291a230
いい練習の番組:
Seinfeld (アメリカ、コメディー) 話が本当にアメリカの形。ユーモアが最高。一番有名なので英語が話せる人とたしかにしゃべれる。
Frasier (アメリカ、コメディー) 一杯あるし、Kelsey GrammerとDavid Hyde Pierceの英語がうまい。
The Office (UKとUSの番組だって、両方ある。とてもいいイギリスとアメリカの比べる事。)
Sherlock (イギリス、) 話がとても速いけど、いいイギリスの英語だと思う。
その他:(これは、僕がちょっとだけ見ましたけど、いい練習だと思う。)
Futurama
House
View gist:688186f4791f1bd719bb
def self.cumulative_by_month model, column
tally = 0
count_by_month(model, column).map do |(month, count)|
[month, tally += count]
end
end
def self.cumulative_by_month_inject model, column
count_by_month(model, column).tap {|pairs|
pairs.inject(0) do |tally,pair|
View babushka-latest-brew.md

For the package management you're talking about, it sounds like there are two cases:

  • Accept any version (1)
  • Require a specific version (2)
  • Require the latest version (3)

Babushka can already do (1) and (2). The third is fairly easy to add, but to do so in babushka core isn't really feasible until I refactor Babushka::BrewHelper.

For (1), you don't need to do anything: that's the standard behaviour. For example:

@benhoskings
benhoskings / gist:8344953
Created Jan 10, 2014
Ben's guide to painless ruby switching with chruby
View gist:8344953
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
View normalize.rb
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 Oct 28, 2013
sublime config.py
View gist:7192000
{
"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,
View postgres-window-function.sql
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
View gist:6693097
> 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,
View babushka_vagrant.rb
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 Sep 20, 2013
sublime key bindings
View gist:6633784
[
{ "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"},
You can’t perform that action at this time.