Skip to content

Instantly share code, notes, and snippets.

View linyows's full-sized avatar

Tomohisa Oda linyows

View GitHub Profile
shared_context "for_extending" do
context "extended with MyModule" do
before(:all){ subject.extend(MyModule) }
it "should define #some_method" do
subject.should respond_to(:some_method)
end
yield
end
end
@linyows
linyows / create_snapshot.rb
Last active December 17, 2015 17:18
Create snapshot of volume on AWS
#!/usr/bin/env ruby
# README
#
# Create snapshot
# ===============
#
# Create snapshot of volume. and generation management.
#
# Usage
@linyows
linyows / generate_hosts.rb
Last active December 17, 2015 13:38
Generate the Hosts Dynamically on AWS
#!/usr/bin/env ruby
# README
#
# Generate the Hosts Dynamically
# ==============================
#
# Usage
# -----
#

Vagrant Setup

This tutorial guides you through creating your first Vagrant project.

We start with a generic Ubuntu VM, and use the Chef provisioning tool to:

  • install packages for vim, git
  • create user accounts, as specified in included JSON config files
  • install specified user dotfiles (.bashrc, .vimrc, etc) from a git repository

Afterwards, we'll see how easy it is to package our newly provisioned VM

# -*- mode: ruby -*-
# vi: set ft=ruby :
# David Lutz's Multi VM Vagrantfile
# inspired from Mark Barger's https://gist.github.com/2404910
boxes = [
{ :name => :web, :role => 'web_dev', :ip => '192.168.33.1', :ssh_port => 2201, :http_fwd => 9980, :cpus =>4, :shares => true },
{ :name => :data, :role => 'data_dev', :ip => '192.168.33.2', :ssh_port => 2202, :mysql_fwd => 9936, :cpus =>4 },
{ :name => :railsapp, :role => 'railsapp_dev', :ip => '192.168.33.3', :ssh_port => 2203, :http_fwd => 9990, :cpus =>1}
]
// ==UserScript==
// @name github-build-badge
// @author linyows
// @namespace http://linyows.com/
// @description "Expand build status badge"
// @include https://github.com/*
// ==/UserScript==
(function() {
var match_witch_badge = /<a href="(http:\/\/ci[0-9]{0,3}\..*\.[a-z]{2,5}\/job\/.*)"><img src=".*" alt="Build Status" data-canonical-src=".*" style=".*"><\/a>/g;
class ApplicationController < ActionController::Base
...
# FORCE to implement content_for in controller
def view_context
super.tap do |view|
(@_content_for || {}).each do |name,content|
view.content_for name, content
end
end
end
# 2. Include Sweeping module in your controller(s) to have cache_sweeper
# method to be avaliable, or right in ApplicationController so it will be
# available in all controllers inheriting from it.
class ApplicationController < ActionController::Base
include ActionController::Caching::Sweeping
# ...
end
#!/usr/bin/env ruby
remote = `git remote -v | grep origin | awk '{print $2}'`.
split("\n").first.chomp.
sub(/.*:(.*)/, '\1').sub(/\.git/, '')
log = `git log --after=yesterday --author='linyows'`
#log = `git log --author='linyows'`
commits = {}
count = 0
var startDate = new Date(2012, 8-1, 31);
var endDate = new Date(2012, 8-1, 31);
if (startDate.getTime() <= nowDate.getTime() && nowDate.getTime() < endDate.getTime()) {
}