Skip to content

Instantly share code, notes, and snippets.

🌴
On vacation

Hironao OTSUBO motemen

🌴
On vacation
Block or report user

Report or block motemen

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@motemen
motemen / git-remove-old-branches
Created Dec 29, 2011
remove old remote git branches interactively
View git-remove-old-branches
#!/bin/sh
git fetch
for branch in `git branch --remote --merged origin/master | sed 's/ *origin\///' | grep -v ' ' | grep -v 'master$'`
do
MERGE_EPOCH=$(git --no-pager log -1 --pretty='%ct' $(git merge-base origin/master origin/$branch))
CURRENT_EPOCH=$(git --no-pager log -1 --pretty='%ct' origin/master)
if [ $(expr $(expr $CURRENT_EPOCH - $MERGE_EPOCH) / 60 / 60 / 24) -ge 14 ]; then
@motemen
motemen / push-gh-pages.sh
Last active May 19, 2019
Shell script to setup/push GitHub pages
View push-gh-pages.sh
#!/bin/sh
# usage: push-gh-pages DIRECTORY # DIRECTORY is where GitHub pages contents are in (eg. build)
# LICENSE: Public Domain
set -e
remote=$(git config remote.origin.url)
described_rev=$(git rev-parse HEAD | git name-rev --stdin)
View textlint-asciidoctor.rb
#!/usr/bin/env ruby
# textlint-asciidoctor -r ./macro.rb -T code,dfn index.adoc
require 'asciidoctor'
require 'cgi'
require 'json'
require 'optparse'
require 'tempfile'
ERASED_TEXT = '◆◆'
@motemen
motemen / gorun.sh
Created Mar 9, 2018
Shell script to run a Go program by package path
View gorun.sh
#!/bin/bash
set -e
pkg="$1"; shift
files=($(go list -f '{{range .GoFiles}}{{$.Dir}}/{{.}}{{end}}' "$pkg"))
go run -exec "bash -c 'shift; exec \"\$0\" \"\$@\"'" "${files[@]}" -- "$@"
@motemen
motemen / git-commit-file-to-branch.sh
Created Apr 29, 2012
Commit a file to another branch
View git-commit-file-to-branch.sh
#!/bin/sh
BRANCH=$1
FILE=$2
if [ -z "$BRANCH" ]; then
echo "Usage: $0 <branch> <file>"
exit 1
fi
View test.pl
$] = 5.008008
$URI::VERSION = 1.71
https://www.example.com?hoge=%E3%81%BB%E3%81%92
https://www.example.com?hoge=%C3%A3%C2%81%C2%BB%C3%A3%C2%81%C2%92&foo=bar
View resolvecpandeps.pl
use strict;
use warnings;
use HTTP::Tiny;
use JSON;
use App::cpanminus::fatscript;
my $dist = shift;
my $dep = shift;
my $version = shift;
View exercise-a.3.4.als
sig Person {
shaken: set Person,
partner: Person
}
fact partnerProperties {
partner = ~partner
no p: Person | p in p.partner
}
View metacpan-query.json
http://api.metacpan.org/v0/release/_search?source={%20%22query%22:%20{%20%22filtered%22:%20{%20%22query%22:%20{%20%22match_all%22:%20{}%20},%20%22filter%22:%20{%20%22and%22:%20[%20{%20%22term%22:%20{%20%22distribution%22:%20%22Net-CIDR-MobileJP%22%20}%20},%20{%20%22nested%22:%20{%20%22path%22:%20%22dependency%22,%20%22filter%22:%20{%20%22and%22:%20[%20{%20%22term%22:%20{%20%22dependency.module%22:%20%22WWW::MobileCarrierJP%22%20}%20},%20{%20%22term%22:%20{%20%22dependency.version_numified%22:%200%20}%20}%20]%20}%20}%20}%20]%20}%20}%20}%20}
You can’t perform that action at this time.