Skip to content

Instantly share code, notes, and snippets.

View keiya's full-sized avatar

keiya keiya

View GitHub Profile
// BrainFsck Ruby Extension by Keiya CHINEN <s1011420@coins.tsukuba.ac.jp>
// C extension and Ruby src was written by Keiya CHINEN <s1011420@coins.tsukuba.ac.jp>
// Original version (Pure-C): https://github.com/keiya/brainfuck
#include "ruby.h"
#include <stdio.h>
#include <stdlib.h>
char *prog;
int ary[30000];
@keiya
keiya / audio_convert.bash
Created January 31, 2015 19:29
multiple wav/aiff audio file to ogg/flac/he-aac v2 converter.
#!/bin/bash
# usage:
# bash audio_convert.bash ORIGINAL_FILEs_PATH DESTINATION_PATH
find $1 -type f -iname '*.wav' -print0 | while IFS= read -r -d '' fullfile; do
#printf '%s\n' "$fullfile"
file=$(basename "${fullfile}")
@keiya
keiya / content_script.js
Last active August 29, 2015 14:20
Chrome Extension / Generate a M3U or XSPF playlist from HTML <a> links. Useful for playing audios/movies on a HTTP server.
$(document).ready(function(){
var exts = ["aif","avi","flac","m4a","mkv","mov","mp3","mp4","ogg","ogv","opus","wav"];
var m3u = "";
for (var i = 0; i < $('a').size(); ++i) {
var $uri = $('a').eq(i);
var absuri = $uri.attr('href');
var available_format = false;
@keiya
keiya / extract_and_replace.bash
Created May 22, 2015 11:50
Progressive extractor of compressed files (arc, zip, lzh, 7z, rar); requires unar (The UNARchiver); tested on Windows 8.1
#!/bin/bash
UNAR='/cygdrive/d/apps/unar/unar.exe'
find "$1" -type f \( -iname "*.lzh" -o -iname "*.arc" -o -iname "*.zip" -o -iname "*.7z" -o -iname "*.rar" \) -print0 | while IFS= read -r -d '' fullfile; do
fullpath=$(readlink -f "${fullfile}")
fulldir=$(dirname "${fullfile}")
$UNAR -t -o "${fulldir}" "${fullfile}" && rm -f "${fullfile}"
done
@keiya
keiya / recursive_image_converter.bash
Created June 6, 2015 13:10
compress large uncompressed or lossless format into compressed/lossy format. // powered by imagemagick
#!/bin/bash
CONV='/usr/bin/convert.exe'
#find "$1" -type f \( -iname "*.bmp" \) -print0 | while IFS= read -r -d '' fullfile; do # BMP->PNG (Lossless)
find "$1" -type f \( -iname "*.bmp" -o -iname "*.png" \) -print0 | while IFS= read -r -d '' fullfile; do # any Lossless to Lossy JPEG
#$CONV "${fullfile}" "${fullfile}.png" && rm -f "${fullfile}" # BMP->PNG (Lossless)
$CONV -quality 80 "${fullfile}" "${fullfile}.jpg" && rm -f "${fullfile}" # any Lossless to Lossy JPEG
done
@keiya
keiya / content_script.js
Last active August 29, 2015 14:24
fiver (Google Chrome Extension): [instant play & preview audios] Play instantly music/voices on the web page without download it. / work with <a> links (audio files) / GAPLESS playback, Preview Audio (55sec or 55%) / supported formats: "aif","m4a","mp3","ogg","opus","wav"
function eschtml(body) {
return jQuery('<div>').text(body).html();
}
$(document).ready(function(){
var exts = ["aif","m4a","mp3","ogg","opus","wav"];
var queue = [];
var current = {};
@keiya
keiya / gist:583900
Created September 17, 2010 08:02
Univ. of Tsukuba WLAN Auth Script
#!/usr/bin/perl
use strict;
use LWP::UserAgent;
use HTTP::Request::Common qw(POST);
# リクエストの生成
my $url = 'https://wlan-auth1.cc.tsukuba.ac.jp/login.html';
my %formdata = ('buttonClicked' => '4','username' => 'YOUR_ID', 'password' => 'YOUR_PASSWORD');
my $request = POST($url, [%formdata]);
@keiya
keiya / destroyTwitterPosts
Created September 17, 2010 08:09
Delete your twitter posts
#!/usr/bin/perl
# Cf. http://d.hatena.ne.jp/famnet/20100917/1284711061
use strict;
use warnings;
use lib './lib';
use LWP;
use LWP::ConnCache;
use Net::Twitter;
@keiya
keiya / brainfsck.rb
Created October 3, 2010 12:44
brainfsck, the compatible of brainfuck (ruby)
#!/usr/bin/ruby
# 言語仕様: http://wiki.keiyac.org/index.pl?page=Brainfsck
$KCODE = "UTF8"
$ptr = 0
$tkn_ptr = 0
$token = []
@keiya
keiya / rmbf
Created November 11, 2010 02:00
remove the backup(swap) files of vim, gedit / usage: rmbf -d
#!/usr/bin/perl
use strict;
use warnings;
use Cwd;
# rmbf version 1.0.1
# Remove backup files
# Written by Keiya CHINEN