Skip to content

Instantly share code, notes, and snippets.

@yohfee
yohfee / Vagrantfile
Last active July 15, 2021 23:43
Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network "forwarded_port", guest: 3000, host: 3000
config.vm.network "private_network", ip: "192.168.33.20"
config.vm.synced_folder ".", "/app", nfs: true
@yohfee
yohfee / game_test.rb
Created December 13, 2014 13:45
Code Retreat Sendai #01
require 'test/unit'
class GameTest < Test::Unit::TestCase
def test_a_cell_knows_its_neighbors
cell = Cell.new(1, 1)
expected_neighbours = [
Cell.new(0, 0), Cell.new(1, 0), Cell.new(2, 0),
Cell.new(0, 1), Cell.new(2, 1),
@yohfee
yohfee / _favorite_button.html.erb
Created June 17, 2014 14:22
RE: Rails4 でお気に入りをオン・オフするトグルボタンみたいのをやってみるメモ
<% if current_user.fav? comment %>
<%= link_to "Favorite", comment_favorites_path(comment), method: :delete, remote: true, class: 'btn btn-xs btn-warning' %>
<% else %>
<%= link_to "Favorite", comment_favorites_path(comment), method: :post, remote: true, class: 'btn btn-xs btn-default' %>
<% end %>
This application does not collect or publish any personal information.
@yohfee
yohfee / chef_solo_bootstrap.sh
Created August 7, 2012 01:30
Ubuntu 12.04 & Ruby 1.9.3-p194 & Chef
#!/usr/bin/env bash
apt-get -y update
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev
cd /tmp
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.gz
tar -xvzf ruby-1.9.3-p194.tar.gz
cd ruby-1.9.3-p194/
./configure --prefix=/usr/local
make
make install
@yohfee
yohfee / gist:2723330
Created May 18, 2012 05:25
Can I use local Gemfile?
echo "eval File.read('Gemfile')\ngem 'pry'" > Gemfile.local
echo "Gemfile.local\nGemfile.local.lock" >> .git/info/exclude
bundle install --gemfile Gemfile.local
BUNDLE_GEMFILE=Gemfile.local bundle list
@yohfee
yohfee / who.rb
Created February 23, 2012 09:43
コイツ誰?って思ったとき用のearthquake.gemプラグイン(要libnotify)
#coding: utf-8
begin
require 'libnotify'
require 'tempfile'
require 'open-uri'
Earthquake.init do
help :who, 'show user name and icon', <<-HELP
⚡ :who yohfee
@yohfee
yohfee / 51-android.rules
Created January 24, 2012 07:45
Ubuntuでadb devicesで端末が???になるのを回避する
# Sharp
SUBSYSTEM=="usb", ATTR{idVendor}=="04dd", MODE="0666", GROUP="plugdev"
# Sony Ericsson
SUBSYSTEM=="usb", ATTR{idVendor}=="0fce", MODE="0666", GROUP="plugdev"
@yohfee
yohfee / source.rb
Created November 15, 2011 09:03
earthquakegemでhelpが悲しいのでだったらソース見ちゃえ的なやっつけ仕事
require 'method_source'
Earthquake.init do
command :source do |m|
puts commands.detect{|c| m[1] =~ c[:pattern]}[:block].source
end
end
@yohfee
yohfee / pocky.rb
Created November 11, 2011 02:05
Have a nice pocky day!!
Earthquake.init do
command :pocky do |m|
sleep 0.5 until [:month, :day, :hour, :min, :sec].all?{|t| Time.now.send(t) == 11}
twitter.update m[1]
end
end