Skip to content

Instantly share code, notes, and snippets.

View hmsk's full-sized avatar
🍺
Now Brewing

Kengo Hamasaki hmsk

🍺
Now Brewing
View GitHub Profile
{
"error": {
"type": "card_error",
"message": "The system is so busy. Please wait for a while to try it again.",
"code": "processing_error"
}
}
require 'open-uri'
require 'json'
body = open('http://www3.nhk.or.jp/news/easy/news-list.json', "r:utf-8").read.gsub("\xEF\xBB\xBF", '')
begin
json = JSON.parse(body)
p json
rescue JSON::ParserError => e
puts e.message
#!/usr/local/bin/ruby
ARGV.each do |f|
read_size = 0
io = File.open f
print "#{f} :\n"
while (s = io.sysread(32768) rescue nil) do
read_size += s.size
STDERR.print "#{read_size} bytes read \r"
end

Keybase proof

I hereby claim:

  • I am hmsk on github.
  • I am hmsk (https://keybase.io/hmsk) on keybase.
  • I have a public key whose fingerprint is 2F06 25F6 2AC5 3F32 B45C C423 C5EF 0A6A 7C59 4925

To claim this, I am signing this object:

@hmsk
hmsk / varnish3.rb
Created June 15, 2011 18:31
Install Varnish-3.0.0-beta2 on OSX with homebrew
require 'formula'
class Varnish3 <Formula
url 'http://repo.varnish-cache.org/source/varnish-3.0.0-beta2.tar.gz'
homepage 'http://www.varnish-cache.org/'
md5 '26b6c5f57b1a2a736503a225a4d911cc'
depends_on 'pkg-config' => :build
depends_on 'pcre' => :build
@hmsk
hmsk / file0.txt
Created January 22, 2013 11:31
Google Play In-app BillingをAPI v3のサンプルを使って楽して導入する ref: http://qiita.com/items/39dff3374e2292a1daed
public abstract class BaseActivity extends SherlockFragmentActivity {
private static final String SKU_PREMIUM = "Developer Consoleで設定したproduct id";
private static final int REQUEST_CODE_PURCHASE_PREMIUM = よしなにリクエストコードを;
private static final String BILLING_PUBLIC_KEY = "Developer Consoleで得られるBase64encodedな公開鍵(そのままコードに持たせず別の形からデコードなりして持ってくるのが推奨されている";
private IabHelper mBillingHelper;
private boolean mIsPremium = false;
@Override
git push heroku `git subtree split --prefix website master`:master --force
@hmsk
hmsk / webpay-pry.rb
Created December 22, 2013 15:35
Communicate with WebPay on CLI by `ruby webpay-pry.rb`
# coding: utf-8
# ref: http://sho.tdiary.net/20131128.html
require 'pry'
require 'webpay'
require 'singleton'
module WebPayConsole
class ObjectRepository
robot.router.post '/hubot/an-endpoint', (req, res) ->
payload = req.body || { recipient: null }
unless payload.recipient == 'my-mailgun@email-address'
res.writeHead(403)
res.end()
return
res.writeHead(204)
res.end()
att =
@hmsk
hmsk / git-rebase-on-current-branch
Last active November 27, 2017 21:53
[Run interactive editor for all commits after folking current branch] #git #zsh
#!/bin/sh
_git_rebase_on_current_branch()
{
# https://gist.github.com/joechrysler/6073741
branch=`git rev-parse --abbrev-ref HEAD`
parent_branch=`git show-branch -a 2>/dev/null | grep '\*' | grep -v "$branch" | head -n1 | sed 's/.*\[\(.*\)\].*/\1/' | sed 's/[\^~].*//'`
latest_parent_commit=`git merge-base $parent_branch HEAD`
echo Run rebase interactive editor for commits after $latest_parent_commit
git rebase -i $latest_parent_commit