Skip to content

Instantly share code, notes, and snippets.

@nog
nog / template.rb
Created March 27, 2009 09:24
nog rails application template
#ぼくが考えた最強のれいるずてんぷれーと!
# Copy database.yml
run "cp config/database.yml config/database.sample.yml"
# Delete unnecessary files
run "rm README"
run "rm public/index.html"
#git
git :init
@banyan
banyan / gen.sh
Created October 10, 2011 04:24 — forked from kennyj/gen.sh
backbone.jsが利用できる状態でrailsプロジェクト生成 (rails3.1版 + MySQL)
#!/bin/sh
# 'capybara-webkit' の依存性のため、qt をインストールする必要がある
# $ brew install qt
# railsプロジェクト作成して移動する
rails new "$1" --skip-test-unit --database=mysql
cd "$1"
# Gemfileに必要なgemを追記する
cat << HERE >> Gemfile
@nanki
nanki / findup.rb
Created November 10, 2011 14:06
find a file upward.
#!/usr/bin/env ruby
require 'pathname'
pattern = ARGV.shift
dir = ARGV.shift || Dir.pwd
Pathname(dir).expand_path.ascend{|d| puts Dir.glob(d + pattern)}
@ser1zw
ser1zw / _tmuxinator
Created March 29, 2012 19:43
zsh completion for tmuxinator
#compdef tmuxinator mux
# zsh completion for tmuxinator
# Install:
# $ mkdir -p ~/.tmuxinator/completion
# $ cp _tmuxinator ~/.tmuxinator/completion
# $ vi ~/.zshrc # add the following codes
# fpath=($HOME/.tmuxinator/completion ${fpath})
# autoload -U compinit
@rchampourlier
rchampourlier / google_bot_aware.rb
Created May 3, 2012 22:32
Rack middleware to make Rails deal correctly with GoogleBot's '*/*;q=0.6' Accept header
# This Rack middleware helps solving the issue with some Rails versions which do not accept
# a '*/*;q=0.6' and their variants 'Accept' request header. This header is particularly used
# by Google Bot, and if Rails doesn't like it, it will return a 500 or 406 error to Google Bot,
# which is not the best way to get your pages indexed.
#
# References:
# - http://stackoverflow.com/questions/8881756/googlebot-receiving-missing-template-error-for-an-existing-template
# - https://github.com/rails/rails/issues/4127
#
class GoogleBotAware
@mattn
mattn / dash.vim
Last active December 13, 2015 21:09
function! s:dash(...)
let word = len(a:000) == 0 ? input('Dash search: ') : a:1
call system(printf("open dash://'%s'", word))
endfunction
command! -nargs=? Dash call <SID>dash(<f-args>)
#!/usr/bin/env ruby
require 'rubygems'
require 'net/http'
require 'string-irc'
channels = %w( #test )
status_file = '/tmp/.ghe-overload'
pcpu_threshold = 80
@BenConstable
BenConstable / db-size.sql
Last active December 16, 2015 12:18
Little MySQL query to find the size of database.
# Adapted from http://stackoverflow.com/questions/1733507/how-to-get-size-of-mysql-database
SELECT Round(Sum(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB"
FROM information_schema.tables
WHERE table_schema = "database_name" # Replace this with the name of the database you want to inspect
GROUP BY table_schema;
#!/usr/bin/env ruby
require 'rubygems'
require "active_support/inflector"
require "optparse"
class Rsub
@PDXIII
PDXIII / Nice Button Effect
Last active April 13, 2023 19:33
Less mixin for a nice button effect. see it in action http://pdxiii.github.io/JimmyStash
// see it in action http://pdxiii.github.io/JimmyStash
.buttonFX (@color) {
color: darken(@color, 30%);
border-top: solid 2px lighten(@color, 10%);
border-left: solid 2px lighten(@color, 10%);
border-right: solid 2px darken(@color, 10%);
border-bottom: solid 2px darken(@color, 10%);
background-color: @color;
box-shadow: inset 10px 10px 10px lighten(@color, 15%),