Skip to content

Instantly share code, notes, and snippets.

@fancyoung
fancyoung / color2code.js
Created March 26, 2011 10:23
do a simple trans
var color2code = {
"aliceblue":"#F0F8FF",
"antiquewhite":"#FAEBD7",
"aqua":"#00FFFF",
"aquamarine":"#7FFFD4",
"azure":"#F0FFFF",
"beige":"#F5F5DC",
"bisque":"#FFE4C4",
"black":"#000000",
"blanchedalmond":"#FFEBCD",
@fancyoung
fancyoung / checkmobile.js
Created April 5, 2011 08:18
javascript to check whether on mobile
function checkMobile(){
return (/ucweb|mobile|android|avantgo|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50
@fancyoung
fancyoung / .Xmodmap
Created May 11, 2011 08:11
key mapping(~/.Xmodmap)
keysym Pause = Insert Insert
remove Lock = Caps_Lock
@fancyoung
fancyoung / .xinitrc
Created May 11, 2011 08:14
config for awesome(~/.xinitrc > ~/.Xsession: $ ln -s ~/.xinitrc ~/.xsession)
gnome-settings-daemon &
gnome-volume-manager &
gnome-power-manager &
nm-applet &
update-notifier &
mongod --dbpath /var/lib/mongodb/ &
exec awesome
@fancyoung
fancyoung / rc.lua
Created May 11, 2011 08:17
config for awesome(~/.config/awesome/rc.lua)
autorun = true
autorunApps =
{
"google-chrome",
"LC_CTYPE=zh_CN.utf8 emacs",
"empathy",
terminal,
}
if autorun then
for app = 1, #autorunApps do
@fancyoung
fancyoung / .gitconfig
Last active September 26, 2015 08:38
git config file(~/.gitconfig) git配置文件
[core]
editor = vi
[user]
name = yourname
email = youremail@gmail.com
[alias]
co = checkout
st = status
br = branch
ci = commit
@fancyoung
fancyoung / .Xresources
Created October 10, 2011 03:13
config xterm in .Xresources(xterm配置,解决某些快捷键不能用,中文乱码,配色)。After config, run $ xrdb ~/.Xresources
xterm*metaSendsEscape: true
XTerm*fontMenu*fontdefault*Label: Default
XTerm*faceName: Bitstream Vera Sans Mono Roman
XTerm*faceNameDoublesize: WenQuanYi Bitmap Song
XTerm*faceSize: 10
XTerm*cjkWidth: true
XTerm*mkWidth: true
XTerm*jumpScroll: true
XTerm*SaveLines: 10000
@fancyoung
fancyoung / ToHaml
Created October 27, 2011 07:01
move all .erb file to .haml
class ToHaml
def initialize(path)
@path = path
end
def convert!
Dir["#{@path}/**/*.erb"].each do |file|
`html2haml -rx #{file} #{file.gsub(/\.erb$/, '.haml')}`
`rm #{file}`
end
@fancyoung
fancyoung / html.html
Created October 28, 2011 02:08
HTML template
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>HTML template</title>
<link href="http://blueprintcss.org/blueprint/screen.css" rel="stylesheet" type="text/css" />
<style type="text/css">
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.js" type="text/javascript"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.js" type="text/javascript"></script>
@fancyoung
fancyoung / git-cheat-sheet.md
Last active November 25, 2015 10:22
Git & Hg 常见操作(已迁到blog)

git

对比stage的文件 $ git diff --cached

修改最后一次提交 $ git commit --amend

取消上一次的提交(未push前) $ git reset --soft HEAD^