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 / Ackermann.ss
Last active December 15, 2015 04:58
《计算机编程的构造和解释》学习记录
; 1.2
; http://en.wikipedia.org/wiki/Ackermann_function
; TODO 了解
(define (A x y)
(cond ((= y 0) 0)
((= x 0) (* 2 y))
((= y 1) 2)
(else (A (- x 1)
(A x (- y 1))))))
@dchentech
dchentech / .gitignore
Last active December 15, 2015 12:58
Ruby-China相似性文章测试
*.log
*.lock
@dchentech
dchentech / weight_n_height.R
Created April 15, 2013 01:17
《Exploring Everyday Things with R and Ruby》学习记录
height <- c(58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72) weight <- c(115, 117, 120, 123, 126, 129, 132, 135, 139, 142, 146, 150, 154,
159, 164) print(mean(height))
print(sd(weight)) print(cor(weight, height)) plot(weight, height)
console.log num for num in [10..1]
@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
@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) }
#!/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 / 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
@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