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 | |
count(*) | |
from | |
special_topic_company | |
inner join | |
special_topic on special_topic.id = special_topic_company.special_topic_id | |
where | |
special_topic_company.company_root_id is null | |
and | |
special_topic_company.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
public List<String> convertInputStreamToString(InputStream is) { | |
List<String> ret = Collections.emptyList(); | |
try { | |
ret = IOUtils.readLines(is); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
return ret; | |
} |
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 levenshtein_distance(s, t) | |
t.chars.with_index.inject(0..s.size) do |r, (a, z)| | |
z += 1 | |
[z] + s.chars.zip(r.each_cons(2)).map do |b, (x, y)| | |
z = [y + 1, z + 1, x + (a == b ? 0 : 1)].min | |
end | |
end.last | |
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
#!/usr/bin/env ruby | |
# -*- coding:utf-8 -*- | |
require 'pathname' | |
module VCSCommand | |
@@vcs_update_table = { | |
'.git' => 'git pull', | |
'.hg' => 'hg pull -u', | |
'.svn' => 'svn up', |
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 | |
module Enum | |
def initialize(key, no, value) | |
@key = key | |
@no = no | |
@value = value | |
end | |
attr_reader :key, :no, :value |
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
#!/usr/bin/env sh | |
# https://gist.github.com/1191177 in Ruby origin. | |
while read input | |
do | |
if [[ $input =~ (、|。) ]]; then | |
echo $input | sed -e s/、/,/g | sed -e s/。/./g | |
else | |
echo $input | sed -e s/,/、/g | sed -e s/./。/g | |
fi |
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 some_action | |
#... | |
do_logging(object) | |
#... | |
end | |
def do_logging | |
@logger.info("test") | |
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
my %t; | |
while (<>) { | |
my ($key, $value) = split; | |
if (not $t{$key}) { | |
$t{$key} = (); | |
} | |
push @{$t{$key}}, $value; | |
} | |
foreach $key (keys %t) { | |
print "$key \n"; |
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
ls -ltr | awk '{print $9}' | while read meeting | |
do | |
echo $meeting | xargs nkf -w -Lu > ${meeting%.txt}.rst | |
done |
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
rock=->_{_=="scissors"};scissors=->_{_=="paper"};paper=->_{_=="rock"};->a,b{if a==b;puts"Draw.";elsif eval(a).call(b);puts"Left win.";else puts"Right win.";end}.call(*ARGV) | |