Skip to content

Instantly share code, notes, and snippets.

View soutaro's full-sized avatar

Soutaro Matsumoto soutaro

View GitHub Profile
@soutaro
soutaro / goodcheck.yml
Last active March 14, 2019 23:11 — forked from sumyapp/goodcheck.yml
Secret check Goodcheck.yml, Inspired by Skyscanner/sonar-secrets
rules:
# Inspired by this rule: https://github.com/Skyscanner/sonar-secrets/blob/v1.3.0/java/src/main/java/org/sonar/skyscanner/java/checks/PrivateKeys.java
- id: review.sider.general.security.private_keys
pattern:
- "-----BEGIN RSA PRIVATE KEY-----"
- "-----BEGIN DSA PRIVATE KEY-----"
- "-----BEGIN EC PRIVATE KEY-----"
- "-----BEGIN OPENSSH PRIVATE KEY-----"
- "-----BEGIN PRIVATE KEY-----"
message: Do not put private keys in this repository.
@soutaro
soutaro / gist:5cb6cee5a23a3c7da23a0c48c7bedd48
Created July 5, 2017 11:58
先にraiseしてからjoinする
Thread.new { raise "error from thread" }.tap { sleep 1 }.join
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. *)
@soutaro
soutaro / ruby -cw
Last active June 15, 2016 02:23
ruby -cw
$ 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
import Foundation
class A0 { }
class A1: A0 { }
class A2: A1 { }
class Array<X> {
func get() -> X { fatalError() }
func set(x: X) -> () { fatalError() }
}
@soutaro
soutaro / gist:e96d883bf31ce599ef4c
Last active August 29, 2015 14:16
remove_const
module A
module B
module C
def self.f()
puts "X = #{X}"
end
end
end
end
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,
class AjaxQ
initialize: (options) ->
_.extend(this, Backbone.Events)
@options = _.clone(options)
_.extend(@options, max:3)
@waiting = []
@requests = []
enqueue: (k) ->
@soutaro
soutaro / gist:1785776
Created February 10, 2012 02:42
Test codes for unification
require "test_helper"
require "unifier_assertion"
class UnifierAssertionTest < ActiveSupport::TestCase
include UnifierAssertion
test "unifier" do
assert_equal({:"'a" => 1 },
unify([[
[1,2,3],
@soutaro
soutaro / gist:1785761
Created February 10, 2012 02:38
Testing structures with meta variables, as unification.
# 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