This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def resize_and_crop(blob, w0, h0, w1, h1) | |
image = MiniMagick::Image.read(blob) | |
rw = w1.to_f / w0 | |
rh = h1.to_f / h0 | |
unless rw > 1 or rh > 1 | |
w,h = w1, h1 | |
sx, sy = 0, 0 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set :deploy_via, :remote_cache | |
set :branch, "release" | |
namespace :git do | |
namespace :ensure do | |
desc "Check if your local branch is synched with remote branch" | |
task :pushed do | |
local = `git rev-parse #{branch}`.chomp | |
remote = `git rev-parse remotes/origin/#{branch}`.chomp | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Testing two structures if they are unifiable. | |
# | |
module UnifierAssertion | |
def unify(es, s = {}, &block) | |
return s if es.empty? | |
e = es.shift | |
a,b = e | |
a = s[a] || a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "test_helper" | |
require "unifier_assertion" | |
class UnifierAssertionTest < ActiveSupport::TestCase | |
include UnifierAssertion | |
test "unifier" do | |
assert_equal({:"'a" => 1 }, | |
unify([[ | |
[1,2,3], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AjaxQ | |
initialize: (options) -> | |
_.extend(this, Backbone.Events) | |
@options = _.clone(options) | |
_.extend(@options, max:3) | |
@waiting = [] | |
@requests = [] | |
enqueue: (k) -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1) Failure: | |
JsonIO::API3::Form::CheckoutTest#test_update_checkout_from_open_to_close [/Users/soutaro/src/ubiregi-server/test/unit/json_io/api3/form/checkout_test.rb:342]: | |
=> {:id=>76, | |
:guid=>"checkout_guid_1", | |
:account_id=>1743, | |
:paid_at=>2013-09-01 13:05:00 UTC, | |
:closed_at=>Sun, 01 Sep 2013 22:05:00 JST +09:00, | |
:deleted_at=>nil, | |
:created_at=>2014-06-02 06:26:38 UTC, | |
:updated_at=>2014-06-02 06:26:38 UTC, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module A | |
module B | |
module C | |
def self.f() | |
puts "X = #{X}" | |
end | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
class A0 { } | |
class A1: A0 { } | |
class A2: A1 { } | |
class Array<X> { | |
func get() -> X { fatalError() } | |
func set(x: X) -> () { fatalError() } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat -n w.rb | |
1 a = [1] | |
2 | |
3 a.each do |a| | |
4 a = 3 | |
5 end | |
6 | |
7 p a | |
$ ruby -cw w.rb | |
w.rb:3: warning: shadowing outer local variable - a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ['a] rbarray = object method map : 'b . ('a -> 'b) -> 'b rbarray = Obj.magic () end;; | |
(* Error: The universal type variable 'b cannot be generalized: | |
it escapes its scope. *) |
OlderNewer