Skip to content

Instantly share code, notes, and snippets.

View doitian's full-sized avatar
🎯
Focusing

ian doitian

🎯
Focusing
View GitHub Profile
@doitian
doitian / pidof
Created February 15, 2011 17:31
pidof script for Mac OS X
#!/usr/bin/env ruby
target = ARGV[0] || ""
ids = []
`ps axc`.each do |line|
pid, tt, stat, time, command = line.chomp.split(" ", 5)
if target == command
ids << pid
end
end
@doitian
doitian / org-agenda-3-days-view.el
Created June 1, 2011 19:01
3 days view in org agenda (yesterday, today and tomorrow)
(defun org-agenda-3-days-view (&optional day-of-year)
"Switch to 3-days (yesterday, today, tomorrow) view for agenda."
(interactive "P")
(org-agenda-check-type t 'agenda)
(if (and (not day-of-year) (equal org-agenda-current-span 3))
(error "Viewing span is already \"%s\"" 3))
(let* ((sd (or day-of-year
(org-get-at-bol 'day)
(time-to-days (current-time))))
(sd (and sd (1- sd)))
@doitian
doitian / xmonad.hs
Created June 10, 2011 16:24
xmonad.hs
{-# OPTIONS_GHC -fcontext-stack=32 #-}
import XMonad hiding ( (|||) )
import qualified XMonad.StackSet as W
import Control.OldException(catchDyn,try)
import Data.Char (toLower)
import Data.List (intercalate, intersperse, isSuffixOf, isPrefixOf)
import qualified Data.Map as M (fromList)
@doitian
doitian / .vimrc
Last active October 2, 2017 06:43
if v:progname =~? "evim"
finish
endif
set nocompatible
scriptencoding utf-8
set encoding=utf-8
let loaded_matchparen = 1
let has_ag = executable('ag')
@doitian
doitian / README.md
Created August 23, 2011 16:54
Fix JRuby ffi/enum load error in Rails

To fix the ffi/enum load error, just prepend a directory at the beginning of load path $: and create file ffi/enum.rb in that directory (lib/hotfixists in the example)

(set-frame-font "Inconsolata:pixelsize=18")
(set-fontset-font "fontset-default" 'chinese-gbk "WenQuanYi Micro Hei Mono:pixelsize=18")
(set-frame-font "Inconsolata:pixelsize=18")
(set-fontset-font "fontset-default" 'chinese-gbk "WenQuanYi Micro Hei Mono:pixelsize=18")
;; 1. Quote the string
;; 2. If we didn't input any typically regexp characters, convert spaces to .*,
;; however, it is still order related.
(defun anything-pattern-to-regexp (string)
(prin1-to-string
(if (string-match-p "[\\[\\]*+$^]" string) string
(let ((parts (split-string string "[ \t]+" t)))
(if (eq 2 (length parts))
;; for two parts a,b we make a.*b\|b.*a
(concat
bundled_commands=(cap capify cucumber foreman guard heroku nanoc3 rackup rails rainbows rake rspec ruby shotgun spec spork thin unicorn unicorn_rails)
_bundler-installed() {
which bundle > /dev/null 2>&1
}
_within-bundled-project() {
local check_dir=$PWD
while [ "$(dirname $check_dir)" != "/" ]; do
[ -f "$check_dir/Gemfile" ] && return
\documentclass[12pt]{article}
\usepackage{color}
\usepackage{xcolor}
\usepackage{textcomp}
\usepackage{listings}
\definecolor{solarized@base03}{HTML}{002B36}
\definecolor{solarized@base02}{HTML}{073642}
\definecolor{solarized@base01}{HTML}{586e75}