Skip to content

Instantly share code, notes, and snippets.

View dansuh17's full-sized avatar
🍩
coffee and what?

Dan Suh dansuh17

🍩
coffee and what?
View GitHub Profile
@dansuh17
dansuh17 / gtzan_to_mp3.py
Created November 15, 2017 09:18
Convert GTZAN dataset to mp3 files.
import subprocess
import os
def convert_gtzan_to_mp3(gtzan_folder_path, output_folder_name):
# recursively walk through the directory
for dirpath, dirnames, filenames in os.walk(gtzan_folder_path):
for filename in filenames:
input_filepath = os.path.join(dirpath, filename)
output_folderpath = dirpath.replace(gtzan_folder_path, output_folder_name)
@dansuh17
dansuh17 / downsample_sox.sh
Created November 27, 2017 08:34
Downsampling using sox
sox input.wav -r 16k output.wav
@dansuh17
dansuh17 / finetune.py
Created February 15, 2018 05:34
Finetuning pretrained pytorch model
# from : http://pytorch.org/docs/master/notes/autograd.html
# pretrained models here : https://github.com/pytorch/vision/tree/master/torchvision/models
model = torchvision.models.resnet18(pretrained=True)
for param in model.parameters():
param.requires_grad = False
# Replace the last fully-connected layer
# Parameters of newly constructed modules have requires_grad=True by default
model.fc = nn.Linear(512, 100)
# Optimize only the classifier
@dansuh17
dansuh17 / image_dataset.py
Created February 15, 2018 06:23
Dataset creation for pretrained alexnet model in pytorch.
root = 'imagenet'
traindir = 'train'
image_dataset = ImageFolder(
traindir,
transform=transforms.Compose([
transforms.RandomResizedCrop(224),
transforms.RandomHorizontalFlip(),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406],
std=[0.229, 0.224, 0.225]),
@dansuh17
dansuh17 / perm.js
Created February 15, 2018 09:44
Generate n-permutations
var allPerms = [];
function permutation(list, ret)
{
if (list.length == 0) {
allPerms.push(ret); // return the result
return;
}
for (var i = 0; i < list.length; i++) {
@dansuh17
dansuh17 / poj.sh
Created February 21, 2018 05:16
poj compile script
function poj() {
g++-6 -Wall -std=c++98 -pedantic-errors $1;
cat input.txt | ./a.out
}
@dansuh17
dansuh17 / uninstall-haskell-osx.sh
Created May 18, 2018 00:20 — forked from gatlin/uninstall-haskell-osx.sh
Uninstall Haskell from Mac OS X
#!/bin/bash
# source: http://www.haskell.org/pipermail/haskell-cafe/2011-March/090170.html
sudo rm -rf /Library/Frameworks/GHC.framework
sudo rm -rf /Library/Frameworks/HaskellPlatform.framework
sudo rm -rf /Library/Haskell
rm -rf .cabal
rm -rf .ghc
rm -rf ~/Library/Haskell
@dansuh17
dansuh17 / uninstall-haskell-osx.sh
Created May 18, 2018 00:20 — forked from gatlin/uninstall-haskell-osx.sh
Uninstall Haskell from Mac OS X
#!/bin/bash
# source: http://www.haskell.org/pipermail/haskell-cafe/2011-March/090170.html
sudo rm -rf /Library/Frameworks/GHC.framework
sudo rm -rf /Library/Frameworks/HaskellPlatform.framework
sudo rm -rf /Library/Haskell
rm -rf .cabal
rm -rf .ghc
rm -rf ~/Library/Haskell
@dansuh17
dansuh17 / multipart_upload.sh
Created May 26, 2018 04:37
curl multipart upload
curl -F ‘data=@path/to/file.txt’ https://localhost/upload/
@dansuh17
dansuh17 / http2_curl.sh
Created May 26, 2018 04:40
http2 request using cURL
curl --http2 -k -v https://localhost/get/