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
cat /dev/urandom | LC_CTYPE=C tr -dc '[:alnum:]' | head -c 40 && echo |
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
## rvm bash install script reading memo | |
## Based on https://github.com/wayneeseguin/rvm/blob/1.25.28/binscripts/rvm-installer | |
#!/usr/bin/env bash | |
# enable extended pattern matching | |
# shopt command changes the shell optional behavior | |
# extglob option enables you to write like `ls !(b*)` | |
# http://stackoverflow.com/questions/216995/how-can-i-use-inverse-or-negative-wildcards-when-pattern-matching-in-a-unix-linu | |
shopt -s extglob |
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
We're using git's Merge commit history to list features&bug fixes in a release tag. But I found cases where no merge commit was made as a result of `git merge`. According to this article (http://arjanvandergaag.nl/blog/clarify-git-history-with-merge-commits.html) it's due to fast-forward merge. To prevent it from happening, use `--no-ff` option when you merge. e.g. `git merge --no-ff feature/u483-asdf-asdf` This create a merge commit even if fast-forward merge is possible. Or, you can make it default with `git config --add merge.ff false` | |
Omit them needless merge commits. Add them to convey information. |
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
ubuntu@box432:~$ lsb_release -a | |
No LSB modules are available. | |
Distributor ID: Ubuntu | |
Description: Ubuntu 12.04.5 LTS | |
Release: 12.04 | |
Codename: precise | |
ubuntu@box432:~$ sudo apt-get install libboost-all-dev | |
Reading package lists... Done | |
Building dependency tree |
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 | |
tcpdump -s0 -i eth0 -X port 44567 -w test.cap |
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
# gzsplit.rb | |
# split gz files into pieces | |
# usage: ruby gzsplit [file-name] [lines-per-file] | |
require 'zlib' | |
require 'fileutils' | |
OUTPUT_DIR = "splited_files" | |
file_name = ARGV[0] || "20130910-03_01_00.gz" | |
lines_per_file = ARGV[1] ? ARGV[1].to_i : 5 |
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
#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
# 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
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" |
OlderNewer