Skip to content

Instantly share code, notes, and snippets.

require 'httpclient'
require 'json'
module HTTP
class Message
# Returns JSON object of message body
alias original_content content
def content
if JSONClient::CONTENT_TYPE_JSON_REGEX =~ content_type
JSON.parse(original_content)
@ohnishiakira
ohnishiakira / .gemrc
Created August 1, 2011 03:13
.gemrcの書き方
# 普段はこう書いている
install: --no-rdoc --no-ri
update: --no-rdoc --no-ri
search: --remote
specification: --remote
@kachick
kachick / compare_array.rb
Created September 25, 2012 14:55
Array 要素すべてが#==で一致するか調べる
values = [1, 2, 3]
others = [1.0, 2.0, 3.0]
(values.length == others.length) && values.each_with_index.all?{|v, idx|v == others.fetch(idx)}
@fujimura
fujimura / pipe.rb
Last active December 18, 2015 16:59
Object#pipe
class Object
def pipe
yield self
end
end
# From https://github.com/rspec/rspec-rails/pull/766/files
# Without Object#pipe
types = begin
@shunito
shunito / BeBe_sample.html
Last active December 26, 2015 16:09
BeBeはBiB/i の薄いラッパーです。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>BeBe Sample</title>
<style>
h1 { font-size: 120%; }
</style>
<script src="js/jquery-1.9.1.js"></script>
<script>
@rtoal
rtoal / htmlCollectionIteratorPolyfill.js
Created December 14, 2016 16:52
Polyfill allowing iteration of Safari's HTMLCollection objects
// Polyfill because Safari's HTMLCollections are not iterable
if (typeof HTMLCollection.prototype[Symbol.iterator] !== 'function') {
HTMLCollection.prototype[Symbol.iterator] = function () {
let i = 0;
return {
next: () => ({done: i >= this.length, value: this.item(i++)})
}
};
}
無人島にAさん、Bさん、Cさんが流れついたとする。国へ帰る見込みがほとんどなく当然その状況では誰も日本円他法定通貨は欲しがらずまったく価値がない状況だとする
Aさん食料つくる
Bさん飲料つくる
Cさん食料つくる
という感じで漂着当初は食いつなぐために日々その日の全ての時間をついやしていました。当然みんなでその日得られた飲食物をわけあってました。
しばらくすると食料と飲料の生産効率があがり貯蔵できるようになってきました。そうなると余った時間を使って嗜好品も生産するようになってきました。
ここで3人は通貨みたいなものが必要だねという話になりました。
はじめはそこらにあった100個の貝殻を通貨とみたてて3人の合意のもと流通させてみました。当初は予想通りうまく流通して飲食物や嗜好品が交換されてそれに伴い
@X0nic
X0nic / disable-vagrant-time-sync.sh
Last active February 4, 2022 04:52
Disable vagrant time sync
#List vms
VBoxManage list vms
#get status of time sync
VBoxManage getextradata <vm-name> VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled
#NOTE: Make sure to restart the VM after changing these settings.
#disable time sync
VBoxManage setextradata <vm-name> VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled 1
@suginoy
suginoy / rent2018.md
Last active May 19, 2022 14:00
RENTについて

RENTについて

映画化もされていて、映画版もなかなかよく、ここから入門した人も多いのですが、舞台版を最初に見る方がオススメです。 Yahoo!映画に「世界観が受け付けない!」という書き込みを見ても耐えられるくらいは大人になったので、お気に召さなくてもまったく私は元気です。 「伝説の」という枕詞が付く理由は、以下のYouTubeを見ればだいたいわかります。 昔NHK BSの番組「ブロードウェーの100年」という番組の一部でやったやつです。

38分46秒から始まります。44分14秒まで。

https://www.youtube.com/watch?v=VCObLZUP3k4&amp;feature=youtu.be&amp;t=38m46s

@kiesia
kiesia / attributes-default.rb
Created July 5, 2012 06:12 — forked from philwo/attributes-default.rb
Chef cookbook for nginx + passenger (compiled from source)
default['nginx']['version'] = "1.2.0"
default['nginx']['passenger']['version'] = "3.0.12"