Skip to content

Instantly share code, notes, and snippets.

@flaneur2020
flaneur2020 / .vimrc
Created November 14, 2010 11:07
my .vimrc
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin
syntax on
filetype plugin on
"about tab
set autoindent
@flaneur2020
flaneur2020 / readsector.s
Created January 30, 2011 03:39
read_sector
; from http://www.mouseos.com/arch/processor_mode.html
;----------------------------------------------------------------------
;
; read_sector(int sector, char *buf) - read one floppy sector(LBA mode)
; input: di - sector
; si - buf
;----------------------------------------------------------------------
read_sector:
@flaneur2020
flaneur2020 / echo.c
Created April 14, 2011 11:17
simple echo server
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
//
/* author: Dutor
* from : http://www.dutor.net/index.php/2011/04/recursive-iterative-quick-sort/ */
int
partition(int *a, int n) //~ seperate a[], using a[0] as pivot
{
int l = 0, r = n;
int pivot = a[l];
while(l < r)
{
@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)
@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 / 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 / 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 / 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 / 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: 切换用户