Skip to content

Instantly share code, notes, and snippets.

View Shinpeim's full-sized avatar

Shinpei Maruyama Shinpeim

View GitHub Profile
module Nyan
def nyan
"nyan"
end
extend self
end
class Neko
include Nyan
@Shinpeim
Shinpeim / embed.css
Created December 12, 2012 17:37 — forked from kkosuge/embed.css
.gist {
color: #000;
}
.gist div {
padding: 0;
margin: 0;
}
.gist .gist-file {
a--- 0--- b--- --0- a--- 0--- b--- --0- a--0 a--0 a--0 a--0 a--- 0--- b--- --0-
c--- ---- c--- c--- d-0- e--- 0--- e--- f--- ---- ---- 0--- g--- g--- g--- 0---
a--- 0--- b--- --0- a--- 0--- b--- --0- a--0 a--0 a--0 a--0 a--- 0--- b--- --0-
c--- ---- c--- c--- d-0- e--- 0--- e--- f--- ---- ---- 0--- g--- g--- g--- 0---
r--- ---- ---- 0--- a0-- z--- z--- 0--- g--- g--- g--- 0--- e--- ---- ---- 0---
c--- ---- c--- c--- d-0- e--- 0--- e--- f--- ---- ---- 0--- g--- g--- g--- 0---
r--- ---- ---- 0--- a0-- z--- z--- 0--- g--- g--- g--- 0--- e--- ---- ---- 0---
c--- ---- c--- c--- d-0- e--- 0--- e--- f--- ---- ---- 0--- g--- g--- g--- 0---
class A
class B
def self.nyan
"A::B"
end
end
def self.nyan
B.nyan
end
def self.wan
@Shinpeim
Shinpeim / 000.md
Last active November 2, 2024 00:52
プロセスとかスレッドとかプロセス間通信とかについて書く場所

重要

サイズがあまりに大きくなってしまったので、gist ではなくて github 上で管理するようにしました。

https://github.com/Shinpeim/process-book

URL 変わっちゃうの申し訳ないんだけど、一覧性が高くなるのと pull req が受け取れるメリットのほうを取ります。せっかく読みにきてくれたのにひと手間かかっちゃってすみません。

この文書の目的

# -*- coding: utf-8 -*-
class Player
attr_reader :position
# Cで言うenum的なやつが増えた
module MOVING_MODE
NORMAL = 1
FAST = 2
end
# -*- coding: utf-8 -*-
class Player
attr_reader :position
def initialize(position)
@position = position
end
def move(direction)
case direction
# -*- coding: utf-8 -*-
class Player
attr_reader :position
# Cで言うenum的なやつ
module MOVING_MODE
NORMAL = 1
FAST = 2
KANI = 3 #蟹モードが増えた
end
# -*- coding: utf-8 -*-
class Player
# それぞれのモードをクラスに切り分けて、
# それぞれの振る舞いを定義してあげる
module MovingMode
class Normal
def move(direction, position)
case direction
when :up
position[:y] -= 10
# -*- coding: utf-8 -*-
class Player
module MovingMode
class Normal
def move(direction, position)
case direction
when :up
position[:y] -= 10
when :down
position[:y] += 10