Skip to content

Instantly share code, notes, and snippets.

View hanachin's full-sized avatar
🌺
OKA

Seiei Miyagi hanachin

🌺
OKA
View GitHub Profile
@hanachin
hanachin / file2.txt
Last active December 20, 2018 02:14
定数の名前書き換えloadするimport_as gemの紹介 ref: https://qiita.com/hanachin_/items/c3c513b1215de18b62f3
module ImportAs
class DSL
def initialize(&block)
@as = block
end
end
def import(&block)
DSL.new(&block)
end
@hanachin
hanachin / file0.txt
Last active December 6, 2018 15:16
refineをしてるモジュール取り出せるrefinements_robbery gem ref: https://qiita.com/hanachin_/items/20c1b77936962ee07a7d
require "refinements_robbery"
class C
using Module.new {
refine(C) {
def hi
puts "hi"
end
}
}
@hanachin
hanachin / file11.txt
Last active December 6, 2018 12:52
pendingしてからコミットpushしよう 〜RSpecしぐさ〜 ref: https://qiita.com/hanachin_/items/bfce007529c962c5ed74
% rspec /tmp/pending.rb
*
Pending: (Failures listed here are expected and do not affect your suite's status)
1) usingをキメると気持ちいい
# No reason given
Failure/Error: subject { self.pleasure? }
NoMethodError:
@hanachin
hanachin / file0.txt
Last active December 5, 2018 14:28
TracePointのenable(target: )は戻り値を書き換えるときべんり ref: https://qiita.com/hanachin_/items/d5e243048900344b2146
# 2.6.0-devで動く
using Module.new {
refine(Object) do
def fizzbuzz_env(*ns)
Module.new {
# このRefinementsのモジュールをあとで使うので取っておく
r = refine(Integer) {
# methodがRubyで定義されていないとenableのtargetに指定できないため
# Refinementsで再定義
def to_s

Keybase proof

I hereby claim:

  • I am hanachin on github.
  • I am hanachin (https://keybase.io/hanachin) on keybase.
  • I have a public key whose fingerprint is 4FA4 4513 DA29 52D3 C20A E0B4 80B4 87C5 55BB 71DA

To claim this, I am signing this object:

@hanachin
hanachin / file0.txt
Last active December 5, 2018 14:27
Re: シクシク素数アドベントカレンダー Ruby 編 ref: https://qiita.com/hanachin_/items/ac842237556d0a1d5a1b
require 'prime'
😭prime = Prime.each.lazy.select {|prime|
digits = prime.digits
digits.include?(4) || digits.include?(9)
}
puts 😭prime.take(ARGV.first.to_i).to_a.join(",")
@hanachin
hanachin / file0.txt
Last active December 5, 2018 14:27
Re: Ruby で季節のような循環する概念を表したい ref: https://qiita.com/hanachin_/items/583e7a202667bdf24b7c
season = %w[春 夏 秋 冬].cycle
season.next # => "春"
season.next # => "夏"
season.next # => "秋"
season.next # => "冬"
@hanachin
hanachin / Gemfile
Last active December 2, 2018 11:36
RailsのviewでPDFを書くSATySFi-rails gemの使い方 ref: https://qiita.com/hanachin_/items/f8424d766d3020d32acf
gem "SATySFi-rails"
@hanachin
hanachin / file0.txt
Created October 23, 2018 22:10
SATySFiで二項演算子や単項演算子を定義する ref: https://qiita.com/hanachin_/items/14501730a3c065d63d09
let ( ここに演算子にしたい文字列を書く ) 引数1 引数2 = 結果
@require: stdja
@require: list
module Kansuji : sig
direct \kansujichar0 : [inline-text] inline-cmd
direct \kansujichar1 : [inline-text] inline-cmd
direct \kansujichar2 : [inline-text] inline-cmd
direct \kansujichar3 : [inline-text] inline-cmd
direct \kansujichar4 : [inline-text] inline-cmd
direct \kansujichar5 : [inline-text] inline-cmd