Skip to content

Instantly share code, notes, and snippets.

# Search shell history with peco: https://github.com/peco/peco
# Adapted from: https://github.com/mooz/percol#zsh-history-search
if which peco &> /dev/null; then
function peco_select_history() {
local tac=$( \
(which gtac &> /dev/null && echo -n "gtac") || \
(which tac &> /dev/null && echo -n "tac") || \
echo -n "tail -r" \
)
BUFFER=$(fc -l -n 1 | eval $tac | \
@tarot
tarot / map_values.coffee
Last active August 29, 2015 14:12
map values for underscore.js
_.mixin
map_values: (obj, iteratee, context) ->
iteratee = @iteratee iteratee, context
@object @map obj, (v, k, o) -> [k, iteratee(v, k, o)]
@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
@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_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 / 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
<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 / 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
@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 / .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