Skip to content

Instantly share code, notes, and snippets.

View zerobase's full-sized avatar

Hideto Ishibashi zerobase

View GitHub Profile
@zerobase
zerobase / japanese_ime.html
Created December 10, 2013 01:41
"compositionstart" and "compositionend" events, and Japanese Input Method
<!DOCTYPE html>
<html>
<head>
<title>"compositionstart" and "compositionend" events, and Japanese Input Method</title>
</head>
<body>
<textarea name="textarea" id="textarea" cols="30" rows="3"></textarea>
<h2>onkeydown</h2>
<p>nowCompositioning: <span id="nowCompositioning"></span></p>
<p>keyCode: <span id="keyCode"></span></p>
@zerobase
zerobase / safari-reading-list-to-instapaper-csv.rb
Last active July 16, 2020 04:13
Safari Readling List to Instapaper CSV (Ruby script for Mac)
# 1. Open Terminal.app.
# 2. Type "cd Desktop" and Enter.
# 3. Type "open ~/Library/Safari/" and Enter.
# 4. Hold Option key and drag-and-drop (i.e. copy) Bookmarks.plist to the Desktop.
# 5. Back to the Terminal, type "ruby safari-readling-list-to-instapaper-csv.rb" and Enter.
# 6. Open Instapaper Settings (https://www.instapaper.com/user), and select "Import from Instapaper CSV."
# 7. Upload Safari-Reading-List.csv on the Desktop.
require "plist"
require 'csv'
@zerobase
zerobase / .gitignore
Last active May 21, 2020 06:32
課税所得に対する所得税額を返す (計算根拠: 国税庁タックスアンサーNo.2260 所得税の税率 https://www.nta.go.jp/taxes/shiraberu/taxanswer/shotoku/2260.htm)
node_modules/
@zerobase
zerobase / fix_cask.sh
Created October 27, 2016 06:26
Fix Homebrew Cask application links (one-liner for zsh)
#!/bin/zsh
src=/opt/homebrew-cask; dst=/usr/local; for f in ~/Applications/*.app; do [ -h $f ] && l=$(readlink $f); ln -sf ${l/$src/$dst} $f; done
@zerobase
zerobase / kinokuniya_stock.js
Created July 7, 2016 12:52
紀伊國屋在庫検索ブックマークレット Amazon.co.jp用
javascript:var%20d=document,h='#form-contents',f='https://www.kinokuniya.co.jp/disp/CKnSfStockSearchStockView',l=d.location,b0='978'+l.href.match('https://www.amazon.co.jp/.*(?:dp|product)/([0-9X]{10})/')[1].substr(0,9),bn=b0+(10-(b0.split('').map((x,i)=>(xx=parseInt(x),(i%252==0)?xx:xx*3)).reduce((acc,cur)=>acc+cur,0)%2510)),e=encodeURIComponent,p='.jsp?CAT=01&GOODS_STK_NO='+e(bn)+'&MAN_ENTR_CD1=G2';1;try{if%20(!/^(.*\.)?kinokuniya\.[^.]*$/.test(l.host))throw(0);share_internal_bookmarklet(p)}catch(z)%20{a=function()%20{if%20(!window.open(f+p+h,'stockinfo','toolbar=0,status=0,resizable=1,width=700,height=500'))l.href=f+p+h};if%20(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else{a()}}void(0)
@zerobase
zerobase / gist:8536743
Last active January 3, 2016 23:39
Chaplin/Backbone謎の擬似コード
class Homepage extends Chaplin.Model
_.extend @prototype, Chaplin.EventBroker
result: (val) ->
if val
publishEvent "change:result", result
getRemoteData: () ->
$.ajax () =>
class FooView extends View
constructor: (@jquery, @model) ->
super @jquery, @model
###
# Factory Method Example in CoffeeScript
## Introduction
This example of the factory method pattern is a part of a [Tic-tac-toe](http://en.wikipedia.org/wiki/Tic-tac-toe) application. See [Wikipedia](http://en.wikipedia.org/wiki/File:Factory_Method_UML_class_diagram.svg) for the UML diagram of the factory method pattern.
This example has four classes: Grid, GridCell, Board and Space.
@zerobase
zerobase / https-proxy.js
Created September 9, 2013 10:20
[nodejitsu/node-http-proxy#Proxying to HTTP from HTTPS](https://github.com/nodejitsu/node-http-proxy#proxying-to-http-from-https)
var fs = require('fs'),
https = require('https'),
httpProxy = require('http-proxy');
var options = {
https: {
key: fs.readFileSync('path/to/your/key.pem', 'utf8'),
cert: fs.readFileSync('path/to/your/cert.pem', 'utf8')
},
target: {
@zerobase
zerobase / copy-and-paste-httpd.js
Last active December 20, 2015 08:59
A simple Node.js application which give you a secure way to copy & paste a short text between devices.
// A simple Node.js application which give you an easy insecure way to copy & paste a short text between devices.
//
// To use this app:
// 1. On your terminal, run: node copy-and-paste-httpd.js
// 2. Open http://ip-address-on-your-lan:port/ in your browser.
// 3. Paste any text and submit.
// 4. Open the same address from another device and you'll see the text.
// 5. Now you're done.
// 6. Don't forget to exit the process. It's insecure until you kill the process.