This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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 = "[email protected]: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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |