Skip to content

Instantly share code, notes, and snippets.

View st63jun's full-sized avatar

Jun SAITO st63jun

View GitHub Profile
@st63jun
st63jun / delete_personal_document.js
Created October 26, 2012 15:44 — forked from tdtds/delete_personal_document.js
Kindle Personal Documentの一覧に一発削除用の「×」マークを付けるBookmarklet
javascript:jQuery('span.headerStatus').each(function(){var%20e=jQuery(this);e.append(jQuery('<a>').attr('href',e.attr('id').replace(/^Row.*_/,'javascript:Fion.deleteItem("deleteItem_')+'");').text('%C3%97'))});void(0)
@st63jun
st63jun / tree.rb
Created November 6, 2012 03:43
7つの言語7つの世界 Ruby2日目
class Tree
attr_accessor :children, :node_name
def initialize(tree)
@node_name = tree.keys.first
@children = []
tree.values.first.each do |name, children|
@children << Tree.new({name => children})
end
end
@st63jun
st63jun / SpeedResult.local
Created November 8, 2012 06:16
SpeedResult
Io localAccesses := 15.28
Io localSets := 7.48
Io slotAccesses := 7.14
Io slotSets := 3.62
Io blockActivations := 0.47
Io instantiations := 0.89
Io cfuncActivations := 13.01
@st63jun
st63jun / Utils.java
Created November 13, 2012 07:36
byte[]からjava.util.UUIDを作る
public static UUID fromByteArray(byte[] ary) {
if (ary.length < 16)
throw new IllegalArgumentException("array length must be >= 16");
long msb = 0;
long lsb = 0;
for (int i=0; i<8; i++)
msb = (msb << 8) | (ary[i] & 0xff);
for (int i=8; i<16; i++)
lsb = (lsb << 8) | (ary[i] & 0xff);
return new UUID(msb, lsb);
@st63jun
st63jun / convert_utf8.rb
Created November 19, 2012 07:40
JavaのコードをUTF-8に一括変換
require 'nkf'
# UTF-8とCP932がソースツリーに混在して頭がおかしくなりそうだったのでやっつけスクリプト書いた
# あとでまた使うかもしれないからgistにメモしておく
def mkdir_p(path, mode = 0700)
return if Dir.exist?(path)
parent = File.dirname(path)
mkdir_p(parent, mode) unless Dir.exist?(parent)
Dir.mkdir(path, mode)
@st63jun
st63jun / edt_test.groovy
Created November 27, 2012 07:27
SwingBuilderではSwingBuilder.edt()の中で書く必要がある
import groovy.swing.SwingBuilder
import javax.swing.SwingUtilities
def testEDT() {
new SwingBuilder().frame() {
if (SwingUtilities.isEventDispatchThread())
println("I'm in EDT!")
else
println("I'm NOT in EDT!")
}
@st63jun
st63jun / init.el
Created November 29, 2012 20:51
Emacsニュービー向けinit.el
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Emacs設定ファイル
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 起動後は untitled という名前のバッファを開く
(setq initial-scratch-buffer nil)
(setq initial-buffer-choice (switch-to-buffer "untitled"))
;; パッケージシステムの設定
(require 'package)
@st63jun
st63jun / line.sh
Created December 6, 2012 09:20
コメントを抜いたJavaソースの行数を数える
cat `find . -name "*.java" -print` | sed -e '/¥/¥*/,/¥*¥//d' -e '/^[[:blank:]]*¥/¥/.*$/d' -e '/^[^[:graph:]]*$/d' | wc -l
@st63jun
st63jun / citmenu.rb
Last active December 12, 2015 04:18
学食のメニュー取得するやつ
#!env ruby
# -*- coding: utf-8 -*-
# Copyright (C) 2013 Jun SAITO <jsaito@xopowo.info>
#
# This is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
@st63jun
st63jun / girlfriend.psgi
Last active December 13, 2015 18:28
Proxy adds X-Girlfriend-Wanted header
use strict;
use warnings;
use Plack::Builder;
use Plack::App::Proxy;
builder {
enable 'Proxy::AddVia';
enable sub {
my $app = shift;
return sub {