Skip to content

Instantly share code, notes, and snippets.

@tarot
tarot / Amazon URL Shortener
Last active December 11, 2015 02:58
Amazonの商品ページのURLを短くするBookmarklet
javascript:(function(){var asin,_,_ref;_ref=location.pathname.match(/(?:\/dp\/|\/gp\/product\/|\/asin\/)([^\/]+)/i),_=_ref[0],asin=_ref[1];if(asin!=null){return history.replaceState("","","/dp/"+asin+"/")}})();
#!/bin/bash
seq 0 10 | {
declare -i sum
while read num ; do
let sum+=$num
done
# bash => 55 (^^)v
# zsh => 55
@tarot
tarot / .zshrc
Last active December 21, 2015 08:19
history-beginning-search-*-endにCtrl+P/Nを割り当てると、zstyleでCtrl+P/Nが効かなくなる
HISTFILE=~/.zsh_history
HISTSIZE=100000
SAVEHIST=10000
autoload -Uz compinit
compinit
zstyle ':completion:*:default' menu select=2
bindkey "^[[Z" reverse-menu-complete
autoload -Uz history-search-end
@tarot
tarot / kindle_search.rb
Last active December 22, 2015 13:48
Kindle検索のクエリパラメータのメモ
require 'nokogiri'
require 'open-uri'
=begin
パラメータ:
node: ジャンル。例: 2293143051=コミック, 2275256051=本, 2292700051=SF/ホラー/ファンタジー
field-releasedate: 発売日の範囲。nxはn日前、nyはn日後らしい。
例: "0x-0x"=今日, "1x-1y"=昨日から明日, "0x-"=今日以降, "-0x"=今日以前
発売日未設定の本は無限に昔の扱いらしい。"-1000000x"とかやるとヒットする。
page: 最大400(19200件)まで。400ページを超えた場合、401以上は400と同じ結果になる。
@tarot
tarot / cookie_validation.rb
Last active August 29, 2015 14:08
monkey patch for cookiejar 0.3.2 to correct domain-matching algorithm. see: http://tools.ietf.org/html/rfc6265#section-5.1.3
<b:if cond='data:blog.isMobile'>
<script>
(function() {
var el = document.querySelector('#main');
el.__addEventListener = el.addEventListener;
el.addEventListener = function(type) {
if (!type.match(/^touch/)) {
this.__addEventListener.apply(this, arguments);
}
};
@tarot
tarot / csp.txt
Created December 20, 2014 14:19
Lightning ApplicationのCSP (https://ap0.lightning.force.com, 2014-12-20)
Content-Security-Policy: default-src 'self'; script-src 'self' https://ssl.gstatic.com/accessibility/ chrome-extension: 'unsafe-eval' 'unsafe-inline'; object-src 'self'; style-src 'self' chrome-extension: 'unsafe-inline'; img-src http: https: data:; media-src 'self'; frame-src https:; font-src https: data:; connect-src 'self'; report-uri /_/csp
@tarot
tarot / datapatch_sample.coffee
Last active August 29, 2015 14:12
jsforceを使ってデータパッチするサンプル。そのままだとContact.LastName = Contact.LastName + Contact.Nameになっちゃうよ!
jsforce = require 'jsforce'
Promise = require 'bluebird'
streamify = require 'stream-array'
csv = require 'csv'
fs = require 'fs'
program = require 'commander'
program
.option '-d, --deploy', 'deploy'
.parse process.argv
@tarot
tarot / package.json
Last active August 29, 2015 14:12 — forked from yusuke8609/package.json
{
"name": "retrieve_folders",
"dependencies": {
"bluebird": "^2.4.2",
"dotenv": "^0.4.0",
"jsforce": "^1.3.1",
"underscore": "^1.7.0",
"unzip": "^0.1.11"
}
}
@tarot
tarot / datapatch_stream_sample.coffee
Last active August 29, 2015 14:12
streamってこんなかんじ?
jsforce = require 'jsforce'
Promise = require 'bluebird'
streamify = require 'stream-array'
csv = require 'csv'
fs = require 'fs'
program = require 'commander'
program
.option '-d, --deploy', 'deploy'
.parse process.argv