Skip to content

Instantly share code, notes, and snippets.

ruohan.chen crhan

Block or report user

Report or block crhan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
crhan / pyproject.toml
Created Oct 8, 2019
poetry bug produce toml
View pyproject.toml
name = "20191008"
version = "0.1.0"
description = ""
authors = ["ruohan.chen <>"]
python = "^2.7, <3.0 || ^3.7, < 3.8"
crhan / install-setup.txt
Last active Oct 9, 2018 — forked from cactus/install-setup.txt
python serialization speed comparison
View install-setup.txt
virtualenv --no-site-packages hodor
hodor/bin/pip install simplejson ujson cbor tnetstring msgpack-python
curl -s '' > test.json
crhan /
Last active Sep 19, 2018
MotionLights for HomeAssistant


  1. 支持光照度条件, 环境光足够亮就不开灯, 例如阳台灯
  2. 支持多个 sensor 共同触发, 例如卫生间可以放两个人体传感器, 玄关可以放一个门窗传感器+人体传感器
  3. 支持只关不开(厕所排气扇场景)或者只开不关(不知道为啥要这样, 你想到了告诉我)
  4. 支持延时关闭, 根据自身情况设定, 规避人体传感器不灵敏的问题

这个功能不适合经常有人呆着的地方, 比如书房, 卧室, 客厅.

crhan /
Last active Apr 12, 2017 — forked from chuangbo/
Python dynamic DNSPod DNS Script

替换上你的 Token,域名ID,记录ID等参数,就可以运行了。 跟原代码不同的是,该版本每次执行就运行一次,方便使用调度系统来进行调度

获得domain_id可以用curl curl -k -d "login_token=xxx"

获得record_id类似 curl -k -d "login_token=xxx&domain_id=xxx"

crhan /
Last active Feb 20, 2017
DHCPd Detector

DHCPd Detector

Useful tool for sniffing DHCP Server on specified Interface

How to use

python [--config <filename>.cfg]


View operating_system.rb
module Gem
class << self
# Returns full path of previous but one directory of dir in path
# E.g. for '/usr/share/ruby', 'ruby', it returns '/usr'
def previous_but_one_dir_to(path, dir)
split_path = path.split(File::SEPARATOR)
File.join(split_path.take_while { |one_dir| one_dir !~ /^#{dir}$/ }[0..-2])
crhan / deploy.rb
Last active Jan 1, 2016
deploy rails app to remote server, which has a limited internet access.
View deploy.rb
# config/deploy.rb
namespace :deploy do
desc "check local vendor/cache"
task :bundled_package do
run_locally do
unless test "[[ -d #{File.expand_path("../../vendor/cache", __FILE__)} ]]"
error "please `bundle package --all` first!"
raise StandardError
crhan / attributes.rb
Last active Jan 1, 2016
chef deploy rbenv and binary ruby
View attributes.rb
default["ops-oob"]["rbenv_tar"] = "rbenv_6u2.tar.gz"
umask 002
## Install rbenv, ruby-build and rbenv-gem-rehash
git clone git:// $RBENV_PREFIX
crhan / deploy.rb
Created Dec 19, 2013
make capistrano deploy code in a limited parallel
View deploy.rb
namespace :deploy do
## set max_hosts 20 or via env
set :max_hosts, ENV['MAXHOSTS'] || 20
## set max_hosts on update_code
task :update_code, :except => { :no_release => true }, :max_hosts => "#{max_hosts}" do "\e[0;31;1mNOTICE:\e[0m Pulling repo from #{repository}: max_hosts => '#{max_hosts}'"
on_rollback { run "rm -rf #{release_path}; true" }
You can’t perform that action at this time.