Skip to content

Instantly share code, notes, and snippets.

View keiya's full-sized avatar

keiya keiya

View GitHub Profile
@keiya
keiya / README.md
Last active April 22, 2024 06:43
How to broadcast to Icecast2 by using ffmpeg (FLAC,Opus,Vorbis,AAC,MP3/Windows, Mac)

FFMpeg to Icecast2 Streaming Samples

Examples usage of various codecs with FFMpeg.

Samples

  • flac.sh : An Icecast Source Client
    • for Windows (Cygwin is required)
    • and macOS (brew install ffmpeg)
  • another_examples.sh : Samples
  • FFMpeg can push to Icecast2 in various formats: Opus/Vorbis/AAC/MP3
@keiya
keiya / pow.rb
Created January 11, 2017 14:34
Proof Of Work in Ruby // this snippet shows an example of Bitcoin "proof of work"
require 'digest/sha2'
class ProofOfWork
@charset = (" ".."~").to_a
def self.solve(target,maxlength)
for i in 1..maxlength+1
ProofOfWork.chain(ProofOfWork.product(i)) do |candidate|
hashval = Digest::SHA256.hexdigest(candidate)
if hashval.start_with?(target)
@keiya
keiya / perio_iperf.sh
Created December 25, 2016 21:01
periodical iperf
IP=127.0.0.1
PORT=443
while true
do
DATE=$(date +%s)
iperf3 -c $IP -p $PORT -J --logfile ${DATE}_forward.json
iperf3 -R -c $IP -p $PORT -J --logfile ${DATE}_reverse.json
sleep 600
done
@keiya
keiya / midi_to_wav.sh
Last active September 26, 2016 00:53
MIDI to WAV / WavPack. For extreme high audio quality, we use 64bit/32bit floating-point intermediate file.
#!/bin/bash
BANKSELECT='gm'
SF="$HOME/Timbres Of Heaven GM_GS_XG_SFX V 3.2 Final.sf2"
find "$1" -type f -iname "*.mid" -print0 | while IFS= read -r -d '' fullfile; do
file=`basename ${fullfile}`
fluidsynth -g 0.01 -o synth.midi-bank-select=$BANKSELECT -o synth.midi-channels=256 -o synth.polyphony=4096 -r 48000 -O double -F "${file}_raw.wav" "${SF}" "${fullfile}"
sox --norm=-1 "${file}_raw.wav" -b 32 -e signed-integer "${file}.wav"
rm "${file}_raw.wav" &
var di = 0.81 * temp + 0.01 * rh * (0.99 * temp - 14.3) + 46.3 ;
@keiya
keiya / separate.c
Created February 22, 2016 15:46
Split Motion-JPEG (MJPEG) Stream into JPEG files; for Syma X5SW WiFi FPV Camera. ; also included realtime streaming shell script which is using VLC.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MAX_FRAME_SIZE 256*1024 // KB
#define CONTENT_LENGTH "Content-Length: "
#define PAYLOAD "\r\n"
int main()
{
@keiya
keiya / mst.py
Last active November 9, 2015 08:53
ワークロード特性評価/クラスタリング:ミニマム・スパニング・ツリー (Minimum spanning tree; MST clustering for workload benchmarking)
import math
src_data = ((14,2735,"TKB"),
(13,253,"MAC"),
(8,27,"COBOL"),
(6,27,"BASIC"),
(6,12,"Pascal"),
(4,91,"EDT"),
(1,33,"SOS"))
@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 / 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 / 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