Skip to content

Instantly share code, notes, and snippets.

var array = [
2,
4,
8,
16,
32,
64,
128,
256,
512,
@libitte
libitte / reset_revert_commit.md
Created October 24, 2013 22:14
commit を取り消したいとき...

not yet pushed

git reset --hard HEAD^

already pushed...

@libitte
libitte / test_bq.pl
Last active December 26, 2015 17:59
Perl * system() ... 2>&1 で、出力させつつ、戻り値としては $? を返す。 * `` ... 2>&1 で出力させた結果を戻り値とする。なお、改行コードも含まれる。
#!/usr/bin/env perl
use strict;
use warnings;
print "- system\n";
print "-----------------\n";
my $ret_sys = system 'ps aux | grep -v grep | grep perl | wc -l';
print '$ret_sys is ', $ret_sys;
print "\n";
print "-----------------\n";
#!/usr/bin/env perl
use strict;
use warnings;
use Perl6::Say;
use Data::Dumper;
#use List::Util qw( shuffle );
use Digest::MD5 qw(md5_hex);
my $KEY = 'bra-bra';
#!/usr/bin/env perl
use strict;
use warnings;
use Perl6::Say;
use Data::Dumper;
local $Data::Dumper::Indent = 1;
local $Data::Dumper::Terse = 1;
use Digest::MD5 qw(md5_hex);
@libitte
libitte / undef_vs_delete.pl
Created November 6, 2013 03:57
hash... * exists * delete variable... * defined * undef
#!/usr/bin/env perl
use strict;
use warnings;
use Data::Dumper;
my %hash = (
key1 => 'value1',
key2 => 'value2',
key3 => 'value3',
VIM
In Vi Improved to change or set desired syntax highlighting mode to MODE you have to type in VIM's command line:
:set syntax=MODE
It is very usefull when your file does not have standard extension or you are editting file with two languages in it, eg. AWK commands in a BASH script.
You can set AWK mode :set syntax=awk
@libitte
libitte / diff_between_hadoop_dfs_and_hadoop_fs.md
Created February 13, 2014 12:45
`hadoop dfs` と `hadoop fs` の違い
  • 配列の差分

@A - @B

my @A = qw(1 2 3 4 5 6 7 8 9);
my @B = qw(3 5 9);
 
my %cnt = ();
map { $cnt{$_}-- } @B;

user ごとの 件数のうち最大件数をしらべる

SELECT MAX(counted) FROM
(
SELECT COUNT(*) AS counted
FROM table_actions
WHERE status = "good"