Skip to content

Instantly share code, notes, and snippets.

View makotom's full-sized avatar
👋
Huomiseen. Bye.

Makoto Mizukami makotom

👋
Huomiseen. Bye.
View GitHub Profile
@makotom
makotom / cue2aac
Created October 6, 2012 12:14
Create MPEG-4 Audio files from CUE sheet music
#!/bin/bash
if [ $# -lt 1 ]
then
exit
fi
cue_file=$1
wav_file=$(cat $cue_file | grep FILE | sed -e "s/^FILE \"\(.*\)\".*$/\1/")
cuebreakpoints "$cue_file" | shntool split "$wav_file"
@makotom
makotom / cue.js
Created December 11, 2012 12:16
Add song metadata to a cue sheet using XML from Musicbrainz
(function(){
var document = require("jsdom").jsdom(require("fs").readFileSync(process.argv[2])),
cue = require("fs").readFileSync(process.argv[3]).toString().split("\n"),
discTitle = document.getElementsByTagName("release")[0].getElementsByTagName("title")[0].textContent, artists = "", titles = [],
medium = document.getElementsByTagName("medium"),
tracks, credits, discNo = process.argv.length > 4 ? parseInt(process.argv[4], 10) - 1 : 0, i = 0, j = 0;
if(medium.length > 1){
discTitle += " (Disc " + (discNo + 1).toString() + ")";
@makotom
makotom / NetworkObj.js
Created December 19, 2012 21:40
OU-EEI exp-b3-d3
exports.NetworkObj = function(){
var NetworkObj = function(){
this.connections = [];
this.spaces = this.getInitSpaces();
};
NetworkObj.prototype = (function(){
var edges = [];
require("fs").readFileSync("distance.txt").toString().replace(/\r/, "").split("\n").forEach(function(row){
var values = row.split(" "),
<?php
define("RDIR", (isset($_SERVER["HTTPS"]) ? "http://" : "https://") . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "?t");
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: x-prototype-version,x-requested-with");
if(isset($_GET["r"])){
header("Location: " . RDIR);
exit();
}
@makotom
makotom / netspeed.php
Last active December 12, 2015 06:39
Useless network speed tester
<?php
define("TESTFILE", "zero");
if(isset($_GET["d"])){
readfile(TESTFILE);
exit();
}else if(isset($_GET["n"])){
exit();
}
?>
<!doctype html>
@makotom
makotom / homev6.sh
Created February 12, 2013 13:03
Helper script to launch v6 over v4 and radvd sequentially
#!/bin/bash
ETH="p1p1"
NET6SCRPATH="/usr/local/bin/iij-ipv6-up"
$NET6SCRPATH
NET6PREFIX=$(ip -6 addr show dev ppp128 scope global | grep inet6 | sed -e s/^\ \*inet6\ //g -e s/\ .\*\$//g -e s/\\\(:[0-9a-f]*\\\)\\{4\\}\\/64//g)"::/64"
sysctl net.ipv6.conf.all.forwarding=1
@makotom
makotom / isbn.js
Last active March 10, 2019 14:44
ISBN tools by JS
var ISBN = (function(){
"use strict";
var validateISBN13 = function(isbnChars){
var checksum = 0;
isbnChars.forEach(function(isbnChar, key){
checksum += parseInt(isbnChar, 10) * (key % 2 === 1 ? 3 : 1);
});
@makotom
makotom / gist:5692789
Created June 2, 2013 06:07
Objective JS?
(function(){
var TestType = function(num){
var target = {},
internal = {num10 : num * 10};
target.firstProp = internal.num10.toString();
target.firstMethod = function(){ console.log("The first method: " + target.firstProp); };
return target;
},
@makotom
makotom / iij-ipv6-up.sh
Last active December 17, 2015 23:58
Old script to start IIJmio's IPv6
#!/bin/sh
sed -i -e "/nameserver 2001:240:.*$/d" /etc/resolv.conf
iter=0
until nc ipv6a.2iij.net 1723 < /dev/null > /dev/null 2>&1
do
iter=$(expr $iter + 1)
if [ $iter -gt 30 ]
@makotom
makotom / http.js
Created June 2, 2013 06:31
HTTP request wrapper for Node.js and its showcase
var HttpSimpleRequest = function(){
var http = require("http"), https = require("https"),
target = {},
getProperProtocol = function(param){
var testee = "";
if(typeof param === typeof ""){
testee = param.toString();