Skip to content

Instantly share code, notes, and snippets.

View masaakif's full-sized avatar

masaakif masaakif

View GitHub Profile
@masaakif
masaakif / whitelist.txt
Created October 24, 2011 06:45
This is whitelist
[BlockSite]
[My Sites]
http://money.cocokulu.jp/
https://money.cocokulu.jp/
http://github.com/
https://github.com/
http://*.github.com/
https://*.github.com/
http://*.akamai.net/
https://*.akamai.net/
@masaakif
masaakif / media_maker.user.js
Last active February 27, 2018 12:09
Add Media Maker link on Amazon page
// ==UserScript==
// @name Media Maker
// @namespace http://gist.github.com/2156093
// @description Add item to Media Maker
// @include http://*.amazon.*
// ==/UserScript==
// Version 20100312
var DEBUG=true;
@masaakif
masaakif / suginamiward_tweaks.user.js
Created March 22, 2012 04:44
Suginami Ward library tweaks
// ==UserScript==
// @name Suginami Ward Tweaks
// @namespace http://gist.github.com/2156095
// @include https://www.library.city.suginami.tokyo.jp/TOSHOW/asp/WwYoySettei.aspx*
// ==/UserScript==
tweaks();
function tweaks() {
var comboLib = document.evaluate("//select[@id='cmbUkeKan']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
comboLib.selectedIndex = 5; // 宮前
@masaakif
masaakif / amazon_calil.user.js
Created March 22, 2012 05:11
Add Calil link on Amazon page
// ==UserScript==
// @name Amazon Calil
// @namespace http://gist.github.com/2156262
// @description Show calil page from Amazon book listing
// @include http://*.amazon.*
// ==/UserScript==
var DEBUG=true;
showCalil();
function showCalil() {
@masaakif
masaakif / delUnnecessary.rb
Created March 27, 2012 03:10
ErrorReportsで始まる複数ディレクトリの中の不要なテキストファイルとZIPファイルを削除する
Dir::glob("ErrorReports*/*/*.OrderEvents.txt").each do |file|
puts "#{file} : #{File.stat(file).size}"
File::delete(file)
end
Dir::glob("ErrorReports*/*1.24.*.zip").each do |file|
puts "#{file} : #{File.stat(file).size}"
File::delete(file)
end
@masaakif
masaakif / parseCons.rb
Created April 10, 2012 11:40
ConsiderationChecks.xmlというファイルを読み込んで、要素のテキストを:区切りで印字する
require "rexml/document"
include REXML
@elem = ""
def printElem(name)
begin
print @elem.elements[name].text + ":"
rescue
# Nothing to do
end
@masaakif
masaakif / showStats.rb
Created April 10, 2012 11:45
複数のカンマ区切りのファイルを読み込んで、6番目のフィールドの平均、最大値、標準偏差、件数を表示
include Math
Dir.glob("*/*OrderEvents.Delay.csv") do |file|
i = 1
max = 0
sum = 0
File.open(file).each do |line|
delay = 0
delay = line.split(",")[5].to_i unless i == 1
sum += delay
@masaakif
masaakif / renjpg.rb
Created April 14, 2012 00:39
実行されたフォルダから再帰的にすべてのjpgファイルの名前をyyyymmdd-もとのファイル名.jpgにファイル名変更
ren = Proc.new do |tdir,ind|
puts "#{ind} #{tdir}"
Dir::foreach(tdir) do |ft|
next if /^\.+$/ =~ ft
fo = tdir + "/" + ft
if FileTest.file?(fo) then
next unless File.extname(fo).downcase == ".jpg"
ymd = File::mtime(fo).strftime("%Y%m%d")
next if File.basename(fo)[0..7] == ymd # すでに日付がついてるときは無視
fd = "#{tdir}/#{ymd}-#{ft}"
@masaakif
masaakif / zip_and_remove_rec.rb
Created April 20, 2012 08:30
複数のフォルダーを再帰的にZIPしてその後フォルダは削除する
require "zipruby"
require "fileutils"
def zip_rec(folder)
Zip::Archive.open("#{folder}.zip", Zip::CREATE) do |arc|
fd = folder
arc.add_dir(fd)
Dir.glob("#{fd}/**/*").each do |path|
if File.directory?(path)
@masaakif
masaakif / cv_pos.rb
Created May 14, 2012 12:34
カンマ区切りのファイルを読み込み、UTF16LEのタブ区切りに変える。最初のフィールドはスキップ、空のフィールドはN/Aにする。
require 'uconv' #ここ動かない
File.open(ARGV[0]).each do |line|
vals = line.gsub(/,,/,',N/A,').gsub(/,,/,',N/A,').split(',')
puts Uconv.sjistou16(vals[1..-1].join("\t"))#ここも動かない
end