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
#!/bin/bash | |
MYSQL_HOST="" | |
MYSQL_USER="" | |
MYSQL_PASSWORD="" | |
MYSQL_DB="" | |
CMD_INTERVAL=30 # 30sec | |
dump_info() { | |
echo "==== $(date)" |
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
# decode_buf_timestamp('522bedf5152a281c') => 2015-10-23 05:27:49 UTC | |
def decode_buf_timestamp(str) | |
Time.at((str.to_i(16) >> 12) / (1000 * 1000)).utc | |
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
git ls-files | xargs -n1 git --no-pager blame -f -w|grep <git name> |wc -l |
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 'msgpack' | |
require 'json' | |
fpath = ARGV[0] | |
io = if fpath | |
File.open(fpath) | |
else | |
$stdin | |
end | |
u = MessagePack::Unpacker.new(io) |
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 'tzinfo' | |
require 'date' | |
TIMEZONES = { | |
'us-east-1' => 'US/Eastern', | |
'us-west-1' => 'US/Pacific', | |
'us-west-2' => 'US/Pacific', | |
'eu-west-1' => 'GB', | |
'ap-southeast-1' => 'Singapore', | |
'ap-northeast-1' => 'Japan', |
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
class RedshiftString | |
# Redshift supports UTF-8 but it enforces stricter rule than other | |
# implementations such as MySQL or Ruby. This method returns a | |
# Redshift-safe string from the given string. | |
def self.encode(string, options = {}) | |
result = string.encoding == Encoding::UTF_8 ? string.encode(Encoding::UTF_16, options).encode(Encoding::UTF_8) : string.encode(Encoding::UTF_8, options) | |
result.each_char.collect{|c| | |
# Per Redshift document | |
# http://docs.aws.amazon.com/redshift/latest/dg/multi-byte-character-load-errors.html | |
if c >= "\uFDD0" && c <= "\uFDEF" || c == "\uFFFE" || c == "\uFFFF" |
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
# rails_root/config/initializers/load_submodule_models.rb | |
RAILS_MODEL_LIST = %w( | |
Account | |
Plan | |
User | |
UserPreference | |
) | |
def apply_db_change(class_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
#include <boost/version.hpp> | |
#include <iostream> | |
int main() | |
{ | |
std::cout << BOOST_LIB_VERSION << std::endl; | |
return 0; | |
} |
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 append_load_path_if_not_exist(new_lib_path) | |
absolute_path = File.realpath(new_lib_path) | |
$LOAD_PATH.unshift absolute_path unless $LOAD_PATH.include? absolute_path | |
end | |
another_lib_dir = File.realpath('../../lib', __FILE__) | |
append_load_path_if_not_exist(another_lib_dir) |
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
select trunc(startwork), count(distinct xid) from stl_commit_stats where xid > 0 group by trunc(startwork) order by 1; |