Skip to content

Instantly share code, notes, and snippets.

@fny
fny / assets.rb
Created July 8, 2015 01:09
Dry Up Your Initializers with #tap
# Before
Rails.application.config.assets.version = '1.0'
Rails.application.config.assets.paths << Emoji.images_path
Rails.application.config.assets.precompile += %w( search.js )
# After
Rails.application.config.assets.tap do |assets|
assets.version = '1.0'
assets.paths << Emoji.images_path
assets.precompile += %w( search.js )
@snoozer05
snoozer05 / gist:1477002
Created December 14, 2011 15:23
sumim さんのボウリング集計のコード(http://d.hatena.ne.jp/sumim/20111214/p1)を Ruby で
def score1(pins)
cursor = 0
frame_points = []
9.times do
frame_points << pins[cursor, 3]
cursor += 2
if frame_points.last.first == 10
cursor -= 1
else
if frame_points.last.take(2).inject(:+) != 10
@ppworks
ppworks / gist:3107537
Created July 13, 2012 21:17
Backbone.js で History.pushState未実装ブラウザでhash fragmentを使わずにそのままのurlを使う
window.App =
Models: {}
Collections: {}
Views: {}
Routers: {}
init: (options)->
options = {} unless options
options.pushState = true
options.hashChange = false # don't want to rewrite /pathname to #pathname
シェルTIPS 20min
===========
コンピュータの方がうまくできることに人間を使うな。
-- Tom Duff
キーバインド
----------
Emacs の基本操作とおなじ。
@rhumlover
rhumlover / review.md
Last active December 5, 2016 23:36
Javascript Templates Comparison: Hogan, dust, doT, underscore

JavaScript Templates Engines

A quick comparison/ benchmark between Hogan, Dust, doT and underscore

Presentation and Readability

Hogan.js

Developed by Twitter (same team as Bootstrap), use exactly the same syntax as Mustache, but more performant and more stuff available server side.

My name is {{ name }}

def count_by_word(string)
fn = ->(s, h){ h[s] += 1 }
string
.scan(/\w+/)
.each_with_object(Hash.new(0), &fn)
end
@hyuki0000
hyuki0000 / positive.tex
Created June 2, 2017 13:44
正の整数の分類
$n$を正の整数とする。$n$を割り切る正の整数が$1$個しかないとき、$n$を<b>単数</b>という。ちょうど$2$個あるとき、$n$を<b>素数</b>という。$3$個以上あるとき、$n$を<b>合成数</b>という。
$$
\begin{array}{|c|c|c|c|c|c|c|c|c|c}
\hline
\textbf{単数} & 1 & & & & & & & & & & \\
\hline
\textbf{素数} & & 2 & 3 & & 5 & & 7 & & & & \\
\hline
\textbf{合成数} & & & & 4 & & 6 & & 8 & 9 & 10 & \\
@gaspanik
gaspanik / rvm2rbenv-setup.markdown
Last active June 7, 2018 23:23
RVMからrbenvに移行した手順まとめ

RVMからrbenvへの移行(OS X 10.8.x)

(注意)既にRVMを使ってRubyがインストール済みなので、OS X標準のRubyではなくHomebrewを使って別バージョンのRubyをインストールするまでのもろもろの準備は省いています。その部分が必要であれば、このあたりの記事の前段が参考になるかもしれません(Rails OS X Developer Guide)。

RVMのアンインストール

まずは、RVMをアンインストールしましょう。

$ rvm implode
@rsff
rsff / ssh_agent_start.fish
Last active March 14, 2019 08:56 — forked from schaary/ssh_agent_start.fish
ssh agent for fish
#this script can never fail
#i use it in the fish_config
#call it with start_agent
setenv SSH_ENV $HOME/.ssh/environment
function start_agent
if [ -n "$SSH_AGENT_PID" ]
ps -ef | grep $SSH_AGENT_PID | grep ssh-agent > /dev/null
@onteria
onteria / kaomoji.txt
Created October 19, 2012 05:08
顔文字.txt
a(;`・ω・)o━ヽ_。_・_゚_・_フ))
?(っ´。ω゜`c)
☝(〃`l _ l´)☝
☝( ◠‿◠ )☝
༼(*꒪ั❥꒪ั*༽༽
(✿꒪ั◡꒪ั✿)
(੭ु ˃̶͈̀ x ˂̶͈́)੭ु⁾⁾
:(ヽ'ω`):
+。:.゚٩(๑>◡<๑)۶:.。+゚
(★l ω l)