Skip to content

Instantly share code, notes, and snippets.

View Shinpeim's full-sized avatar

Shinpei Maruyama Shinpeim

View GitHub Profile
class Prisoner
attr_reader :color
def initialize(num_of_color)
@color = rand(num_of_color)
end
end
class Solver
def initialize(num_of_prisoner, num_of_color)
require "inline"
class Nyan
inline do |builder|
builder.c "
int add(int a, int b) {
return a + b;
}"
end
end
n = Nyan.new
// ==UserScript==
// @name ChatWork Image Extractor
// @description Image extractor for ChatWork.
// @include https://www.chatwork.com/*
// @version 0.0.1
// ==/UserScript==
(function(){
function main(){
var extractedList = []
class Node
attr_accessor :parent
attr_reader :value
def self.merge(a, b)
a.root_node.parent = b.root_node
end
def self.same_group?(a, b)
a.root_node == b.root_node
@Shinpeim
Shinpeim / Main.scala
Last active December 5, 2018 15:44
Scalaで組み込みクラスの直和型作るやつ考えてみてる
object Main extends App {
trait IntOrString{
val value:Any // ここつらい
}
implicit class MyInt(self: Int) extends IntOrString{
val value:Int = self
}
implicit class MyString(self:String) extends IntOrString{
val value:String = self
}
@Shinpeim
Shinpeim / Main.scala
Created December 2, 2013 07:23
implicitly
object Main {
def main(args:Array[String]): Unit = {
implicit val nyan:String = "nyan"
println(implicitly[String])
}
}
@Shinpeim
Shinpeim / gist:7701608
Last active December 29, 2015 17:08 — forked from civic/gist:7701433
  • ボールみたいなソファ
  • 椅子(アーロン、オカムラ...etc)
  • パーティション有無
  • マルチモニタ数
  • キーボード提供
  • OS選択の自由
  • 服装の自由
  • フレックスタイム実態の自由度
  • フリードリンク
  • フリーお菓子
a = 1
def nyan
b = 2
p a # raise undefined local variable Error
p b # => 2
end
class Nyan
p a # raise undefined local variable or method Error
c = 3
p self #=> main
class Nyan
p self # => Nyan
class << self
p self #=> #<Class:Nyan>(Nyanの特異クラス)
def class_method_a
p self # => Nyan
end
class Nyan
def replace_method(a, b)
(class << self; self end).module_exec do
alias_method "#{a}_backup", a
alias_method "#{b}_backup", b
alias_method b, "#{a}_backup"
alias_method a, "#{b}_backup"
end
end