Skip to content

Instantly share code, notes, and snippets.

View sandyxu's full-sized avatar
Working from office

Sandy Xu sandyxu

Working from office
  • Shanghai, China
View GitHub Profile

Simple Starting Point

创建 Model

var Person = Backbone.Model.extend();
@sandyxu
sandyxu / brew-install-postgresql
Created August 23, 2013 09:57
PostgreSql install & init & star
$brew doctor
$brew install postgreSql
#初始化数据库
$ initdb /usr/local/var/postgres -E utf8
#Success. You can now start the database server using:
# postgres -D /usr/local/var/postgres
#or
# pg_ctl -D /usr/local/var/postgres -l logfile start
@sandyxu
sandyxu / vim-current-line-move
Created August 23, 2013 09:53
vim current line move
zz - move current line to the middle of the screen
zt - move current line to the top of the screen
zb - move current line to the bottom of the screen
Ctrl-e Moves screen up one line
Ctrl-y Moves screen down one line
Ctrl-u Moves screen up ½ page
Ctrl-d Moves screen down ½ page
Ctrl-b Moves screen up one page
Ctrl-f Moves screen down one page
@sandyxu
sandyxu / brew-install-mysql
Last active September 7, 2018 16:14
brew install mysql & my.cnf & init database & start mysql & change root password & uninstall & show character & some solution s
1. brew安装mysql
$ brew install mysql
2. 创建或修改/usr/local/etc/my.cnf
https://gist.github.com/sandyxu/6317492
3. 初始化 init database
$ unset TMPDIR
$ mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
@sandyxu
sandyxu / my.cnf
Created August 23, 2013 09:46
mysql config file /usr/local/etc/my.cnf
[client]
port = 3306
socket = /tmp/mysql.sock
default-character-set = utf8
[mysqld]
collation-server = utf8_unicode_ci
character-set-server = utf8
init-connect ='SET NAMES utf8'
max_allowed_packet = 64M
@sandyxu
sandyxu / time-format-string
Created August 23, 2013 09:29
strftime方法中可用的 ISO 8601 格式化符号
%a 星期的缩写,如Wed
%A 星期的全称,如Wednesday
%U 本星期在全年中所属的周数
%W
%H 小时(24小时制)
%M 分钟
%S 秒
%I 小时(12小时制)
%p PM 或 AM
%b 月份的缩写,如 Jan
@sandyxu
sandyxu / models-should-be-organized-format.rb
Created August 23, 2013 09:25
All models should be organized using the following format
# All models should be organized using the following format.
class MyModel < ActiveRecord::Base
# extends ...
# includes ..
# security (i.e. attr_accessible) ......
# relationships ....
# validations ..
# callbacks
# scopes
# additional config
@sandyxu
sandyxu / brew-uninstall.sh
Created August 23, 2013 09:21
brew uninstall
cd `brew --prefix`
rm -rf Cellar
brew prune
rm `git ls-files`
rm -r Library/Homebrew Library/Aliases Library/Formula Library/Contributions
rm -rf .git
rm -rf ~/Library/Caches/Homebrew
@sandyxu
sandyxu / .gitconfig
Last active December 21, 2015 14:09
gitconfig
[user]
name = sandyxu
email = [email protected]
[core]
quotepath = false
[color]
interactive = auto
diff = auto
status = auto
branch = auto
@sandyxu
sandyxu / git-diary.txt
Last active December 21, 2015 14:08
git, skills, expertise, config, autocomplete command
# git 命令自动提示 blog:
http://code-worrier.com/blog/autocomplete-git/
# 安装git命令自动提示后很爽,但是删除后的branch由于缓存,仍然提示出来,导致提示过多且混乱。通过查看
$ git remote show origin
* remote origin
Fetch URL: [email protected]/sandyxu/xx.git
Push URL: [email protected]/sandyxu/xx.git
HEAD branch (remote HEAD is ambiguous, may be one of the following):
master
next