This file contains 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 ruby | |
# | |
# enumetric.rb | |
# | |
# Rough estimate of usage/non-usage of Enumerable methods | |
TRIVIAL_METHODS = [:first, :count, :to_a] | |
def count_usage(method, dir = '.') | |
method_delimiter = '[\s\.\{\(=]' |
This file contains 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
GYRR | |
RYYGYG | |
GYGYRR | |
RYGYRG | |
YGYRYG | |
GYRYRG | |
YGYRYR | |
YGYRYR | |
YRRGRG | |
RYGYGG |
This file contains 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
# -*- coding: utf-8 -*- | |
<!-- beginning_of_monthはyyyy-mm-ddで取得するが、 | |
ddが入ってるのがクエリで見えてしまうとおかしいし不要な情報でもあるので加工してる。--> | |
<% Work.all.map {|w| w.date.beginning_of_month}.uniq.sort.each do |m| -%> | |
<%= link_to_unless_current m.month, month: m.to_s.sub!(%r[\-\d{2}$],"") %> | |
<% end %> |
This file contains 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
# 一部抜粋 | |
# emacsのエイリアス | |
alias e='emacsclient -t' | |
alias kille="emacsclient -e '(kill-emacs)'" | |
if pgrep emacs >/dev/null 2>&1; then | |
echo "Emacs server is already running..." | |
else | |
`emacs --daemon` | |
fi |
This file contains 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
separator = %Q(+#{"-" * ARGV.size}+) | |
result = ARGV.map do |arg| | |
[separator, "|" << arg.ljust(ARGV.size) << "|"] | |
end | |
puts result << separator |
This file contains 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
# -*- coding: utf-8 -*- | |
class Janken | |
HAND = %i(グー チョキ パー) | |
def hand | |
@hand = HAND.shuffle.first | |
end | |
def versus(other) | |
other = other.hand |
This file contains 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
var net = require('net'); | |
var readline = require('readline'); | |
var util = require('./util'); | |
var server = net.createServer(); | |
server.maxConnections = 3; | |
function Client(socket) { | |
this.socket = socket; | |
} |
This file contains 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
var http = require('http'); | |
server = http.createServer(function (req, res) { | |
res.writeHead(200, {'Content-Type': 'text/plain'}); | |
res.end('Hello World\n'); | |
server.close(); | |
}); | |
server.listen(8080, 0, function () { | |
console.log('Server running at http://localhost:8080/'); | |
}); |
This file contains 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
var http = require('http'); | |
server = http.createServer(function (req, res) { | |
console.log(req.url); | |
res.writeHead(200, {'Content-Type': 'text/plain'}); | |
res.end('Hello World\n'); | |
req.on('end', function() { | |
req.connection.end(); | |
}); | |
}); | |
server.on('connection', function() { |
This file contains 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
# language: ja | |
フィーチャ: 自販機でジュースを購入できる | |
自販機にお金を投入したら、ジュースが選択可能になる | |
ジュースを決定すれば、ジュースとお釣りが出てくる | |
シナリオ: お金を投入したら、ジュースが購入可能になる | |
前提 トップページを表示している | |
もし "100"円を投入する | |
かつ "10"円を投入する | |
かつ "10"円を投入する |
OlderNewer