2013-01-28 atnd
- 何かアプリを乗せる話
- Java
<?php | |
require_once 'Crypt/Blowfish.php'; | |
$data = "test text"; | |
$key = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; | |
$iv = "bbbbbbbb"; | |
$blowfish = Crypt_Blowfish::factory('cbc', $key, $iv); # Crypt_Blowfish-1.1.0RC2 only | |
$encrypted_data = $blowfish->encrypt($data); | |
echo base64_encode($encrypted_data) . "\n"; |
def quicksort(arr) | |
return arr if arr.size <= 1 | |
pivot = arr.last | |
f, l = 0, arr.size - 1 | |
loop do | |
loop { break if arr[f].nil? || arr[f] > pivot; f += 1 } | |
loop { break if arr[l].nil? || arr[l] < pivot; l -= 1 } | |
break if l < f | |
arr[f], arr[l] = arr[l], arr[f] | |
end |
2013-01-28 atnd
% perlbrew install perl-5.16.2 | |
Fetching perl 5.16.2 as /Users/katsunori.kawaguchi/perl5/perlbrew/dists/perl-5.16.2.tar.bz2 | |
Installing /Users/katsunori.kawaguchi/perl5/perlbrew/build/perl-5.16.2 into ~/perl5/perlbrew/perls/perl-5.16.2 | |
This could take a while. You can run the following command on another shell to track the status: | |
tail -f ~/perl5/perlbrew/build.perl-5.16.2.log | |
Installation process failed. To spot any issues, check |
http://www.zusaar.com/event/489108
use 5.016; | |
use DateTime; | |
# beginning_of_day | |
say DateTime->now( time_zone=>'local' )->truncate( to => "day" )->strftime('%Y/%m/%d %H:%M:%S') | |
# => 2013/03/15 00:00:00 | |
# サマータイムで存在しない時刻を指定すると例外 | |
# (America/Chicago時刻では、2003-04-06 01:59:59 の次は 2003-04-06 03:00:00) | |
DateTime->new( time_zone => 'America/Chicago', year => 2003, month => 4, day => 6, hour => 2, minute => 0, second => 0 ); |
require "open3" | |
require "colorize" | |
guard 'shell' do | |
watch(/(.*).pm/) do |m| | |
arr = Open3.capture3("perl -c #{m[0]}") | |
line = arr.first.split("\n").first | |
unless line =~ /syntax OK/ | |
puts line.red | |
else |
[1] pry(main)> require "active_support/time" | |
=> true | |
[2] pry(main)> Time.parse("2013-03-31").next_month | |
=> 2013-04-30 00:00:00 +0900 | |
re.pl$ use DateTime | |
re.pl$ DateTime->new(year => 2013, month => 3, day =>31)->add( months => 1)->ymd; | |
"2013-05-01" |
use 5.016; | |
use utf8; | |
use Encode; | |
use Encode::Guess qw/utf8 euc-jp shiftjis/; | |
my $str = 'あああ'; | |
say guess_encoding($str)->name; | |
# => utf8 |
#!perl | |
use strict; | |
use warnings; | |
# ref: http://techlife.cookpad.com/entry/2015/11/17/151426 | |
my $commit_hash = $ARGV[0]; | |
unless ($commit_hash) { | |
print "usage: open_pull_request <commit_hash>\n"; |