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
@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 / 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-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

Simple Starting Point

创建 Model

var Person = Backbone.Model.extend();
@sandyxu
sandyxu / .gitignore
Created November 14, 2013 10:03
git ignore file
# See http://help.github.com/ignore-files/ for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile ~/.gitignore_global
# Ignore bundler config
/.bundle
# Ignore the default SQLite database.
@sandyxu
sandyxu / app_store_receipt.txt
Last active December 30, 2015 05:39 — forked from sauloarruda/receipt
Verify in-app payment data on App store & Android market
ewoJInNpZ25hdHVyZSIgPSAiQXBNVUJDODZBbHpOaWtWNVl0clpBTWlKUWJLOEVk
ZVhrNjNrV0JBWHpsQzhkWEd1anE0N1puSVlLb0ZFMW9OL0ZTOGNYbEZmcDlZWHQ5
aU1CZEwyNTBsUlJtaU5HYnloaXRyeVlWQVFvcmkzMlc5YVIwVDhML2FZVkJkZlcr
T3kvUXlQWkVtb05LeGhudDJXTlNVRG9VaFo4Wis0cFA3MHBlNWtVUWxiZElWaEFB
QURWekNDQTFNd2dnSTdvQU1DQVFJQ0NHVVVrVTNaV0FTMU1BMEdDU3FHU0liM0RR
RUJCUVVBTUg4eEN6QUpCZ05WQkFZVEFsVlRNUk13RVFZRFZRUUtEQXBCY0hCc1pT
QkpibU11TVNZd0pBWURWUVFMREIxQmNIQnNaU0JEWlhKMGFXWnBZMkYwYVc5dUlF
RjFkR2h2Y21sMGVURXpNREVHQTFVRUF3d3FRWEJ3YkdVZ2FWUjFibVZ6SUZOMGIz
SmxJRU5sY25ScFptbGpZWFJwYjI0Z1FYVjBhRzl5YVhSNU1CNFhEVEE1TURZeE5U
SXlNRFUxTmxvWERURTBNRFl4TkRJeU1EVTFObG93WkRFak1DRUdBMVVFQXd3YVVI
@sandyxu
sandyxu / workers.rake
Created February 19, 2014 04:39 — forked from karmi/workers.rake
# Rake task to launch multiple Resque workers in development/production with simple management included
require 'resque/tasks' # Require Resque tasks
namespace :workers do
# = $ rake workers:start
#
# Launch multiple Resque workers with the Rails environment loaded,
# so they have access to your models, etc.
@sandyxu
sandyxu / sort.rb
Created July 22, 2014 03:47
经典排序算法资料及 ruby 实现
class Array
# 插入排序
def insert_sort!
(0...self.length).to_a.each do |j|
key = self[j]
i = j - 1;
while i >= 0 and self[i] > key
self[i+1] = self[i]
i = i-1
end
@sandyxu
sandyxu / git-description.md
Last active August 29, 2015 14:04
git command description

Git 安装与初始化

Linux

如果你用的是Linux,你可以用你的本地包管理系统(native package management system)来安装.

$ yum install git-core  #译者注,在redhat等系统下用yum

$ apt-get install git-core #译者注,在debian, ubuntu等系统下用apt-get
@sandyxu
sandyxu / scan_chinese.rb
Created August 8, 2014 10:29
找出指定路径下文件中包含中文的行
# encoding: utf-8
class ScanChinese
def self.scan(file)
if File.directory?(file)
files = (Dir.entries(file) - %w( . .. ))
dir = files.map{|name| File.join(file, name)}
dir.each do |filename|
if File.directory?(filename)
scan(filename)
else