Skip to content

Instantly share code, notes, and snippets.


Tada, Tadashi tdtds

View GitHub Profile
View tdiary-hikidoc2markdown.rb
#!/usr/bin/env ruby
# Convert tDiary's documents from HikiDoc to Markdown
# Copyright (C) Tada, Tadashi <>
require 'open-uri'
require 'nokogiri'
require 'cgi'
tdtds /
Last active Aug 29, 2015
PicasaWeb APIのOAuthがうまく使えないメモ


  • 従来パスワード認証で使っていたpicasa gemを使いたい(OAuth対応してると書いてある)
  • アルバム作成、指定アルバムへの画像追加がしたい


  • Google Developers Consoleでプロジェクトをひとつ作成
  • そのプロジェクトの「認証情報」でサービスアカウントを追加、ここでメールアドレス「」を得る
  • P12キーを生成してダウンロード(test.p12)
  • picasa gemに加えてgoogle-api-client gemをインストール
  • (以下はgoogle-api-clientとpicasaをrequireしたpry上で作業)
View mkmf.log
package configuration for libffi is not found
have_header: checking for ffi.h... -------------------- no
"gcc -E -I../../.ext/include/x86_64-linux -I../.././include -I../.././ext/fiddle -I/home/sho/.rbenv/versions/2.2.0/include -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat conftest.c -o conftest.i"
conftest.c:3:17: fatal error: ffi.h: No such file or directory
compilation terminated.
checked program was:
/* begin */
1: #include "ruby.h"
View ruby-build.20141225191028.7198.log
/tmp/ruby-build.20141225191028.7198 ~/tmp
/tmp/ruby-build.20141225191028.7198/ruby-2.2.0 /tmp/ruby-build.20141225191028.7198 ~/tmp
config.guess already exists
config.sub already exists
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
View gist:425df48f99023edc0e73
// applicationCacheの更新を妨害する
(function () {
// AppCache上でlocation.hrefを読み込むとAppCacheの内容を読み込むため、「ブラウザは別URLと認識するが、サーバは同じコンテンツを返すURL」を作る
// 本来であればsubmit等のイベントもキャッチする必要がある
window.addEventListener('click', function (evn) {
var elem =;
while (elem.tagName.toLocaleLowerCase() != 'a') elem = elem.parentNode;
tdtds / preprocess.rb
Last active Dec 31, 2015
View preprocess.rb
#!/usr/bin/env ruby
require 'open-uri'
require 'rexml/document'
def metainfo(isbn)
uri = ''
uri << "?Service=AWSECommerceService"
uri << "&SubscriptionId=1CVA98NEF1G753PFESR2"
uri << "&Operation=ItemLookup"
tdtds / request_decompressor.rb
Last active Dec 23, 2015
Rack middleware of Request Decompression (gzip or deflate).
View request_decompressor.rb
require 'zlib'
module Rack
class UnknownCompressMethod < StandardError; end
class RequestDecompressor
def initialize(app)
@app = app
View mongoid_test.rb
#!/usr/bin/env ruby
require 'mongoid'
class Agent
include Mongoid::Document
field :guid, type: String
validates :guid, uniqueness: true
has_many :commands
tdtds / module.pp
Last active Dec 17, 2015
puppet内からpuppet moduleのインストールを管理する
View module.pp
define puppet::module(
$ensure = installed,
$module = regsubst($name, '^.*?-(.*)$', '\1')
if $ensure == installed {
exec { "install":
path => ['/bin', '/usr/local/bin'],
command => "puppet module install ${name}",
creates => "/etc/puppet/modules/${module}",
tdtds / delete_personal_document.js
Created Oct 26, 2012
Kindle Personal Documentの一覧に一発削除用の「×」マークを付けるBookmarklet
View delete_personal_document.js
javascript:jQuery('span.headerStatus').each(function(){var e=jQuery(this);e.append(jQuery('<a>').attr('href',e.attr('id').replace(/^Row.*_/,'javascript:Fion.deleteItem("deleteItem_')+'");return false;').text('×'))})
You can’t perform that action at this time.