Skip to content

Instantly share code, notes, and snippets.

from time import strptime, strftime
d = "2013-08-12"
oldFormat = "%Y-%m-%d"
newFormat = "%d-%b-%Y"
oldDate = strptime(d, oldFormat)
# print oldDate
# print strftime(newFormat, oldDate).upper()
@nickyfoto
nickyfoto / all.py
Last active November 7, 2019 17:06
# jupyter notebook --no-browser --ip=0.0.0.0
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"
%matplotlib inline
%config InlineBackend.figure_format = 'retina'
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
@nickyfoto
nickyfoto / cloud9.sh
Last active February 15, 2019 21:58
cloud9 initial script
# set java
sudo yum -y update
sudo yum -y install java-1.8.0-openjdk-devel
sudo update-alternatives --config java
sudo update-alternatives --config javac
sudo yum -y update
@nickyfoto
nickyfoto / docker-ps-vertical
Created November 24, 2018 17:19 — forked from wzulfikar/docker-ps-vertical
vertical format for docker ps
export FORMAT="ID\t{{.ID}}\nNAME\t{{.Names}}\nIMAGE\t{{.Image}}\nPORTS\t{{.Ports}}\nCOMMAND\t{{.Command}}\nCREATED\t{{.CreatedAt}}\nSTATUS\t{{.Status}}\n"
// usage:
docker ps --format="$FORMAT"
@nickyfoto
nickyfoto / setup.sh
Created December 22, 2018 21:26
Setup nvm, node and yarn on cloud9
#!/bin/sh
# setup nvm node yarn on aws cloud9
set -e
cd ~/.nvm
git init
git remote add origin https://github.com/creationix/nvm.git
rm nvm-exec nvm.sh
@nickyfoto
nickyfoto / eeg_to_spectrogram.py
Last active May 24, 2024 10:46
Convert EEG signal to pure spectrogram image
# eeg_to_spectrogram
# steps
# 1. read eeg with pyedflib
# 2. convert eeg signal to spectrogram using matplotlib
# 3. remove unneccesary staff from matplotlib
# 4. save a pure spectrogram image for further analysis or
# machine learning image classification task
@nickyfoto
nickyfoto / video_sub_dl.sh
Last active October 20, 2023 09:31
Download video and its subtitle and merge subtitle to it.
# list available subtitles
# https://superuser.com/questions/927523/how-to-download-only-subtitles-of-videos-using-youtube-dl
youtube-dl --list-subs https://www.youtube.com/watch?v=lmWh9jV_1ac
# download a particular subtitle
youtube-dl --write-sub --sub-lang zh-CN --skip-download https://www.youtube.com/watch\?v\=lmWh9jV_1ac
# download auto generated sub
youtube-dl --write-auto-sub --sub-lang zh-CN --skip-download https://www.youtube.com/watch\?v\=lmWh9jV_1ac
@nickyfoto
nickyfoto / master_theorem.md
Last active April 16, 2019 03:12
master theorem
A problem is divided into a subproblem, each problem has size n/b
and combine these answers in O(n^d) time.

If T(n) = aT(ceiling(n/b)) + O(n^d) for some constant 

a > 0, b > 1, and d >= 0, then

T(n) = O(n^d) if d > log_b a
T(n) = O(n^d log n) if d = log_b a
@nickyfoto
nickyfoto / efs.md
Last active April 24, 2019 16:41
ubuntu mount efs
@nickyfoto
nickyfoto / fibR.py
Last active April 25, 2019 14:32
Recursively calculate nth Fibonacci number
def fibR(n):
"""recursive fib"""
if n == 0:
return 0
if n == 1:
return 1
return fibR(n-1) + fibR(n-2)
fibR(25)