Skip to content

Instantly share code, notes, and snippets.

View diewland's full-sized avatar
🧩
Jigsaw Fam

diewland.eth diewland

🧩
Jigsaw Fam
View GitHub Profile
@diewland
diewland / split_mp3_to_flac_files.py
Last active August 14, 2018 08:38
Split stereo mp3 to mono flac files
import os, sys
from pydub import AudioSegment
filepath = sys.argv[1]
filename, ext = os.path.splitext(filepath)
flacname = "%s.flac" % filename
song = AudioSegment.from_mp3(filepath)
song = song.set_frame_rate(16000)
song = song.set_channels(1)
@diewland
diewland / check_dup_filesize.py
Last active August 7, 2018 04:09
Check duplicate file size
import os
import sys
from pprint import pprint as pp
path = sys.argv[1]
size_dict = {}
for _, _, files in os.walk(path):
for f in files:
size = os.path.getsize("%s/%s" % (path, f))
@diewland
diewland / wav2flac.py
Last active February 5, 2023 10:37
convert wav to flac from python
from os.path import splitext
from pydub import AudioSegment
def wav2flac(wav_path):
flac_path = "%s.flac" % splitext(wav_path)[0]
song = AudioSegment.from_wav(wav_path)
song.export(flac_path, format = "flac")
if __name__ == "__main__":
import sys
@diewland
diewland / Vagrantfile
Last active July 31, 2018 10:44
my Vagrantfile
Vagrant.configure("2") do |config|
...
# proxies
# vagrant plugin install vagrant-proxyconf
if Vagrant.has_plugin?("vagrant-proxyconf")
config.proxy.http = "http://your.proxy.host:8080/"
config.proxy.https = "http://your.proxy.host:8080/"
config.proxy.no_proxy = "localhost,127.0.0.1"
@diewland
diewland / gb.bat
Created July 11, 2018 11:48
show git branch in windows command prompt
@echo off
set GITBRANCH=
for /f "tokens=2" %%I in ('git.exe branch 2^> NUL ^| findstr /b "* "') do set GITBRANCH=%%I
if "%GITBRANCH%" == "" (
prompt $P$G
) else (
prompt $P $C$E[10;7;32;47m%GITBRANCH%$E[0m$F $G
)
@diewland
diewland / pyunzip.py
Last active July 4, 2018 03:38
Unzip with python
#!/usr/bin/env python3
import sys
from zipfile import PyZipFile
for zip_file in sys.argv[1:]:
pzf = PyZipFile(zip_file)
pzf.extractall()
@diewland
diewland / rotate_log.sh
Created June 18, 2018 05:43
Rotate log batch script
ps aux | grep 'app.py' | grep -v grep | awk '{print "kill -9 " $2}' | sh
mv app.log app.log.$(date -d "today" +"%Y%m%d%H%M%S")
source ../venv/bin/activate
python app.py &> app.log &
@diewland
diewland / dialogflow.txt
Created May 21, 2018 10:12
Dialogflow Yes-No template
okay
of course
i don't mind
do it
ok
sounds good
confirm
that's correct
I agree
yes
@diewland
diewland / foo.log
Created December 23, 2017 04:52 — forked from ibeex/foo.log
Flask logging example
A warning occurred (42 apples)
An error occurred
@diewland
diewland / add_tag_to_word.js
Created December 15, 2017 04:53
Automatic add tag to specific words
'hello my name is diewland'.replace(/(diewland|name)/g, "<span class='hl'>$&</span>")
// "hello my <span class='hl'>name</span> is <span class='hl'>diewland</span>"