Skip to content

Instantly share code, notes, and snippets.

@bootleq
bootleq / quickrun-as-sql-client.vim
Created June 12, 2015 08:30
Use vim-quickrun as SQL client
" First, install thinca/vim-quickrun
"
" https://github.com/thinca/vim-quickrun
"
" Then write some vimrc:
"
@bootleq
bootleq / .zshrc
Created September 1, 2014 02:59
zsh function to restart Rails server (only support nginx server with passenger or unicorn_rails)
rtouch() {
emulate -L zsh
if [[ -d tmp ]]; then
if which passenger 2>&1 >/dev/null; then
touch tmp/restart.txt && echo 'file touched.'
elif which unicorn_rails 2>&1 >/dev/null; then
if [[ -r tmp/pids/unicorn.pid && -n $(ps h -p `cat tmp/pids/unicorn.pid` | tr -d ' ') ]]; then
kill -USR2 $(cat tmp/pids/unicorn.pid) && echo "process killed."
elif [[ -f config/unicorn.rb ]] && [[ -n $RAILS_ENV ]]; then
bundle exec unicorn_rails -D -E $RAILS_ENV -c config/unicorn.rb && echo "process started."
module ActionController
class Metal
attr_internal :cached_content_for
end
module Caching
module Actions
def _save_fragment(name, options)
return unless caching_allowed?
@bootleq
bootleq / .gitconfig
Created April 4, 2014 08:31
Currently in use messy ~/.gitconfig
[user]
name = bootleq
email = bootleq@gmail.com
[color]
ui = auto
; [help]
; format = web
@bootleq
bootleq / .zshrc
Created March 5, 2014 09:31
Currently in use messy zshrc
# References:
# GRML - https://github.com/grml/grml-etc-core
# zsh-users - https://github.com/zsh-users
[[ $ZDOTDIR == '' ]] && export ZDOTDIR=$HOME
if [[ $ZDOTDIR == '/etc/users/bootleq' && -f $ZDOTDIR/.vimrc ]]; then
alias vim="vim -u $ZDOTDIR/.vimrc"
fi
set all&
set nocompatible
set runtimepath=
set rtp+=~/repository/delimitMate/
set backspace=indent,eol,start
let delimitMate_expand_cr = 1
@bootleq
bootleq / a-unite.vim
Created August 26, 2013 08:16
Test example for unite-session `save` function.
let SessionLoad = 1
if &cp | set nocp | endif
let s:so_save = &so | let s:siso_save = &siso | set so=0 siso=0
let v:this_session=expand("<sfile>:p")
silent only
cd ~/repository/dotfiles/vim-test
if expand('%') == '' && !&modified && line('$') <= 1 && getline(1) == ''
let s:wipebuf = bufnr('%')
endif
set shortmess=aoO
@bootleq
bootleq / .zshrc
Created May 19, 2013 07:57
zsh alias for ag
() {
# TODO --hidden
local common='noglob ag --nobreak --nogroup --noheading --smart-case --depth=27'
local colors='--color-path 35 --color-line-number 32 --color-match "1;31"'
alias ag=$common' '$colors
alias agjs=$common' '$colors' -G public/javascripts/.*-(debug|src).js'
}
@bootleq
bootleq / moedict-tw.xml
Created April 28, 2013 15:28
萌典 OpenSearch plugin
<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"
xmlns:moz="http://www.mozilla.org/2006/browser/search/">
<ShortName>萌典</ShortName>
<Description>教育部國語詞典(民間線上版)</Description>
<InputEncoding>UTF-8</InputEncoding>
<Image width="16" height="16" type="image/x-icon">https://www.moedict.tw/favicon.ico</Image>
<Url type="text/html" method="GET" template="https://www.moedict.tw/#{searchTerms}"></Url>
</OpenSearchDescription>
#!/usr/bin/env ruby
require 'rubygems'
require 'redis'
require 'active_support/core_ext/hash'
require 'optparse'
require 'yaml'
require 'pp'
options = {}.with_indifferent_access