Skip to content

Instantly share code, notes, and snippets.

View keiya's full-sized avatar

keiya keiya

View GitHub Profile
@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 / 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}")
// 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 / gist:8165245
Created December 28, 2013 22:53
Grooveshark "are you there?" canceller : automatically click the resume button!
var timer = setInterval(function(){
var $btn = $(".btn.btn-large.submit.btn-primary");
if ($btn.length > 0) {
$btn.click();
console.debug("Button clicked");
}
},1000);
@keiya
keiya / http-server.c
Created July 24, 2013 10:41
[ a simple http server ] feature: directory listing, high-throughput mmap io
#include <stdio.h> /* fprintf() */
#include <stdlib.h> /* exit() */
#include <sys/types.h> /* socket(), wait4() */
#include <sys/socket.h> /* socket() */
#include <netinet/in.h> /* struct sockaddr_in */
#include <sys/resource.h> /* wait4() */
#include <sys/wait.h> /* wait4() */
#include <pthread.h> /* pthread_create */
#include <netdb.h> /* getnameinfo() */
#include <string.h> /* strlen() */
@keiya
keiya / ipcalc.py
Created June 10, 2013 23:22
サブネット計算機
#!/usr/bin/python
# ip address util by Keiya Chinen
def binary_ip(dec_ip):
ip_l = dec_ip.split('.')
ip = (int(ip_l[0]) << 24) | (int(ip_l[1]) << 16) | (int(ip_l[2]) << 8) | int(ip_l[3])
return ip
def decimal_ip(bin_ip):
return (bin_ip >> 24, bin_ip >> 16 & 0xff, bin_ip >> 8 & 0xff, bin_ip & 0xff)
@keiya
keiya / uriparser.c
Last active December 17, 2015 18:29
URI Parser in C: hostとpathに分割するので,SocketでHTTP系の処理するときにラクだと思う. ポインタ操作のオンパレード.
typedef struct uri {
char host[REQ_HEAD_HOST_SZ];
char *path;
char *filename;
int port;
} Uri;
int
parse_uri(char uri[], Uri *parsed)
{
@keiya
keiya / http_heartbeat.py
Last active December 15, 2015 23:49
this script checks the health status of the http server periodically. health report will be write out as csv format: ISO-8601,HTTP_STATUS_CODE,RESPONSE_TIME_MICROSEC USAGE: $ python3 -u http_heartbeat.py | tee ~/hb.log
#!/usr/bin/python
import pprint,http.client,sys
from datetime import datetime
from time import sleep
if (len(sys.argv) != 2) :
print ( "Usage: python3 {0} host" .format(sys.argv[0]) )
quit()
@keiya
keiya / packspeed.pl
Last active December 15, 2015 15:08
Simple Traffic Monitor (ifconfig, perl)
#!/usr/bin/perl
# by Keiya Chinen <keiya_21@yahoo.co.jp>
use strict;
use warnings;
$ENV{'LANG'} = 'C';
$| = 1;
@keiya
keiya / SOLAR.htm
Created March 16, 2013 05:04
日の出・日の入りの計算アルゴリズム
<html><head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<style>
div#map_canvas {
width: 640px;
height: 320px;
}
</style>
<title>SOLAR</title>
</head>