Skip to content

Instantly share code, notes, and snippets.

View enamoria's full-sized avatar
💭
vohox

Kính Phan enamoria

💭
vohox
  • Viet Nam
View GitHub Profile
@enamoria
enamoria / error_scarlette_chrome.sh
Last active November 6, 2021 22:10
Fix chrome and firefox cannot play sound with external audio interface in between, even though they can recognize the interface
# Source https://askubuntu.com/a/668329/646308
killall pulseaudio
rm -r ~/.config/pulse/*
rm -r ~/.pulse*
# IF NOT WORK: MAY BE A DAW IS TAKING OVER THE CONTROL OF THE OUTPUT
# INSTALL pavucontrol-module-jack. Check the link below
# SOURCE: https://askubuntu.com/a/681079/646308 ######################
# FINAL RESORT: WORKED WITH REAPER + SCARLETTE 2i2 + UBUNTU 20.04
@enamoria
enamoria / .inputrc
Created December 31, 2019 03:20
use `vi` mode in bash (jk for up and down, no more arrow key)
# edit ~/.inputrc
# want vi to be the default editor for readline
set editing-mode vi
# vi settings
$if mode=vi
# normal mode
set keymap vi-command
"j": previous-history
@enamoria
enamoria / NlpUtils.java
Created October 10, 2019 09:13 — forked from behitek/NlpUtils.java
Chuẩn hóa cách gõ dấu câu về kiểu gõ cũ
/*
Copyright @ nguyenvanhieu.vn
Thằng code java này vẫn giữ được lower/upper case
Code này ngon hơn, check đúng trường hợp cần thêm dấu thì mới thêm
Tuy nhiên code python ở dưới không check nhưng vẫn chưa thấy bugs nào hết :v
*/
package utils;
import java.util.*;
@enamoria
enamoria / frequency_estimator.py
Created August 21, 2019 03:09 — forked from endolith/frequency_estimator.py
Frequency estimation methods in Python
from __future__ import division
from numpy.fft import rfft
from numpy import argmax, mean, diff, log, nonzero
from scipy.signal import blackmanharris, correlate
from time import time
import sys
try:
import soundfile as sf
except ImportError:
from scikits.audiolab import flacread
#WINE with error (OLE error 80040154)
wget http://winetricks.org/winetricks
chmod +x winetricks
winetricks -v vcrun6 winetricks -v msxml4
@enamoria
enamoria / .ideavimrc
Created December 18, 2018 04:38
IdeaVim configuration: .ideavimrc
nnoremap <S-Left> :action EditorLeftWithSelection<CR>
nnoremap <S-Right> :action EditorRightWithSelection<CR>
nnoremap <S-Up> :action EditorUpWithSelection<CR>
nnoremap <S-Down> :action EditorDownWithSelection<CR>
inoremap <S-Left> <C-O>:action EditorLeftWithSelection<CR>
inoremap <S-Right> <C-O>:action EditorRightWithSelection<CR>
inoremap <S-Up> <C-O>:action EditorUpWithSelection<CR>
inoremap <S-Down> <C-O>:action EditorDownWithSelection<CR>
@enamoria
enamoria / useful_bash.sh
Last active July 3, 2019 03:51
Sweet bashscript o' mine
# copy a list of file (from file_id_list) from src to dest
cat file_id_list | awk '{system("cp " $1 " <dest_dir")}'
# total time of audio file within a directory
soxi -D *.wav | awk '{sum+=$1} END {print sum}'
@enamoria
enamoria / dataframe_reduce_memory.py
Created October 17, 2018 03:32
Reduce pandas dataframe memory usage
# This function is used to reduce memory of a pandas dataframe
# The idea is cast the numeric type to another more memory-effective type
# For ex: Features "age" should only need type='np.int8'
# Source: https://www.kaggle.com/gemartin/load-data-reduce-memory-usage
def reduce_mem_usage(df):
""" iterate through all the columns of a dataframe and modify the data type
to reduce memory usage.
"""
start_mem = df.memory_usage().sum() / 1024**2
print('Memory usage of dataframe is {:.2f} MB'.format(start_mem))
@enamoria
enamoria / specshow.py
Created October 2, 2018 04:00
Create audio spectrogram (with legend) from wav
#!/usr/bin/env python
# coding: utf-8
""" This work is licensed under a Creative Commons Attribution 3.0 Unported License.
Frank Zalkow, 2012-2013 """
# Source: http://www.frank-zalkow.de/en/code-snippets/create-audio-spectrograms-with-python.html?ckattempt=1&i=1
import numpy as np
from matplotlib import pyplot as plt
import scipy.io.wavfile as wav
from google.colab import drive
drive.mount('/content/drive')
!rm *.json
from google.colab import files
files.upload() # upload kaggle.json
!pip install kaggle
!mkdir -p ~/.kaggle