Skip to content

Instantly share code, notes, and snippets.

耿返 angelfan

Block or report user

Report or block angelfan

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 session_patch.rb
# frozen_string_literal: true
module SessionRedisPatch
def generate_unique_sid(_session)
loop do
sid = generate_sid
first = with do |c|
[*init_session(c, sid, @default_options)].first
end
break sid if [1, true].include?(first)
View fabfile.py
# -*- coding: utf-8 -*-
from fabric.api import env, run
env.user = 'root'
env.hosts = ['10.1.69.24', '10.1.51.22']
env.port = '22'
env.git_clone = "git@gitlab.tuhu.cn:gengfan/treasure.git"
env.base_dir = "/root/apps"
env.app_name = "treasure"
env.domain_path = "{base_dir}/{app_name}".format(base_dir=env.base_dir, app_name=env.app_name)
@angelfan
angelfan / stringify_keys.rb
Created Jul 28, 2016 — forked from mkuhnt/stringify_keys.rb
Deep Stringify Keys of hash even with embedded arrays
View stringify_keys.rb
def transform_hash(original, options={}, &block)
original.inject({}){|result, (key,value)|
value = if (options[:deep] && Hash === value)
transform_hash(value, options, &block)
else
if Array === value
value.map{|v| transform_hash(v, options, &block)}
else
value
end
@angelfan
angelfan / dbconfig.rake
Created Jul 28, 2016 — forked from ka8725/dbconfig.rake
database.yml generator. Global Rake implementation
View dbconfig.rake
require 'yaml'
desc 'Generates database.yml, optional arguments: [adapter, user, password]'
task :dbconfig => 'database.yml'
file 'database.yml', [:adapter, :username, :password] do |t, args|
Dir.chdir('config')
args.with_defaults(:project_path => Dir.pwd)
DBConfigGenerator.new(t, args).generate
end
@angelfan
angelfan / si.rb
Created Mar 21, 2016 — forked from rasefon/si.rb
Similar Image Compare
View si.rb
require 'RMagick'
$scale_size = 256.0
$img_fn1 = ARGV[0]
$img_fn2 = ARGV[1]
$scale_size = ARGV[2].to_f if ARGV[2]
def calculate_threshold(img_fn)
dir_name = File.dirname(img_fn)
You can’t perform that action at this time.