Skip to content

Instantly share code, notes, and snippets.

@ainoya
ainoya / epv.py
Last active August 14, 2023 09:04
extract phrasal verbs
#!/usr/bin/env python
import pprint
import json
import corenlp
corenlp_dir = "/tmp/stanford-corenlp-full-2013-06-20"
parser = corenlp.StanfordCoreNLP(corenlp_path=corenlp_dir)
result_json = json.loads(parser.parse("hey shut down the station"))
pprint.pprint(result_json)
@ainoya
ainoya / stripe_error_ja.json
Created December 30, 2020 03:19
stripe errors Japanese translated
{
"account_already_exists": "アカウントがすでに存在します",
"account_country_invalid_address": "アカウントの国籍とビジネスを行う国籍が異なります",
"account_invalid": "アカウントが不正です",
"account_number_invalid": "口座番号が不正です",
"alipay_upgrade_required": "Alipayのアップデートが必要です",
"amount_too_large": "金額が多すぎます",
"amount_too_small": "金額が少なすぎます",
"api_key_expired": "APIキーが失効しています",
"balance_insufficient": "残高不足です",
@ainoya
ainoya / SKAction+Extensions.swift
Created July 12, 2015 18:46
Swift Extensions for SKAction.playSoundFileNamed() with custom volume
// reference: https://github.com/pepelkod/iOS-Examples/blob/master/PlaySoundWithVolume/PlaySoundWithVolumeAction.m
import SpriteKit
public extension SKAction {
public class func playSoundFileNamed(fileName: String, atVolume: Float, waitForCompletion: Bool) -> SKAction {
let nameOnly = fileName.stringByDeletingPathExtension
let fileExt = fileName.pathExtension
@ainoya
ainoya / remote_sudo.rb
Created June 13, 2013 00:40
Execute remote sudo command with net-ssh
#!/usr/bin/env ruby
require 'net/ssh'
require 'highline/import'
def get_password
ask( "Enter Password: " ) {|q| q.echo = '*'}
end
def remote_sudo host, ssh_user, command, opts={}
@ainoya
ainoya / wf.md
Created November 9, 2017 02:08
td wfコマンドをdockerfileに含めたい
FROM vixns/java8

RUN  cp -p /usr/share/zoneinfo/Asia/Tokyo /etc/localtime

RUN apt-get -y update && apt-get -y install wget unzip mysql-client ftp ruby ruby-msgpack ruby-yajl libmysqld-dev libmysqlclient-dev ruby-dev gcc build-essential
RUN gem install rake td mysql2

ARG TD_API_KEY=${TD_APIKEY}
RUN echo 'Y' | td wf
@ainoya
ainoya / utf8-mac-matcher.rb
Created July 28, 2016 06:52
matcher for comparing string as uf8-mac coded string in test iOS app via appium
RSpec::Matchers.define :eq_as_utf8_mac do |expected|
match do |actual|
actual.force_encoding('UTF8-MAC') === expected.encode('UTF8-MAC')
end
end
expected = 'ぱぴぷぺぽ'
# actual = 'ぱぴぷぺぽ' gots from iOS App through appium server.
expect(find(actual).name.strip)
@ainoya
ainoya / simple_daemon_restarts_regularly.rb
Created July 28, 2016 06:49
damonize process and restart regularly
#!/usr/bin/env ruby
require 'rufus-scheduler'
$stdout.sync = true
scheduler = Rufus::Scheduler.new
def exec_command(cmd)
IO.popen(cmd) do |io|
while (line = io.gets) do
@ainoya
ainoya / parallel_appium.rb
Created July 28, 2016 06:46
start appium server in parallel
require 'selenium-webdriver'
require 'logger'
class AppiumServer
def initialize(opts = {})
@port = Selenium::WebDriver::PortProber.above(3000)
@log = ::Logger.new(STDOUT)
end
def start
@ainoya
ainoya / gist:4662509
Created January 29, 2013 07:38
Convert csv data to array of hash/yaml/json.etc.. in ruby
#!/usr/bin/env ruby
require 'csv'
require 'yaml'
require 'json'
csv =<<EOF
id,name,price
A1,apple,100
A2,grape,300
@ainoya
ainoya / gist:4662125
Last active December 11, 2015 21:28
Avoiding pry installation failure by installing rdoc gem before install it.
➜ ~ rbenv global 1.9.3-p286
➜ ~ rbenv rehash
➜ ~ gem install pry
Fetching: coderay-1.0.8.gem (100%)
Fetching: slop-3.4.3.gem (100%)
Fetching: method_source-0.8.1.gem (100%)
Fetching: pry-0.9.11.4.gem (100%)
Successfully installed coderay-1.0.8
Successfully installed slop-3.4.3
Successfully installed method_source-0.8.1