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
>>> dict(map(lambda x: [x["k"], x], [{"k":"1", "v":1}, {"k":"2","v":2}])) | |
{'1': {'k': '1', 'v': 1}, '2': {'k': '2', 'v': 2}} |
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
$ echo test | fcache set -k hoge -e 1m | |
$ fcache get -k hoge | |
test | |
$ fcache purge -k hoge | |
$ fcache get -k hoge | |
$ |
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
module UserTempDir | |
def self.extended(example_group) | |
example_group.use_tempdir(example_group) | |
end | |
def self.included(example_group) | |
example_group.extend self | |
end | |
def use_tempdir(describe_block) |
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 perl | |
use strict; | |
use warnings; | |
MAIN: { | |
my $cli = CLI->new(); | |
$cli->run(); | |
} | |
package CLI; |
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 python | |
from optparse import OptionParser | |
class Hoge(object): | |
def __init__(self): | |
parser = OptionParser() | |
parser.add_option("-f", "--foo", action="store_true", dest="foo", default=False, | |
help="Foo") | |
(self.options, self.args) = parser.parse_args() |
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
$ brew install -v mp3wrap ffmpeg id3lib | |
$ mp3wrap tmp.mp3 1.mp3 2.mp3 3.mp3 .... | |
$ ffmpeg -i tmp_MP3WRAP.mp3 -acodec copy all.mp3 && rm tmp_MP3WRAP.mp3 | |
$ id3cp 1.mp3 all.mp3 |
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
require 'rspec' | |
require 'webmock/rspec' | |
require 'find' | |
RSpec.configure do |config| | |
config.before(:each) do | |
stub_files(File.expand_path("../mock_files/", __FILE__)) | |
end | |
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
$ export BRANCH=test | |
$ git fetch | |
$ git checkout $BRANCH || git checkout -b $BRANCH origin/$BRANCH | |
$ git pull |
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
# branch | |
$ git branch -d BRANCH # delete local BRANCH | |
$ git push origin :BRANCH # delete remote BRANCH | |
# tag | |
$ git tag -d TAG # delete local TAG | |
$ git push origin :refs/tags/TAG # delete remote TAG |
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
use strict; | |
use warnings; | |
use Fcntl qw/:DEFAULT :flock/; | |
use File::stat; | |
sub _parse_stats_file { | |
my ($self) = @_; | |
my $stats_fh = $self->_stats_fh(); | |
my $results = +{}; | |
while (<$stats_fh>) { |