Skip to content

Instantly share code, notes, and snippets.

View riywo's full-sized avatar
🏈
Go 49ers!

Ryosuke Iwanaga riywo

🏈
Go 49ers!
View GitHub Profile
>>> 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}}
$ echo test | fcache set -k hoge -e 1m
$ fcache get -k hoge
test
$ fcache purge -k hoge
$ fcache get -k hoge
$
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)
@riywo
riywo / cli.pl
Last active December 14, 2015 05:29
#!/usr/bin/env perl
use strict;
use warnings;
MAIN: {
my $cli = CLI->new();
$cli->run();
}
package CLI;
#!/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()
@riywo
riywo / gist:5023060
Created February 24, 2013 07:58
Join mp3 files with homebrew
$ 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
@riywo
riywo / spec_helper.rb
Created February 22, 2013 10:51
webmock spec_helper
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
@riywo
riywo / gist:5008080
Created February 21, 2013 20:47
sync git local branch to remote branch (origin)
$ export BRANCH=test
$ git fetch
$ git checkout $BRANCH || git checkout -b $BRANCH origin/$BRANCH
$ git pull
@riywo
riywo / gist:5000181
Created February 20, 2013 22:15
How to delete git remote(origin) branch or tag?
# 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
@riywo
riywo / gist:4736159
Last active December 12, 2015 07:19
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>) {