Skip to content

Instantly share code, notes, and snippets.

View NP-chaonay's full-sized avatar
🎆
HNY 2025 and been RICKROLL

Nuttapong Punpipat NP-chaonay

🎆
HNY 2025 and been RICKROLL
View GitHub Profile
@NP-chaonay
NP-chaonay / remove_last_char.py
Last active July 5, 2020 15:31
Remove last charecter from text-encoded file (UTF-8 is supported).
#!/usr/bin/env python3
from types import SimpleNamespace as Namespace
import sys
# Future function from np_chaonay.main
def tmp(err,status_msg=None,IsWarning=False):
name=type(err).__name__
if not IsWarning:
type_='Error'
if status_msg==None: status_msg='Program operation has error due to Python exception.'
@NP-chaonay
NP-chaonay / Stopwatch.py
Last active June 23, 2020 12:19
My main stopwatch program written in Python.
#!/usr/bin/env python3
# Name: Main Stopwatch
# Description: My main stopwatch program written in Python.
# Author: Nuttapong Punpipat (NP-chaonay)
# Version: V.2.0.0_beta
# Revised Date: 2020-06-23 12:20 (UTC)
# License: MIT License
# Version Note:
# - Major version: indicates of very significant changes or changes that break compatibility on some system/platforms.
# - Minor version: indicates of significant changes or features adding.
@NP-chaonay
NP-chaonay / DS_Snippist_1.py
Last active May 29, 2020 06:30
Get specific fields of n randomly-selected songs metadata, on each mode group (Major-Minor), from MillionSongDataset.
# Import objects
import numpy as np
import pandas as pd
import h5py,random
# Prepare file
path='./Misc/msd_summary_file.h5'
hd5_file=h5py.File(path,'r')
# Shuffle and get n randomly-selected songs index (on each mode group (Major-Minor))
maj_index=np.where( hd5_file['analysis']['songs']['mode']==0 )[0]
@NP-chaonay
NP-chaonay / DS_Audio_CodeSnippist_1.py
Last active May 25, 2020 15:29
1st code snippist for Data Science project on Audio Processing.
#### Get the most n highest-amplitude musical note using my custom algorithm of FFT (on FFT length 35999) on each period (4134 samples) in the arr.
### Metadata
+ Author : Nuttapong Punpipat (NP-chaonay)
+ Updated On : 25/05/2020 at 9:56 UTC
+ General Updating Frequency : Weekly
+ Code Snippet Completeness : N/A
+ Stability : Beta
### General Notices
@NP-chaonay
NP-chaonay / DSPAudio-Python-Snippet
Last active May 24, 2020 04:46
My DSP (Audio) code snippet
### Create sine wave and write to disk ###
import math
import numpy as np
import scipy.io.wavfile as scp_io_wav
rate=44100
freq=440
sample_num=rate*5
# Note: round to 15 due to inaccurate of resulted value when input values "pi" and "2pi"
# Note: Using modulus (When at least 1 cycle of circle sine is reached, reset to 0) to prevent bigger value cause the inaccurate of resulted value. (Using lower rounding decimal point may decrease precision when inputted value goes higher.)
@NP-chaonay
NP-chaonay / np_chaonay_main.py
Last active June 10, 2020 13:54
My module that contains general object for using.
# Name : NP-chaonay main module
# Description : My module that contains general object for using.
# Author : Nuttapong Punpipat (NP-chaonay)
# License : MIT License
# Language : English
# Version / Last Programmed : V.1.0 09/06/20 14:33 (UTC)
### TODO ###
# - Update this script : Added print_err
# - Improve print_err
# - Improve another object
@NP-chaonay
NP-chaonay / GitHub_Gist-Registration.txt
Last active December 11, 2022 09:30
(Special-typed Gist) Registration of all my gists (except those one tagged "Special" like this gist)
# (General Properties's Description)
# - Type : Available as {Program,Script,Snippet,Module,Project,Library,Docs}
# (WARNING) Script and Program Difference: Script is like a Program it is scripting AND it (recommended OR must) be confingured inside the script first.
# - Implemented_Language : If more than 1 coding language is used, specify as Multi or specify them
# (Python-related Properties's Description)
# - PythonInteractive_CopyPaste_Guaranteed :
# (Note) For shorten the sentence, define this sentence "executed by copy the whole portion and paste to Python Interactive Console" as the word "that action"
# If, all code-contained sections are able to be done that action
# Or if,
# there're at least 1 code-contained sections that are able to be done that action
@NP-chaonay
NP-chaonay / UbuntuReleasesChangelogs_DataImporting.py
Last active May 11, 2020 12:23
Data Importing on Ubuntu releases' changelogs using pandas
### Program/Data Initialization ###
import urllib.request
import pandas as pd
import itertools
def pandas_series_full_display(series):
print('-'*64)
for property_i in range(series.count()):
print(str(series.index[property_i])+': '+str(series[property_i]))
@NP-chaonay
NP-chaonay / specialized-mplayer-audio-player-1.py
Last active May 7, 2020 08:22
My specialized music player (MPlayer front-end)
#!/usr/bin/env python3
import os,glob,random,subprocess,signal,threading,time,sys,curses
IsProcessRunning=True
Is_cli_win_display_Active=False
Has_cli_win_display_Active=False
play_no=0
args=['<Not playing>','<Not playing>']
os.chdir('/home/np-chaonay/')
songs=[]
def curses_print(msg,scr):
@NP-chaonay
NP-chaonay / specialized_timer_1.py
Last active May 13, 2020 09:04
Specialized-purpose timer #1 : It can adjust "from-to duration" and when exit the program, returns the recent-counting and accumulated time.
#!/usr/bin/python3
import time
start=time.time()
end=time.time()
latency=end-start
import signal,subprocess,sys,threading,os,random
def is_str_is_integer(string):
if string[0]=='-':
n=1
else: n=0