This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module DefaultConstructor | |
def self.included(base) | |
base.extend(ClassMethods) | |
end | |
module ClassMethods | |
def constructor(*attributes) | |
attr_reader *attributes | |
define_method :initialize do |*attrs| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'cgi/util' | |
require 'cgi/html' | |
ch5 = CGI::HTML5.new | |
puts ch5.instance_eval { | |
html { | |
head { | |
title { "XML encoding with Ruby" } | |
} + | |
body { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data Person = Person { firstName :: String, lastName :: String } deriving Show | |
data DisplayPerson = DisplayPerson { name :: String } deriving Show | |
names :: Person -> [String] | |
names person = [firstName person, lastName person] | |
translate :: Person -> DisplayPerson | |
translate = DisplayPerson . unwords . names | |
translateR :: Person -> DisplayPerson |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
mkdir $1 | |
cd $1 | |
npm init -y | |
npm install -D babelify watchify babel-preset-es2015 babel-preset-react babel-plugin-syntax-flow babel-plugin-transform-flow-strip-types react react-dom | |
echo '{"presets": ["es2015", "react"], "plugins": ["transform-flow-strip-types", "syntax-flow"]}' > .babelrc | |
gibo Node OSX > .gitignore | |
cat <<EOF > .flowconfig | |
[ignore] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<root> | |
<item> | |
<name>TRONキーボード</name> | |
<identifier>private.tron_kbd</identifier> | |
<autogen>__KeyToKey__ KeyCode::OPTION_L, KeyCode::CONTROL_L</autogen> | |
<autogen>__KeyToKey__ KeyCode::COMMAND_R, KeyCode::JIS_KANA</autogen> | |
<autogen>__KeyToKey__ KeyCode::JIS_EISUU, KeyCode::COMMAND_L</autogen> | |
<autogen>__KeyToKey__ KeyCode::JIS_KANA, KeyCode::SPACE</autogen> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* point と colord_point の共通項を型として定義する *) | |
type pointable = <get_pos : int> | |
(* 明示的にキャストすれば同じリストにいれられる *) | |
let lst = [(p :> ptwointable); (cp :> pointable)] | |
# List.map (fun x -> x#get_pos) lst;; | |
- : int list = [365; 123] | |
(* リストに型制約をつけて宣言する *) | |
# let l : pointable list = [p; cp];; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
module TelSplitter | |
MAP = { | |
# 市外局番 , 市内局番の桁数のマップ | |
# http://www.soumu.go.jp/main_sosiki/joho_tsusin/top/tel_number/number_shitei.html のデータを利用 | |
# 固定電話以外の桁数は適当です... | |
'050' => 4, # IP電話 | |
'070' => 4, # 携帯電話/PHS | |
'080' => 4, # 携帯電話 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun spamf-register-words-directory (corpus dirname) nil) | |
(defun spamf-register-words-file (corpus filename) nil) | |
(defun spamf-register-words-buffer (corpus buffer) nil) | |
(defun spamf-register-words-string (corpus string) nil) | |
(defun spamf-delete-words-directory (corpus dirname) nil) | |
(defun spamf-delete-words-file (corpus filename) nil) | |
(defun spamf-delete-words-buffer (corpus buffer) nil) | |
(defun spamf-delete-words-string (corpus string) nil) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'objspace' | |
module MemoryMesureable | |
extend ActiveSupport::Concern | |
included do | |
delegate :memsize_of, to: ObjectSpace | |
end | |
def memsize |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ruby -p -e "gsub /\e\[\d{1,3}[mK]/, ''" < INPUT > OUTPUT |