Skip to content

Instantly share code, notes, and snippets.

@f440
f440 / zaw.rb
Last active August 29, 2015 13:57
brew install ./zaw.rb --HEAD
require 'formula'
class Zaw < Formula
homepage 'https://github.com/zsh-users/zaw'
head 'https://github.com/zsh-users/zaw.git'
def install
(share/'zaw').install Dir['*']
end
@f440
f440 / pinboard_to_elasticsearch.rb
Created February 16, 2014 10:34
Import to ElasticSearch from Pinboard
#!/usr/bin/env ruby
require 'rexml/document'
require 'elasticsearch'
doc = REXML::Document.new(open(ARGV[0]).read)
es = Elasticsearch::Client.new log: true
doc.elements.each('/posts/post') do |element|
# attributes: [href, time, description, extended, tag, hash, shared]
@f440
f440 / config.ru
Created December 20, 2013 07:43
forwardable
require 'sinatra/base'
require 'forwardable'
class I18n
def self.t(s); "I18n.t(#{s})"; end
def self.l(s); "I18n.l(#{s})"; end
end
class App < Sinatra::Base
extend Forwardable
@f440
f440 / app.rb.diff
Created November 10, 2013 08:08
アクション別アクセスカウンタ(Redis版)
diff --git a/qualifier/webapp/ruby/app.rb b/qualifier/webapp/ruby/app.rb
index 4d64f98..0a45adf 100644
--- a/qualifier/webapp/ruby/app.rb
+++ b/qualifier/webapp/ruby/app.rb
@@ -8,6 +8,7 @@ require 'erubis'
require 'tempfile'
require 'redcarpet'
require 'rack/perftools_profiler'
+require 'redis'
@f440
f440 / Gemfile
Created August 18, 2013 07:48
Sphinx utilities
source 'https://rubygems.org'
gem 'guard-livereload'
gem 'guard-shell'
gem 'rb-fsevent'
gem 'foreman'
gem 'terminal-notifier-guard'
function zaw-src-hg-files() {
hg root >/dev/null 2>&1
if [[ $? == 0 ]]; then
candidates=("${(ps:\0:)$(hg status -cman0)[1,-2]}")
fi
actions=("zaw-callback-edit-file" "zaw-callback-append-to-buffer")
act_descriptions=("edit file" "append to edit buffer")
options=("-m")
}
# -*- sh -*-
zmodload zsh/parameter
function zaw-src-gisty() {
candidates=("${(ps:\n:)$(gisty list)}")
actions=("zaw-callback-gisty-append-to-buffer")
act_descriptions=("append to edit buffer")
}
zaw-register-src -n gisty zaw-src-gisty
# -*- sh -*-
# [pbl](https://github.com/glidenote/pbl)
# A command line tool for Pinboard to search your bookmarks.
# [zaw](https://github.com/zsh-users/zaw)
# zsh anything.el-like widget.
function zaw-src-pbl() {
local username=$(ruby -rpit -e 'puts Pit.get(:pinboard)[:username]')
local password=$(ruby -rpit -e 'puts Pit.get(:pinboard)[:password]')
@f440
f440 / _pbl
Created October 4, 2012 15:57
#compdef pbl
_arguments "1:first:($(curl -s https://$pinboard_username:[email protected]/v1/tags/get | grep tag= | sed -Ee 's/.*tag=\"(.*)\".*/\1/'))"
# -*- sh -*-
# [pbl](https://github.com/glidenote/pbl)
# A command line tool for Pinboard to search your bookmarks.
# [zaw](https://github.com/zsh-users/zaw)
# zsh anything.el-like widget.
function zaw-src-pbl() {
username=$(ruby -rpit -e 'puts Pit.get(:pinboard)[:username]')
password=$(ruby -rpit -e 'puts Pit.get(:pinboard)[:password]')