Skip to content

Instantly share code, notes, and snippets.

View notalentgeek's full-sized avatar

Mikael Kristyawicaksono notalentgeek

View GitHub Profile
@notalentgeek
notalentgeek / anyton.js
Created October 6, 2017 16:49
JavaScript Anyton (Singleton, Doubleton, X-ton)
var anyton = function (ton, parameters, init_count) {
if (!init_count) {
init_count = 1; // Singleton.
}
var instances = [];
this.create_instance = function () {
if (instances.length < init_count) {
instances.push(new ton(...parameters)); // No pun intended.
@notalentgeek
notalentgeek / flight_api_puller.py
Last active May 10, 2023 23:22
Schipol Python Flight API Puller from https://developer.schiphol.nl/
"""
I faced a problem when pulling data from Schipol Airport API. The first
data pull is only resulted in 20 elements, meanwhile there are hundreds
of flights in Schipol everyday. From my support contact, it appears that
the API are in a pagination of 20 flights for each paginations.
This script is made to pull all flights schedule from all paginations.
"""
import requests, sys
@notalentgeek
notalentgeek / metis.css
Last active March 2, 2017 20:40
Basic MetisMenu style.
.sidebar-nav a,
.sidebar-nav a:active,
.sidebar-nav a:focus,
.sidebar-nav a:hover{
outline: none;
}
.sidebar-nav ul a,
.sidebar-nav ul li{
display: block;
}
@notalentgeek
notalentgeek / DetectChangeInTSecond.js
Last active January 10, 2017 23:26
JavaScript function to detect interval (1, 2, 3, ... seconds) using operating system internal clock.
// Function to detect if x second is already passed.
// If each tick is more than 1 second then this
// function is screwed, but that will not happen
// (hopefully).
function DetectChangeInTSecond(_t, _date){
this.t = _t;
this.currSecond = _date.getSeconds();
this.currSecondPrev = this.currSecond;
this.counter = 0;
@notalentgeek
notalentgeek / see_fm_arrange_numbering.py
Last active December 25, 2016 14:57
Python script to arrange numbering in my "see" folder.
# Python script to arrange files numbering in my personal see folder.
from tzlocal import get_localzone
import datetime as dt
import os
import shutil
import sys
def ArrangeFilesNumbering(_startDir):
# Get the list of files and folders in
@notalentgeek
notalentgeek / file_type_sorter.py
Last active March 4, 2024 13:47
My Python script to sort file based on its MIME type into separate folders.
# This is a Python script that let you arrange
# files into a folder for each extension. Actually
# I lied, this script is not about file extension
# but about a file's mime type. So, in case there
# are files that has no extension this script can
# predict what the file's extension could be.
# However, the only requirement is that file need
# to be able to be read by the computer's OS. For
# example image files usually has no problem with
# this script also with other media files. But,
@notalentgeek
notalentgeek / mass_add_same_extension.py
Last active December 24, 2016 19:51
A Python script to mass add same extension to all files in a folder.
# This is a Python script to mass add same
# extension for all files in a folder.
import os
import shutil
import sys
def MassAddSameExtension(_targDir, _ext):
# Get the list of all files in the targetDirectory.
targDirList = os.listdir(_targDir)
@notalentgeek
notalentgeek / pitch_volume_detection_alsaaudio.py
Created December 22, 2016 09:10
Simple proof of concept to stream audio from main microphone and then extract its pitch and volume properties on the fly.
# Only works with operating system that uses
# AlsaAudio as audio driver. Most Linux distros
# are using this (Debian, Ubuntu). Does not work
# any where else (MacOS or Windows).
#
# This is a class to stream audio data from
# computer microphone then extract the pitch
# and the volume from it. This is done using
# AlsaAudio and Aubio Python library. The
# AlsaAudio is used to turn on the computer
@notalentgeek
notalentgeek / pitch_volume_detection_pyaudio.py
Last active August 23, 2023 10:02
A simple proof of concept to extract pitch and volume of streamed audio from microphone with PyAudio.
# This is a simple demonstration on how to stream
# audio from microphone and then extract the pitch
# and volume directly with help of PyAudio and Aubio
# Python libraries. The PyAudio is used to interface
# the computer microphone. While the Aubio is used as
# a pitch detection object. There is also NumPy
# as well to convert format between PyAudio into
# the Aubio.
import aubio
import numpy as num
@notalentgeek
notalentgeek / note_init.py
Last active December 24, 2016 09:41
Python automation script for initiating my notes.
# This is a Python script to initiate notes with all images.
# Images are all already re - sized into 600 pixel width with
# proportional height. First is that I need to get the directory
# that is filled with the notes I want to init.
import datetime as dt
import io
import os
import shutil
import subprocess