This file contains hidden or 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
const mergeLineChartData = (head, dst, src) => { | |
dst[0].push(head) | |
let existed = false | |
for (const s of src) { | |
existed = false | |
for (const d of dst) { | |
if (d[0] === s[0]) { | |
d.push(s[1]) | |
existed = true | |
} |
This file contains hidden or 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
#!/usr/bin/env ruby | |
Dir.chdir(File.expand_path('..', __FILE__)) do | |
files = Dir.glob('**/*.{mp3,wma}') | |
file = files[rand(files.size)] | |
puts file | |
system "open \"#{file}\"" | |
end |
This file contains hidden or 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
# テナント間でキャッシュキーが同じになってしまいデータが混線するのを防ぐため | |
# config/initializersでnamespaceの設定を追加します。 | |
Rails.cache.options[:namespace] = proc { "#{Apartment::Tenant.current}-#{I18n.locale}" } |
This file contains hidden or 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
every 1.day, at: '3:00 am' do | |
command 'if [ -e /tmp/flushed_cache.* ]; then ionice -c 2 -n 7 nice -n 19 rm -rf /tmp/flushed_cache.*; fi' | |
end |
This file contains hidden or 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
0 3 * * * if [ -e /tmp/flushed_cache.* ]; then ionice -c 2 -n 7 nice -n 19 rm -rf /tmp/flushed_cache.*; fi |
This file contains hidden or 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
namespace :tmp do | |
namespace :cache do | |
# desc "Move all files and directories in tmp/cache to /tmp" | |
task :flush do | |
FileUtils.mv('tmp/cache', "/tmp/flushed_cache.#{Time.now.to_i}") | |
FileUtils.mkdir('tmp/cache') | |
end | |
end | |
end |
This file contains hidden or 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
class BanReservedValidator < ActiveModel::EachValidator | |
WORDS = %w{ | |
index home top help about security contact support faq form mail | |
update mobile tour plan price business company store shop term | |
privacy rule inquiry legal policy image css stylesheet src js | |
javascript asset account user item entry article event doc word | |
product download video community blog site popular i my me topic | |
news info status search explore share feature upload rss widget | |
api wiki auth session register login logout signup signin signout |
This file contains hidden or 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 change | |
adapter = ActiveRecord::Base.connection.instance_values['config'][:adapter] | |
if adapter == 'postgresql' | |
change_column :table_name, :field_name, 'integer USING CAST(field_name AS integer)' | |
else | |
change_column :table_name, :field_name, :integer | |
end | |
end |
NewerOlder