Skip to content

Instantly share code, notes, and snippets.

View tdtds's full-sized avatar
🐱
🐱

Tada, Tadashi tdtds

🐱
🐱
View GitHub Profile
@tdtds
tdtds / pdfcompress
Created December 8, 2011 02:17
自炊PDFをKindle向け16階調グレースケールにしてサイズを小さくする
#!/bin/sh
src=`basename "$1" .pdf`
mkdir tmp
pdftk "${src}.pdf" dump_data output meta.txt
pdfimages "${src}.pdf" "tmp/${src}"
cd tmp
@tdtds
tdtds / OBSOLETE
Created January 19, 2012 10:14
renzaburo.jpにあるHTML形式の文書をまとめて青空文庫形式に
#
# This command was obsolete. see also https://github.com/tdtds/aozoragen
#
#!/usr/bin/env ruby
# -*- coding: utf-8; -*-
#
# usage: renzaburo2aozora <URL>
# URL: the index of a novel in renzaburo, only HTML version NOT Flash.
#
@tdtds
tdtds / amida.rb
Created June 2, 2012 05:48 — forked from ymorimo/amida.rb
#minatork01
#!/usr/bin/env ruby
cols = (ARGV[0] || 5).to_i - 1
rows = (ARGV[1] || 9).to_i
begin
table = (0...rows).map do |i|
(0...cols).map { rand(2) }.join
end
end until table.join =~ /1/
@tdtds
tdtds / delete_personal_document.js
Created October 26, 2012 02:21
Kindle Personal Documentの一覧に一発削除用の「×」マークを付けるBookmarklet
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('×'))})
@tdtds
tdtds / module.pp
Last active December 17, 2015 12:19
puppet内からpuppet moduleのインストールを管理する
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}",
}
#!/usr/bin/env ruby
require 'mongoid'
class Agent
include Mongoid::Document
field :guid, type: String
validates :guid, uniqueness: true
has_many :commands
end
@tdtds
tdtds / request_decompressor.rb
Last active December 23, 2015 08:29
Rack middleware of Request Decompression (gzip or deflate).
require 'zlib'
module Rack
class UnknownCompressMethod < StandardError; end
class RequestDecompressor
def initialize(app)
@app = app
end
@tdtds
tdtds / preprocess.rb
Last active December 31, 2015 10:08
BOOKSCANから送られてきたPDFに、Amazonの書影で表紙を付け、メタ情報のCreaterをScanSnapに変更するスクリプト。srcに置いて、dstに出力。
#!/usr/bin/env ruby
require 'open-uri'
require 'rexml/document'
def metainfo(isbn)
uri = 'http://rpaproxy.tdiary.org/rpaproxy/jp/'
uri << "?Service=AWSECommerceService"
uri << "&SubscriptionId=1CVA98NEF1G753PFESR2"
uri << "&Operation=ItemLookup"
// applicationCacheの更新を妨害する
Object.defineProperty(this,'applicationCache',{get:function(){return{}}});
(function () {
// AppCache上でlocation.hrefを読み込むとAppCacheの内容を読み込むため、「ブラウザは別URLと認識するが、サーバは同じコンテンツを返すURL」を作る
contentLoad(location.href+'/');
// 本来であればsubmit等のイベントもキャッチする必要がある
window.addEventListener('click', function (evn) {
var elem = evn.target;
while (elem.tagName.toLocaleLowerCase() != 'a') elem = elem.parentNode;
/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