Skip to content

Instantly share code, notes, and snippets.

@autch
autch / find_bom.c
Created August 26, 2015 01:34
find -name \*.java | xargs find_bom
#include <errno.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#define UTF8_BOM "\xef\xbb\xbf"
#define UTF16BE_BOM "\xfe\xff"
#define UTF16LE_BOM "\xff\xfe"
#define UTF7_BOM "\x2b\x2f\x76"
@autch
autch / gist:11277712
Created April 25, 2014 04:29
パートのまとめ書きや AAA BBB でなく A/B A/B A/B の形式で書くとバグる MML コンパイラ(ie. mucc for P/ECE)のためにパート記述を変換
#!/usr/bin/env ruby
# -*- encoding: utf-8; -*-
RE_PART = /^([A-Z]+)\s?(.*)$/
filename = ARGV.shift
File.open(filename, "rb:Shift_JIS") do |file|
while line = file.gets do
line.chomp!
@autch
autch / strip_block.rb
Created April 28, 2014 01:11
Liquid version of Smarty's {strip} tag
class Strip < Liquid::Block
def initialize(tag_name, markup, tokens)
super
end
def render(context)
super.split(/\r?\n/).map{|line| line.strip }.join("")
end
end
diff --git a/config.ru b/config.ru
index 0b174f0..0ae477e 100644
--- a/config.ru
+++ b/config.ru
@@ -6,7 +6,7 @@ require 'sinatra'
set :environment, ENV["RACK_ENV"].to_sym
disable :run, :reload
-require_relative "irclog_app"
+require "./irclog_app"
#include <errno.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#define ATTR_PACKED __attribute__((packed))
#define P_DAT_SIGNATURE "GAMEDAT PAC2"
@autch
autch / gist:37359785f53dec860a81
Created July 21, 2014 07:43
epgrecの番組DBから直近7日分のアニメを検索
SELECT
p.id,
p.starttime,
p.endtime,
ch.name,
p.title,
p.description
FROM
Recorder_programTbl p,
Recorder_categoryTbl cat,
@autch
autch / gist:71ca11d0368a812262f6
Created September 5, 2014 00:53
Twitpicの /photos/<ユーザ名> ページから画像のURLリストを取得してくるBookmarklet
javascript:$("<textarea>").val($(".user-photo a img").map(function(i,e){return $(e).attr("src").replace(/photos\/thumb/, "photos/large");}).get().join("\r\n")).prependTo($(".sidebar-section"))
@autch
autch / gf-proxy.rb
Created September 6, 2014 16:30
ガールフレンド(仮)の画像をゲフンゲフンするためのプロキシ
#!/usr/bin/env ruby
# -*- encoding: utf-8; -*-
require 'rubygems'
require 'webrick'
require 'webrick/httpproxy'
require 'uri'
OPTIONS = {
:BindAddress => '0.0.0.0',
@autch
autch / GoAwayCaps.reg
Created December 4, 2014 03:13
Make CapsLock second Control
REGEDIT4
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00
@autch
autch / proclog.rb
Created December 22, 2014 01:44
procmail.log のエンコードをはずす
#!/usr/bin/env ruby
require 'nkf'
RE_SUBJECT = /^\s*Subject: (.*)$/i
RE_ENC = /=\?(.*?)\?([bBqQ])\?(.*)(\?=)?/
while line = ARGF.gets do
line.chomp!