Skip to content

Instantly share code, notes, and snippets.

View nalabjp's full-sized avatar
☀️
🌴

nalabjp nalabjp

☀️
🌴
View GitHub Profile
#!/usr/bin/env ruby
class AlreadyExistsStone < StandardError; end
def init_board(num = 19)
@board = Array.new(num){ Array.new(num) }
end
def init_narabe(num = 5)
@narabe = num
@nalabjp
nalabjp / Gemfile
Created October 10, 2015 10:16
Default Gemfile for gem
source 'https://rubygems.org'
group :development, :test do
gem 'pry'
gem 'pry-doc'
gem 'pry-byebug'
gem 'pry-power_assert'
end
group :test do
@nalabjp
nalabjp / full_error_messages.rb
Last active September 21, 2015 08:32 — forked from pehrlich/full_error_messages.rb
Print out full error messages for nested models
module FullErrorMessages
extend ActiveSupport::Concern
# includes errors on this model as well as any nested models
def all_error_messages
messages = self.errors.messages.dup
messages.each do |column, errors|
if self.respond_to?(:"#{column}_attributes=") && (resource = self.send(column))
messages[column] = resource.errors.messages
end
@nalabjp
nalabjp / git_rename_committer.sh
Last active August 29, 2015 14:27
Rename author name and committer name of git log
git filter-branch --commit-filter '
if [ "$GIT_AUTHOR_NAME" = "Hajime Kimura" ];
then
GIT_AUTHOR_NAME="nalabjp";
GIT_AUTHOR_EMAIL="nalabjp@gmail.com";
GIT_COMMITTER_NAME="nalabjp";
GIT_COMMITTER_EMAIL="nalabjp@gmail.com";
git commit-tree "$@";
else
git commit-tree "$@";
@nalabjp
nalabjp / deploy.rake
Last active August 29, 2015 14:19 — forked from jphenow/deploy.rake
Deploy and rollback on Heroku in staging and production
#Deploy and rollback on Heroku in staging and production
%w(staging production).each do |app|
desc "Deploy to #{app}"
task "deploy:#{app}" => %W(deploy:set_#{app}_app deploy:push deploy:env deploy:restart deploy:tag app:logs)
desc "Deploy #{app} with migrations"
task "deploy:#{app}:migrations" => %W(deploy:set_#{app}_app deploy:push deploy:off deploy:migrate deploy:env deploy:restart deploy:on deploy:tag app:logs)
desc "Rollback #{app}"
@nalabjp
nalabjp / ridgepole.rake
Last active August 29, 2015 14:19
Rake Task for Ridgepole
$stdout.sync = true
DB_CONFIG = 'config/database.yml'
SCHEMA_FILE = 'db/Schemafile'
SCHEMA_DUMP_FILE = "#{SCHEMA_FILE}.dump"
OPT_ENV = "--env #{Rails.env}"
OPT_CONFIG = "--config #{DB_CONFIG}"
OPT_FILE = "--file #{SCHEMA_FILE}"
OPT_MYSQL_AWESOME = '--enable-mysql-awesome --mysql-awesome-unsigned-pk'
OPT_APPLY = '--apply'
@nalabjp
nalabjp / rails_helper.rb
Created March 24, 2015 16:54
rspec-rails + test-queue + simplecov
if ENV['COVERAGE']
require 'simplecov'
require 'simplecov-rcov'
SimpleCov.merge_timeout 3600
SimpleCov.formatters = [
SimpleCov::Formatter::HTMLFormatter,
SimpleCov::Formatter::RcovFormatter
]
SimpleCov.start 'rails'
end
@nalabjp
nalabjp / gitlab.coffee
Last active August 29, 2015 14:06
gitlab.coffee
# Description:
# Post gitlab related events using gitlab hooks
#
# Dependencies:
# "url" : ""
# "querystring" : ""
#
# Configuration:
# GITLAB_CHANNEL
# GITLAB_DEBUG
@nalabjp
nalabjp / private.xml
Last active August 29, 2015 14:06
Karabiner for Slack (~/Library/Application\ Support/Karabiner)
<?xml version="1.0"?>
<root>
<appdef>
<appname>SLACK</appname>
<equal>com.tinyspeck.slackmacgap</equal>
</appdef>
<item>
<name>For Slack CTRL+N=move next channel, CTRL+P=move previous channel, ALT+A=move unread channel</name>
<identifier>private.app_slack_move_channel_with_ctrln_ctrlp</identifier>
<only>SLACK</only>
#!/bin/sh
[ -f /opt/boxen ] && rm -fr /opt/boxen
sudo rm -fr /opt/boxen
sudo mkdir -p /opt/boxen
sudo chown $USER:admin /opt/boxen
git clone https://github.com/nalabjp/our-boxen /opt/boxen/repo
/opt/boxen/repo/script/boxen --no-fde
echo '# boxen' >> ~/.bash_profile
echo '[ -f /opt/boxen/env.sh ] && source /opt/boxen/env.sh' >> ~/.bash_profile