Skip to content

Instantly share code, notes, and snippets.

View kuinak's full-sized avatar

Evan Petrie kuinak

View GitHub Profile

Why doesn't GitHub support the fast-forward merge strategy?

The fast-forward merge strategy is the default strategy employed by git when the base branch is the direct ancestor of the head branch.

For example:

~ % mkdir foo
~ % cd foo
~/foo % git init .
PTY.spawn cmd do |i, o, pid|
Thread.new { o.putc STDIN.getch while !o.closed? }
t = Thread.new { putc i.readchar while !i.eof? }
Process::waitpid(pid) rescue nil
t.join
end

Keybase proof

I hereby claim:

  • I am kuinak on github.
  • I am kuinak (https://keybase.io/kuinak) on keybase.
  • I have a public key whose fingerprint is A6A2 CC36 9F1F C142 D3FA 6A63 B100 74D1 2B55 F12F

To claim this, I am signing this object:

2.0.0p0 :001 > x = ActionController::Parameters.new(a: {b: "foo"})
=> {"a"=>{"b"=>"foo"}}
2.0.0p0 :002 > x.require(:a).permit(:b)
=> {"b"=>"foo"}
2.0.0p0 :003 > include ActionDispatch::TestProcess
=> Object
2.0.0p0 :004 > x = ActionController::Parameters.new(a: {b: fixture_file_upload("spec/test.jpg")})
=> {"a"=>{"b"=>#<Rack::Test::UploadedFile:0x007ffaa5cb8b88 @content_type=nil, @original_filename="test.jpg", @tempfile=#<Tempfile:/var/folders/pb/3546xrb11pl1cl34gdx9jrsc0000gn/T/test.jpg20130511-7104-1w3q5j9>>}}
2.0.0p0 :005 > x.require(:a).permit(:b)
ActionController::UnpermittedParameters: found unpermitted parameters: b
Loading development environment (Rails 3.2.8)
1.9.3p194 :001 > Foo.unscoped.all.count
Foo Load (0.5ms) SELECT "foos".* FROM "foos"
=> 2
1.9.3p194 :002 > Foo.first.destroy
Foo Load (0.2ms) SELECT "foos".* FROM "foos" WHERE "foos"."reviewed" = 't' LIMIT 1
(0.1ms) begin transaction
SQL (0.5ms) DELETE FROM "foos" WHERE "foos"."id" = ? [["id", 9]]
(5.5ms) commit transaction
=> #<Foo id: 9, reviewed: true, created_at: "2012-09-27 04:03:08", updated_at: "2012-09-27 04:03:08">
@kuinak
kuinak / gist:3764026
Created September 21, 2012 21:28
How to crop an image down to a square thumbnail
# takes image and fits to a square, cutting off edges
convert original.jpg -thumbnail 150x150^ -gravity Center -extent 150x150 new.jpg
# takes image and fits to a square, specified by bounds
convert -extract 200x200+250+0 -thumbnail 150x150^ -extent 150x150 -strip original.jpg new.jpg
#!/bin/sh
### BEGIN INIT INFO
# Provides: ntp
# Required-Start: $network $remote_fs $syslog
# Required-Stop: $network $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 1
# Short-Description: Start NTP daemon
### END INIT INFO
@kuinak
kuinak / chef_server.bash
Created June 19, 2012 17:54
chef_server
#!/bin/bash
# curl -L https://raw.github.com/gist/2955566 | bash
echo "deb http://apt.opscode.com/ `lsb_release -cs`-0.10 main" | tee /etc/apt/sources.list.d/opscode.list
mkdir -p /etc/apt/trusted.gpg.d
gpg --keyserver keys.gnupg.net --recv-keys 83EF826A
gpg --export packages@opscode.com | tee /etc/apt/trusted.gpg.d/opscode-keyring.gpg > /dev/null
apt-get update
apt-get -y install opscode-keyring
@kuinak
kuinak / gist:2141761
Created March 20, 2012 22:07 — forked from dx7/gist:1333785
Installing ruby-debug with ruby-1.9.3-p125
# Install with:
# bash < <(curl -L https://raw.github.com/gist/2141761)
#
# Reference: http://blog.wyeworks.com/2011/11/1/ruby-1-9-3-and-ruby-debug
echo "Installing ruby-debug with ruby-1.9.3-p125 ..."
curl -OL http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem
curl -OL http://rubyforge.org/frs/download.php/75415/ruby-debug-base19-0.11.26.gem
rails (master) $ git grep 'inject(\[\])'
actionpack/lib/action_controller/metal/http_authentication.rb: "Digest " + credentials.sort_by {|x| x[0].to_s }.inject([]) {|a, v| a << "#{v[0]}='#{v[1]}'" }.join(', ')
actionpack/lib/action_view/helpers/form_options_helper.rb: options_for_select = container.inject([]) do |options, element|
actionpack/test/template/form_options_helper_test.rb: @fake_timezones = %w(A B C D E).inject([]) do |zones, id|
activemodel/lib/active_model/serialization.rb: method_names = Array.wrap(options[:methods]).inject([]) do |methods, name|
activemodel/lib/active_model/serializers/xml.rb: Array.wrap(options[:methods]).inject([]) do |methods, name|
activerecord/README: clients.inject([]) { |people, client| people + client.people }
activerecord/lib/active_record/associations/association_collection.rb: collection.inject([]) do |kept, record|
activerecord/lib/active_record/base.rb: @@subclasses[self] + @@subclasses[self].inject([]) {|list, su