Skip to content

Instantly share code, notes, and snippets.

Avatar
🌴
On vacation

Hironao OTSUBO motemen

🌴
On vacation
View GitHub Profile
@motemen
motemen / push-gh-pages.sh
Last active Oct 19, 2020
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)
@motemen
motemen / 05_Saving_Data.md
Last active May 9, 2020
Saving Data, Interecting with Other Apps
View 05_Saving_Data.md

データを保存する

Saving Data

  • だいたいのアプリはデータを保存する必要がある
    • onPause() でユーザの進捗を保存する
    • アプリの設定を保存する
    • ファイルやデータベースに巨大なデータを保存する
  • 以下で見ていく内容:
    • Shared preference ファイルに単純なデータ型の key-value ペアを保存する
View azik_customized.txt
- ー
~ ~
: ー
; っ
a あ
ba ば
bd べん
be べ
bh ぶう
bi び
@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
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;
You can’t perform that action at this time.