Skip to content

Instantly share code, notes, and snippets.

View wiccy46's full-sized avatar

Jiajun wiccy46

  • Holoplot
  • Berlin
View GitHub Profile
@wiccy46
wiccy46 / juce_logger.cpp
Created September 22, 2019 15:19
[Juce_logger]Juce Logger on GUI #c++ #juce
TextEditor diagnosticsBox;
void logMessage(const String& m){
diagnosticsBox.moveCaretToEnd();
diagnosticsBox.insertTextAtCaret(m + newLine);
}
// resized()
diagnosticsBox.setBounds;
@wiccy46
wiccy46 / youtube_dl.txt
Last active February 11, 2020 21:50
[youtube-dl]Download Youtube Video as Audio Format #terminal #bash #shell
youtube-dl --extract-audio --audio-format wav --audio-quality 0 --postprocessor-args "-ss 00:00:00.00 -t 00:05:00.00" https://www.youtube.com/watch?v=n
@wiccy46
wiccy46 / gammatone.py
Created December 18, 2019 21:59
[gammatone]Gammatone filter #python
# Try Gammatonefilter
t = np.linspace(0, 1, 1000) # Time
f = 4 # center freq
theta = 0 # phase
b = 1 # filter bandwidth
n = 3 # filter order
a = 1. # Amp
g = a * np.power(t, (n-1)) * np.exp(-2 * np.pi * b * t) * np.cos(2 * np.pi * f * t + theta)
@wiccy46
wiccy46 / conversion.py
Created February 7, 2020 08:21
[conversion] A collection of python conversion #python
# List of string to a long string.
alist = ['1', '2', '3', '4']
alist_joint = ' '.join(alist)
# Long string to list
astring = '1 2 3 4'
alist = astring.split(sep=' ')
@wiccy46
wiccy46 / reverse_int.py
Created February 7, 2020 16:29
[reverse_number] Reverse a number #python
n = 1234
rev=0
while(n>0):
dig=n%10
rev=rev*10+dig
n=n//10
@wiccy46
wiccy46 / counter_defaultdict.py
Created February 10, 2020 14:42
[counter] Counting items with defaultdict #python
from collections import defaultdict
item_list = 'spam spam egg egg spam'.split()
count = defaultdict(int)
for item in item_list:
count[item] += 1
@wiccy46
wiccy46 / dsstoreremove.txt
Created February 21, 2020 16:22
[dsstoreRemove] Remove DS_Store from git, #git
Step 1: In order to remove existing files from the repository:
find . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch
Step 2: Add this line '.DS_Store' to your .gitignore file, which can be found at the top level of your repository (or create if it isn't there already. Use the following command to do so:
echo .DS_Store >> .gitignore
Step 3: Then run the following command:
@wiccy46
wiccy46 / project_root.py
Created March 20, 2020 11:50
[project_root] Get cwd #python
import os
project_root = os.path.dirname(os.path.abspath(__file__))
@wiccy46
wiccy46 / dockerrun.txt
Created March 24, 2020 09:10
[dockerrun] Docker data scicence #docker
$ docker run -it --rm --name ds -p 8888:8888 jupyter/datescience-notebook
@wiccy46
wiccy46 / batch_generator.py
Created March 26, 2020 10:18
[batch] Batch generator #python
def batch_generator(items, batch_size):
batch = []
i = 0
for item in items:
batch.append(item)
if len(batch) == batch_size:
yield batch
batch = []
yield batch