Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Richard Huang flyerhzm

🏠
Working from home
Block or report user

Report or block flyerhzm

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
View gist:8fc234d560a8b38f7e58fa841e19acb3

微信端

身份认证

防止未认证访问或数据篡改,需要在所有api调用加入2个参数 c 和 v

c = Base64(unix timestamp)
v = SHA1 hexdigest({c} + modumajiang)
@flyerhzm
flyerhzm / gist:f93fa4c1b3ab1044e1d2
Created Nov 30, 2015
delete branches already merged into master
View gist:f93fa4c1b3ab1044e1d2
# delete local branches
git branch --merged | grep -v develop | grep -v sandbox | grep -v master | xargs -n 1 git branch -d
# delete remote branches
git branch -r --merged | grep origin | grep -v develop | grep -v sandbox | grep -v master | xargs -L1 | cut -d"/" -f2- | xargs git push origin --delete
@flyerhzm
flyerhzm / gist:447dadfb23f6252d96ad
Created Nov 26, 2015
convert try to ruby 2.3 new safe navigation operator
View gist:447dadfb23f6252d96ad
# make sure your current ruby version is 2.3.0.preview1 or newer
gem install synvert -v 0.9.1
synvert --sync
synvert -r ruby/new_safe_navigation_operator
@flyerhzm
flyerhzm / gist:06eb1eb209d81c65842d
Created Nov 25, 2015
convert ruby code to new hash and lambda syntax
View gist:06eb1eb209d81c65842d
gem install synvert
synvert --sync
synvert -r ruby/new_hash_syntax $PROJECT_PATH
synvert -r ruby/new_lambda_syntax $PROJECT_PATH
View bottomless_spec.rb
class BottomlessHash < Hash
def initialize
super &-> h, k { h[k] = self.class.new }
end
def self.from_hash(hash)
new.merge(hash)
end
end
View exporter.rb
require 'csv'
module Exporter
DEFAULT_EXPORT_TABLES = [ Invoice, InvoiceItem, Item, Merchant, Transaction, User ]
DESTINATION_FOLDER = "tmp/"
def self.included(klass)
klass.extend ClassLevelMethods
end
View exporter.rb
require 'csv'
module Exporter
DEFAULT_EXPORT_TABLES = [ Invoice, InvoiceItem, Item, Merchant, Transaction, User ]
DESTINATION_FOLDER = "tmp/"
def self.included(klass)
klass.extend ClassLevelMethods
end
View gist:0d836d8e60d5673872b7
upstream codingstyleguide_upstream {
server unix:///home/deploy/sites/codingstyleguide/production/shared/tmp/sockets/puma.sock;
}
server {
listen 80;
server_name codingstyleguide-assets.xinminlabs.com;
access_log /var/log/nginx/codingstyleguide-asset.log;
error_log /var/log/nginx/codingstyleguide-error.log;
root /home/deploy/sites/codingstyleguide/production/current/public;
@flyerhzm
flyerhzm / gist:ca39e23100964623fc42
Last active Aug 29, 2015
remove trailing white spaces and use unix new line
View gist:ca39e23100964623fc42
Dir.glob("**/*.{rb,rake,erb}").each do |path|
content = File.read path
content.gsub! /\r\n?/, "\n"
content.gsub! /[ \t]+$/, ""
content.gsub! /^\t+/, " "
File.write path, content
end
View reactjs_onchange.js
R.input({
placeholder: 'City',
className: 'form-control',
type: 'text',
onChange: function(evt) {
this.setState({city: evt.target.value});
}.bind(this)
})
You can’t perform that action at this time.