Skip to content

Instantly share code, notes, and snippets.

@flaneur2020
flaneur2020 / gist:3080709
Created July 10, 2012 03:03
Rakefile for book generator
# author: arcturo
# from https://github.com/arcturo/library/blob/master/coffeescript/Rakefile
require "rdiscount"
require "mustache"
require "active_support/core_ext/string"
require "fileutils"
def generate(page, template = "site/page.ms")
Mustache.render(
@flaneur2020
flaneur2020 / snippets.md
Created March 9, 2012 08:42
snippets for lifestyle.

jquery

parents()方法很好用,配合first()可以省掉一大串难于维护的.parent()

$('.some_class').parents('form').first()

git

clear the ignored files which has already been tracked:

@flaneur2020
flaneur2020 / Gemfile
Created February 8, 2012 02:27
less painful web prototyping with sinatra, slim, sass, and coffeescript
source 'http://ruby.taobao.org'
gem 'sinatra'
gem 'sinatra-reloader'
gem 'slim'
gem 'sass'
gem 'coffee-script'
gem 'compass'
gem 'pry'
<!DOCTYPE html>
<html>
<head>
<style>
@import url(css/reset.css);
@import url(css/style.css);
</style>
<script src="js/script.js"></script>
</head>
<body>
@flaneur2020
flaneur2020 / shell_tips.md
Created January 14, 2012 11:32
shell tips
  • gcc -M hello.c 可以得到某文件依赖的头文件。

  • grep processor /proc/cpu_info 显示当前的CPU数目

  • sudo shutdown -r now 重启机器

  • sshfs yourname@host:/path/to/your/dir ~/local sshfs挂载到本地

  • sudo -u fleuria bash: 切换用户

@flaneur2020
flaneur2020 / rails_note.md
Created January 13, 2012 12:39
notes on setting up the rails stack

rvm

before rvm install 1.9.2, make sure

sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion nodejs

rvm requirements可以列出依赖的软件。

Passenger

@flaneur2020
flaneur2020 / vector.c
Created January 11, 2012 10:54
vector in c
#include <assert.h>
#include "inc/vector.h"
struct ir_vector* iv_new(size_t entry_size, size_t default_max_count) {
struct ir_vector *iv;
assert(entry_size > 0);
iv = (struct ir_vector*)malloc(sizeof(struct ir_vector));
iv->count = 0;
iv->entry_size = entry_size;
@flaneur2020
flaneur2020 / gist:1564910
Created January 5, 2012 11:37
authlogic i18n
zh-CN:
authlogic:
error_messages:
login_blank: '不能为空'
login_not_found: '未找到用户'
login_invalid: '用户不正确'
consecutive_failed_logins_limit_exceeded: Consecutive failed logins limit exceeded, account is disabled.
email_invalid: "格式不正确"
password_blank: can not be blank
password_invalid: is not valid
@flaneur2020
flaneur2020 / gist:1308227
Created October 24, 2011 02:07
.bash_profile
function parse_git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
NO_COLOUR="\[\033[0m\]"
PS1="$GREEN\u@machine$NO_COLOUR:\w$YELLOW\$(parse_git_branch)$NO_COLOUR\$ "
@flaneur2020
flaneur2020 / bstree.hs
Created June 7, 2011 09:00
binary search tree
module BTree where
data BTree a b = Empty
| BNode {
kv :: (a, b),
left :: BTree a b,
right :: BTree a b
}
deriving(Show, Eq)