Skip to content

Instantly share code, notes, and snippets.

View dchentech's full-sized avatar
🎯
Focusing

David Chen dchentech

🎯
Focusing
View GitHub Profile
@dchentech
dchentech / python_closure.py
Created April 28, 2014 08:51
python closure
def computer():
count = 5
def plus(num):
count += num
print count
return plus
plus = computer()
plus(3)
plus(5)
"""
(function () {
"use strict";
var copyOwnProperties = function (from, to) {
for (var propertyName in from) {
if (from.hasOwnProperty(propertyName)) {
to[propertyName] = from[propertyName];
}
}
};
@dchentech
dchentech / backbone_view_dynamic_render.js
Created February 28, 2014 04:06
Backbone View 随数据改变而render。
$(document).ready(function() {
var dom = $("<div>").attr('id', 'mvj3');
$("body").html(dom);
window.mvj3 = Backbone.View.extend({
initialize: function(opts) {
this.opts = opts;
return this;
},
tagName: "div",
render: function() {
@dchentech
dchentech / statlysis.showterm
Last active January 1, 2016 16:19
用statlysis来对CodeGist进行每日统计分析访问,用 http://showterm.io 来录制的。
地址在 http://showterm.io/7881a7c028d436b077273
脚本如下:
# statlysis是一个数据引擎分析框架,核心是对ETL之后的单表数据做类似SQL中GroupBy和GroupConcat的工作,
# 就像操作ActiveRecord等ORM一样简单。项目地址在 http://github.com/mvj3/statlysis
# 在这个test/helper.rb被载入后我们已经导入数据和建立Model了,
# 所以下面我们就来开始试用statlysis吧。
@dchentech
dchentech / sendmail.sh
Created November 4, 2013 08:26
send mail via sendmail command line
cat - README.markdown << EOF | sendmail -t
to:[email protected]
from:[email protected]
subject:debian-jk
EOF
@dchentech
dchentech / install.sh
Created October 18, 2013 06:47
手工通过adb安装APK到android
adb shell pm clear com.ssl.support.install
adb shell pm clear com.ssl.support.daemon
adb install -r ~/sunshine/bhsf-install-adb/SunDaemon-release.apk
adb push ~/sunshine/bhsf-install-adb/SunInstall-release.apk /system/app
sudo umount /Volumes/MID
#!/bin/sh
#
# https://gist.github.com/mvj3/6973600
#
# unicorn - init.d script for single or multiple unicorn installations. Expects at least one .conf
# chkconfig: - 85 15
# description: Unicorn is an HTTP server for Rack applications designed to only serve fast clients on low-latency,
# high-bandwidth connections and take advantage of features in Unix/Unix-like kernels
# processname: unicorn
# config: /etc/unicorn/*.conf
@dchentech
dchentech / select_all_mongoid_models.rb
Created September 12, 2013 10:41
选出所有Mongoid Model
mongoid_models = Object.constants.map {|i| i.to_s.constantize rescue nil }.compact.select {|i| i.is_a?(Class) && i.included_modules.include?(Mongoid::Document) }
@dchentech
dchentech / learn_eoe_cn_code_count.rb
Last active December 20, 2015 14:49
learn.eoe.cn Rails项目及其开源项目源码行数统计
# encoding: UTF-8
# learn.eoe.cn Rails项目及其开源项目源码行数统计
require 'active_support/all'
@total_ruby_lines_count = 0
@total_javascript_lines_count = 0
@total_haml_lines_count = 0
def count_lines_by_file_type pattern, exclude = nil
exclude_str = " | grep -v #{exclude} " if exclude