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
var page = require('webpage').create(); | |
page.onResourceRequested = function(request) { | |
console.log('Request (#' + request.id + '): ' + request.url); | |
}; | |
page.open(phantom.args[0] || 'http://google.com', function() { | |
console.log('loaded'); | |
phantom.exit(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
javascript:(function() {var str = '[' + document.title.replace(/\|/g, '\\|') + '](' + window.location.href + ')'; window.prompt('markdown link', str);})(); |
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
$ perl -MTime::Piece -le 'my $now = localtime->epoch; print $now;' | |
1355125319 |
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
$ perl -MData::Dumper -le 'my $a = +{}; $a->{foo}->{bar}++; $a->{foo}->{bar}++; $a->{foo}->{baz}++; $a->{blah}->{blah}++; print Dumper $a;' | |
$VAR1 = { | |
'blah' => { | |
'blah' => 1 | |
}, | |
'foo' => { | |
'bar' => 2, | |
'baz' => 1 | |
} | |
}; |
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
% perl -le 'my $input = "300x250"; print "abort" unless $input =~ /(\d+)x(\d+)/; my ($w, $h) = ($1, $2); print "$1 x $2";' | |
300 x 250 |
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
$ python -c 'from markdown import markdown; import codecs; print markdown(open("/Users/kosei/projects/please-sleep/posts/zsh-builtin-command-fc.md").read().decode("utf-8")).encode("utf-8");' | |
<ul> | |
<li> | |
<p>nix: zsh の fc ビルトインコマンド | |
<code>fc</code> はコマンドの履歴操作をおこなう汎用的なコマンドで, たとえば <code>history</code> は zsh だと <code>fc -l</code> のエイリアスだったりする.</p> | |
</li> | |
<li> | |
<p><code>history</code> のように普通に履歴を表示するだけだったら <code>-l</code> オプションをつける.</p> | |
</li> | |
<li><code>-n</code> でコマンドの通し番号を表示しない</li> |
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
$ pwd | |
/Users/kosei | |
$ date +%s | |
1355044489 |
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
$ python -c 'import os; print os.environ["SHELL"]; print os.environ["HISTFILE"]' | |
/bin/zsh | |
Traceback (most recent call last): | |
File "<string>", line 1, in <module> | |
File "/Users/kosei/.virtualenvs/dev/bin/../lib/python2.7/UserDict.py", line 23, in __getitem__ | |
raise KeyError(key) | |
KeyError: 'HISTFILE' |
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
$ python -c 'print 1 if [] else 0' | |
0 | |
$ python -c 'print 1 if [1] else 0' | |
1 |
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
$ python -c 'import sys; print dir(sys.stdin)' | |
['__class__', '__delattr__', '__doc__', '__enter__', '__exit__', '__format__', '__getattribute__', '__hash__', '__init__', '__iter__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'close', 'closed', 'encoding', 'errors', 'fileno', 'flush', 'isatty', 'mode', 'name', 'newlines', 'next', 'read', 'readinto', 'readline', 'readlines', 'seek', 'softspace', 'tell', 'truncate', 'write', 'writelines', 'xreadlines'] | |
$ python -c 'import sys; print sys.stdin.isatty()' | |
True | |
$ echo | python -c 'import sys; print sys.stdin.isatty()' | |
False | |
$ python -c 'import sys; print sys.stdin.isatty()' < ~/.bashrc | |
False |