Skip to content

Instantly share code, notes, and snippets.

@fireattack
fireattack / image_match.m
Last active January 1, 2019 14:44
Match image color based on a reference, and save the transformation for more images.
color_mode = 'ycbcr'; %rgb, ycbcr, hsv
work_patch = 'E:\!Scan\image match\';
ref = imread([work_patch,'ref.bmp']); % Your reference image
A = imread([work_patch,'img.bmp']); % Your scan that needs to be calibrated
numColorChan = size(ref,3);
isColor = numColorChan > 1;
@fireattack
fireattack / rename_gamecg_pack.py
Created June 26, 2017 02:36
Batch rename CG pack
import re
from os import listdir, rename, makedirs
from os.path import join, splitext, basename, exists
from urllib.parse import quote
from bs4 import BeautifulSoup as bs
from requests import get # to make GET request
def advrename(original_full_path, new_filename, c):
new_full_path = join(pathforrenamed, new_filename)
@fireattack
fireattack / ti_age.py
Last active July 7, 2018 20:52
Grab DOB of TI8 players from Liquipedia
import re
import requests
from bs4 import BeautifulSoup
url = 'https://liquipedia.net/dota2/The_International/2018'
html = requests.get(url)
html.encoding = 'utf-8'
soup = BeautifulSoup(html.text, "lxml")
divs = soup.find_all('div', class_='teamcard')
@fireattack
fireattack / normalizerms.m
Created July 1, 2017 22:34
Normalize audio signal via target RMS (in dB)
function [ y ] = normalizerms( x, targetdB )
%NORMALIZERMS Summary of this function goes here
% Detailed explanation goes here
%normalize
targetrms=10^(targetdB/20);
myrms=rms(x);
% valueDBFS = 20*log10(abs(myrms));
y=x/(myrms/targetrms);
end
filenames = {'samples/teacher/super.wav','samples/teacher/yume_deem.wav','samples/teacher/yume2005_deem.wav'};
%'samples/panic.wav','samples/super.wav', 'samples/yume.wav','samples/yume2005.wav','samples/single.mp3'
%filenames = {'old/good_rg.wav','old/bad_rg.wav'};
method = 'peri'; % peri, welch, fft, fftband
close all
for i = 1:length(filenames)
file = filenames{i};
[wave,Fs]=audioread(file);
x=(wave(:,1)+wave(:,2))/2; %Downmix
iter = 50000;
gold_result = zeros(1, iter);
gold_odd = 0.1;
initial_dust = 2000;
for method = 1:2
for i = 1:iter
bag = 0;
gold = 0;
<?xml version="1.0"?>
<Chapters>
<EditionEntry>
<ChapterAtom>
<ChapterTimeStart>00:0:00.000000000</ChapterTimeStart>
<ChapterDisplay>
<ChapterString>Opening</ChapterString>
<ChapterLanguage>jpn</ChapterLanguage>
</ChapterDisplay>
</ChapterAtom>
@fireattack
fireattack / DumpAZW6_py3.py
Last active April 3, 2024 08:01
Py3 version
#!/usr/bin/env python
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
import sys
import os, getopt, struct
import imghdr
def get_image_type(imgname, imgdata=None):
imgtype = imghdr.what(imgname, imgdata)
@fireattack
fireattack / vtt_to_srt.py
Last active August 14, 2018 07:56
Py3 requirement: chardet
import argparse
import datetime
import re
from os.path import exists, splitext, join
from os import walk
import chardet
def main():
parser = argparse.ArgumentParser()
Google Inc.
Copyright 2018 Google Inc. All rights reserved.
Google Chrome 71.0.3578.80 (Official Build) (64-bit) (cohort: 71_Win_80)
Revision 2ac50e7249fbd55e6f517a28131605c9fb9fe897-refs/branch-heads/3578@{#860}
OS Windows
JavaScript V8 7.1.302.28
Flash 32.0.0.101 C:\Windows\system32\Macromed\Flash\pepflashplayer64_32_0_0_101.dll
User Agent Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.80 Safari/537.36
Command Line "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --flag-switches-begin --disable-accelerated-video-decode --load-media-router-component-extension=0 --disable-smooth-scrolling --flag-switches-end