Skip to content

Instantly share code, notes, and snippets.

View flada-auxv's full-sized avatar
🎯
Focusing

flada-auxv flada-auxv

🎯
Focusing
View GitHub Profile

Keybase proof

I hereby claim:

  • I am flada-auxv on github.
  • I am flada (https://keybase.io/flada) on keybase.
  • I have a public key ASDQh1yTlP0ZPvfFJRGsVa8gwRhhgJVM0fEKC43oE_NELAo

To claim this, I am signing this object:

@flada-auxv
flada-auxv / README.md
Created August 23, 2018 09:32
internal transaction で発生した event も元の transaction の receipt に含まれる

truffle のデフォルトのディレクトリ構成で contracts/ に Test.sol を配置して

truffle console
> migrate --reset

Fuga.deployed().then(c => c.FugaEvent().options.topics[0] )
// '0x036b5e160c95e397eb8e8ad88d596c87ba315b302a96e253e54a15d259ad4e1a'

Hoge.deployed().then(c => c.HogeEvent().options.topics[0] )
@flada-auxv
flada-auxv / calc_revenue_from_gen0_kitty_sale.js
Created August 23, 2018 04:42
[WIP] Calculate revenue from CryptoKitties' gen0 kitty sale (as in some block range)
// Calculate revenue from gen0 kitty sale (as in some block range)
//
// $ node /path/to/thisFile
// { wei: "9598226439521243188",
// ether: "9.598226439521243188",
// blockRange: "6090000...6100000",
// "salesCount(only gen0 kitty)": 117,
// "birthCount(only gen0 kitty)": 148,
// "SalesCount(all the kitties)": 458 }
class Hoge
def combination(array, num)
return [] if num == 0
return array.map {|elem| Array(elem) } if num == 1
each_with_rest(array).with_object([]) {|(elem, rest), result|
result.push(*_combination(rest, [elem], num))
}
end
class Player
attr_reader :size
def initialize(senryaku)
@count = 0
@size = senryaku.size
@senryaku = senryaku
@senryaku_enum = senryaku.each_char.cycle
end
@flada-auxv
flada-auxv / Gemfile
Last active February 12, 2016 01:59
hiyorime
source 'https://rubygems.org'
gem 'sinatra'
@flada-auxv
flada-auxv / Gemfile
Last active January 26, 2016 02:58
tegaki-jan sample
source "https://rubygems.org"
gem "sinatra"
@flada-auxv
flada-auxv / gist:052f5dfff9b8a8b2aec5
Last active August 29, 2015 14:13
has_many :through な関連で accepts_nested_attributes_for を定義している時、親オブジェクトが保存されていない状態で子オブジェクトとの関連付けを行うと、外部キーが nil な中間テーブルの record を insert して死ぬ
# from http://guides.rubyonrails.org/association_basics.html#the-has-many-through-association
##### Model #####
class Physician < ActiveRecord::Base
has_many :appointments
has_many :patients, through: :appointments
accepts_nested_attributes_for :appointments
end
#!/usr/bin/env ruby
LOG_ITEMS = %w(ip_address ident_user_name authenticate_user_name access_date request_line status_code forwarding_byte caller_url user_agent).each
class LogParser
def initialize(logs)
@logs = logs.chomp
@result = {}
@start_idx = 0
end
@flada-auxv
flada-auxv / kairo.rb
Created August 23, 2013 18:22
抵抗の合計を求める
class Circuit
def initialize(circuit)
@circuit = analyze(circuit)
end
def calc
@circuit.inject(0) {|memo, item| memo + item.val}.truncate
end
def analyze(circuit)