Skip to content

Instantly share code, notes, and snippets.

View ninjacn's full-sized avatar
🤒
Out sick

姚鸣 ninjacn

🤒
Out sick
  • Beijing
View GitHub Profile
@ninjacn
ninjacn / 1.py
Last active October 19, 2018 11:10
动态创建类
# 不安全
class_name = str("ClassName")
obj = eval(class_name)()
# 安全
class_name = str("ClassName")
obj = globals()[class_name]
@ninjacn
ninjacn / go-os-arch.md
Created November 16, 2017 06:04 — forked from asukakenji/0-go-os-arch.md
Go (Golang) GOOS and GOARCH

Go (Golang) GOOS and GOARCH

All of the following information is based on go version go1.8.3 darwin/amd64.

A list of valid GOOS values

(Bold = supported by go out of the box, ie. without the help of a C compiler, etc.)

  • android
  • darwin
select
t_x.refer_from,
COALESCE(t_a.customers_count_for_refer,0) as customers_count_for_refer,
COALESCE(t_b.order_count_for_first_order,0) as order_count_for_first_order,
COALESCE(t_b.first_order_total_price,0) as first_order_total_price,
COALESCE(t_c.customers_count_for_reg_and_order,0) as customers_count_for_reg_and_order,
COALESCE(t_c.total_price_for_reg_and_order,0) as total_price_for_reg_and_order
from
(
select c.refer_from from customers as c where
@ninjacn
ninjacn / gist:8da982e1667b4a19ee85c8469b9aa1b1
Created July 25, 2017 02:40
SQL-通过地区-店铺查询汇总信息
select
t.region_id,
t.region_name,
count(distinct t.order_id) as order_nums_by_store,
count(distinct t.customer_id) as customer_num_by_store,
sum(t.pay_from_third_part) as pay_by_store,
sum(t.snap_total_price) as sales_by_store,
sum(t.pay_from_balance) as balance_by_store,
sum(t.cost_by_store) as cost_by_store
from (
@ninjacn
ninjacn / gist:a0e47f2bd767a988b861
Created September 7, 2015 14:39
yii 动态修改rule
class LoginForm extends CFormModel
{
public $username;
public $password;
}
$form = new LoginForm();
$form->validatorList->add(
CValidator::createValidator('required', $form, 'username, password')
);

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname