Skip to content

Instantly share code, notes, and snippets.

@kodaka
kodaka / graphviz.psgi
Last active July 25, 2019 07:37
Plackup Graphviz!
use Plack::Builder;
use Plack::Request;
use File::Slurp;
use File::Temp;
use MIME::Base64;
my $app = sub {
my $req = Plack::Request->new(shift);
my $res = $req->new_response(200);
@kodaka
kodaka / file2datauri.pl
Created July 30, 2013 03:48
convert file to data URI
#!/usr/bin/env perl
use strict;
use warnings;
use File::Slurp;
use MIME::Base64;
use Plack::MIME;
my $file = shift or die "usage: $0 file¥n";
my $mime = Plack::MIME->mime_type($file) or die "Cannot find MIME type for $file";
@kodaka
kodaka / bookmarklet_take_me_back.js
Created August 8, 2013 04:24
Bookmarklet, Take Me Back!
javascript:(function(){window.open('http://web.archive.org/web/*/'+location.href,'_blank')})()
@kodaka
kodaka / bookmarklet_shorten_amazon_jp_url.js
Last active December 20, 2015 20:39
Shorten Amazon.co.jp URL
javascript:(function(){alert('http://amazon.jp/dp/'+document.getElementById('ASIN').value)})()
@kodaka
kodaka / parse_query.js
Last active December 20, 2015 22:38
Parse QUERY_STRING.
// "?a=1&a=2&b=x&c=%2A&d=&=y&=&==&%2A=3&" -> Object {a: "2", b: "x", c: "*", d: "", %2A: "3"}
var q = (function(){
var q = {};
window.location.search
.substring(1)
.split('&')
.filter(function(a){
return a.indexOf('=') > 0;
})
.forEach(function(a){
@kodaka
kodaka / lame.sh
Created October 13, 2013 14:37
Nomalizing and converting to MP3.
#!/bin/bash
#
# $ ./lame.sh something.aiff
#
set -e
for FILE in "$@"; do
FACTOR=`sox $FILE -n stat -v 2>&1`
TMP=${FILE%.*}.tmp.aiff
sox -v $FACTOR $FILE -t aiff $TMP
echo "normalize $FILE with factor $FACTOR -> $TMP"
@kodaka
kodaka / requestAnimationFrame_test.html
Created December 6, 2013 03:59
JavaScript requestAnimationFrame Test, with another Interval.
<!DOCTYPE html>
<meta charset="UTF-8">
<title>requestAnimationFrame Test</title>
<div id="area" style="border:1px solid black;width:100px;height:100px"></div>
<p>Counting up backgroundly, in 120 fps. requestAnimationFrame will be activated by hover.</p>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script>
$(function(){
@kodaka
kodaka / economic_drawing_test.html
Created December 10, 2013 15:08
JavaScript economic drawing test. draw() called many times will not be actually done.
<!DOCTYPE html>
<meta charset="UTF-8">
<title>Economic Drawing Test</title>
<div id="area" style="border:1px solid black;width:200px;height:200px;"></div>
<p>Mouse-move draws X, Y, and num of drawn times.</p>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script>
$(function(){
@kodaka
kodaka / bookmarklet_revive_right_click.js
Last active January 2, 2016 11:09
The Internet needs Right-Click.
javascript:(function(){document.getElementsByTagName("body")[0].removeAttribute("oncontextmenu")})()
@kodaka
kodaka / update_application_cache.js
Last active January 2, 2016 19:09
HTML5 ApplicationCache / CacheManifest
;(function(window, confirmText){
confirmText = confirmText || "New App version found, Restart now?";
var cache = window.applicationCache;
// ApplicationCache not supported...
if (!cache) {
return;
}
// Add Listener to reload contents before updating manually.