Skip to content

Instantly share code, notes, and snippets.

View sundevilyang's full-sized avatar
😃

Yang Wen sundevilyang

😃
  • ByteDance
  • Beijing
View GitHub Profile
@sundevilyang
sundevilyang / zh-CN.yml
Last active July 7, 2016 15:14
rails.zh-CN.yml
---
zh-CN:
activerecord:
errors:
messages:
record_invalid: "验证失败: %{errors}"
restrict_dependent_destroy:
has_one: 由于 %{record} 需要此记录,所以无法移除记录
has_many: 由于 %{record} 需要此记录,所以无法移除记录
date:
@sundevilyang
sundevilyang / index.md
Last active August 29, 2015 14:13 — forked from rstacruz/index.md

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

规范:
1、标点符号使用全角
2、保留原文中一切标记如<span>,只翻译文字部分
3、必要时在括号中引用原文术语,如"方法(methods)"
字典:
calling: 调用
introduction: 介绍
object, objects: 对象
primer: 初学者
规范:
1、标点符号使用全角
2、保留原文中一切标记如<span>,只翻译文字部分
3、必要时在括号中引用原文术语,如"方法(methods)"
字典:
calling: 调用
introduction: 介绍
object, objects: 对象
primer: 初学者

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
# == Active Model North American Telephone Number Validator
# http://en.wikipedia.org/wiki/North_American_Numbering_Plan#Current_system
# [Author] Roger Rohrbach (roger@ecstatic.com)
class NanpValidator < ActiveModel::EachValidator
def self.matcher(require_area_code) # :nodoc:
%r{
(?<country_code> \+1 ){0}
(?<trunk_prefix> 1 ){0}
(?<delimiter> ([-\.]|\ +) ){0}
# MySQL. Versions 4.1 and 5.0 are recommended.
#
# Install the MySQL driver:
# gem install mysql2
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
adapter: mysql2
encoding: utf8
# PostgreSQL. Versions 7.4 and 8.x are supported.
#
# Install the pg driver:
# gem install pg
# On Mac OS X with macports:
# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
# On Windows:
# gem install pg
# Choose the win32 build.
# Install PostgreSQL and put its /bin directory on your path.
require 'rubygems'
require 'chinese_pinyin'
name = []
cp = false
def p(z)
Pinyin.t(z, '')
end
@sundevilyang
sundevilyang / tmux latest
Created November 5, 2012 11:47 — forked from jespada/tmux latest
tmux
set -g prefix C-a
unbind %
bind | split-window -h
bind - split-window -v
bind-key k select-pane -U
bind-key j select-pane -D
bind-key h select-pane -L
bind-key l select-pane -R
# status bar