Skip to content

Instantly share code, notes, and snippets.

View nightire's full-sized avatar
Looking for new opportunities

余凡 nightire

Looking for new opportunities
View GitHub Profile
@nightire
nightire / application.controller.js
Last active December 9, 2015 07:20
echarts-demo
import Ember from 'ember';
const optionA = {
title : {
text: '未来一周气温变化',
subtext: '纯属虚构'
},
tooltip : {
trigger: 'axis'
},
@nightire
nightire / year_to_chinese_era.md
Created June 25, 2013 12:01
公历年份转换为中国纪元(天干地支)的方法

公历年份转换为中国纪元(天干地支)的方法

1. 为天干编码

0 1 2 3 4 5 6 7 8 9

凡是公元后年份,减4后除10取余,即得该年天干名称。

@nightire
nightire / Rails 4 - Active Record Associations.md
Last active March 27, 2016 12:40
Rails 4 - Active Record Associations

Rails 4 - Active Record Associations

has_one

一对一关系:有 A 和 B,A 拥有且仅拥有一个 B

has_one

belongs_to

@nightire
nightire / application.controller.js
Last active April 5, 2016 22:08
auto-complete component with editable content
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle',
selections: Ember.A([
Ember.Object.create({ name: '张三', phone: '13987654321' }),
Ember.Object.create({ name: '李四', phone: '13987654321' }),
Ember.Object.create({ name: '王五', phone: '13987654321' }),
Ember.Object.create({ name: '赵六', phone: '13987654321' }),
@nightire
nightire / post-merge
Created May 27, 2016 07:13 — forked from sindresorhus/post-merge
git hook to run a command after `git pull` if a specified file was changed. In this example it's used to run `npm install` if package.json changed and `bower install` if `bower.json` changed. Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
#/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
# git hook to run a command after `git pull` if a specified file was changed
# Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"
@nightire
nightire / components.accordion-item.js
Last active July 30, 2016 23:01
Ember Simple Accordion
import Ember from 'ember';
const AccordionItemState = Ember.Object.extend({
id: null,
active: false,
inactive: Ember.computed.not('active')
});
const AccordionItemComponent = Ember.Component.extend({
init() {
@nightire
nightire / Rails 4 - Active Record Query Interface.md
Created March 9, 2013 15:00
Rails 4 - Active Record Query Interface

Rails 4 - Active Record Query Interface

批量查询记录

我们时常会碰到需要一次性处理大量记录的要求,比如说为所有的用户发送电子邮件:

User.all.each do |user|
  NewsLetter.weekly_deliver(user)
end
@nightire
nightire / Git on the Server.md
Last active August 8, 2016 15:53
Git on the Server

Git on the Server

远程代码库通常只是一个“纯仓库”(bare repository)——一个没有当前工作目录的仓库;仓库里仅仅是 Git 的数据,也就是 .git 目录里的内容。

协议

Git 可使用四种协议来传输数据:

  1. 本地传输
  2. SSH 协议

Keybase proof

I hereby claim:

  • I am nightire on github.
  • I am nightire (https://keybase.io/nightire) on keybase.
  • I have a public key ASCw6pnicBByEKz-JHfQ5mi7HXrCQcD_fSdbEXJjpY-oSQo

To claim this, I am signing this object:

@nightire
nightire / components.simple-table.js
Last active September 26, 2016 17:00 — forked from ykaragol/components.simple-table.js
simple-table example
import Ember from 'ember';
export default Ember.Component.extend({
tableClassNames:'table table-striped table-bordered table-hover table-responsive table-condensed',
actions:{
selectionChanged(selectedRows){
this.set('selectedRows', selectedRows);
},