Skip to content

Instantly share code, notes, and snippets.

View ezirmusitua's full-sized avatar
🎯
Focusing

ezirmusitua ezirmusitua

🎯
Focusing
View GitHub Profile
@ezirmusitua
ezirmusitua / interested-keywords.json
Last active June 28, 2020 22:27
[Highlighted Keywords] highlighted keywords configurations for monkey script #configuration #json
{
"color": {
"default": {
"bg": "#FFDA5E",
"text": "black"
},
"programming": {
"bg": "skyblue",
"text": "white"
}
@ezirmusitua
ezirmusitua / .py
Last active January 17, 2019 15:27
[Schedule daily appointment] codewar challenge: schedule daily appointment #algorithm #challenge #python
Total_Work_Time_In_Minute = (19 - 9) * 60 + 1
def timestr2minute(timestr):
hour, minute = map(lambda v: int(v), timestr.split(':'))
return hour * 60 + minute
def minute2timestr(point_in_sheet):
hour, minute = divmod(point_in_sheet, 60)
hour_str, minute_str = '', ''
hour_str = '0' + str(hour + 9) if hour == 0 else str(hour + 9)
@ezirmusitua
ezirmusitua / .py
Last active January 17, 2019 15:20
[Morse encoding] codewar challenge: morse encoding #python #algorithm #challenge
def convert_complement_to_dec(str):
if str[0] == '1':
reversed_str = ''
for bit in str[1:]:
reversed_str += '1' if bit == '0' else '0'
return -1 * (int('0b' + reversed_str, 2) + 1)
return int('0b' + str, 2)
def convert_dec_to_complement(val):
val_bin = bin(val)
@ezirmusitua
ezirmusitua / largest-numeric-plaindrome.py
Last active January 17, 2019 15:20
[Find largest numeric plaindrome] codewar challenge: Largest Numberic Plain drome #algorithm #challenge #python
from operator import mul
from functools import reduce
from itertools import combinations
def all_combinations_from(arr, start=2):
result = list()
for i in range(start, len(arr) + 1):
for t in combinations(arr, i):
result.append(reduce(mul, t))
print('combinations result: ', result)
@ezirmusitua
ezirmusitua / javascript-resize-debounce.js
Last active September 1, 2023 13:14
[Debounce window resize event] Debounce window resize event #javascript #frontend #perfermance
/* --------------------------------------------
* Detect device orientation
* and trigger changes based on it
--------------------------------------------*/
function updateOrientation() {
// Detect whether device supports orientationchange event, otherwise fall back to the resize event
// Genius solution from http://stackoverflow.com/a/2307936
let supportsOrientationChange = "onorientationchange";
let orientationEvent = supportsOrientationChange ? "orientationchange" : "resize";
let newAngle = null;
@ezirmusitua
ezirmusitua / group-same-image.py
Last active November 30, 2022 21:41
[Group similar images] Group similar images using phash algorithm #python #image #algorithm #tools
"""
This script use to group similiar images from source folder
and save to the same output folder, base on the perceptual hash algorithm.
Work on Python3.6 and win10-build-17074
Prerequest: Pillow
Author: jferroal@gmail.com
"""
import hashlib
import mimetypes
@ezirmusitua
ezirmusitua / __init__.py
Last active January 17, 2019 15:26
[csv2xlsx flask app demo] demo code for blog post https://ezirmusitua.site/posts/deep-in-flask-upload-and-download/ #blog #demo #python
def create_app(test_config=None):
# create and configure the csv2xlsx
app = Flask(__name__, instance_relative_config=True)
app.config.from_mapping(SECRET_KEY='dev')
if test_config is None:
# load the instance config, if it exists, when not testing
app.config.from_pyfile('config.py', silent=True)
else:
# load the test config if passed in
@ezirmusitua
ezirmusitua / image-viewer.js
Last active January 17, 2019 15:26
[Local image server] Simplest node image viewer with pagination in localhost #node #javascript #tools #image
// usage: node image-viewer <Gallery Root>
const fs = require('fs');
const path = require('path');
const http = require('http');
// yarn add global gm & apt install graphicmagic
let gm;
try {
const gm = require('gm');
catch (err) {
console.warn('gm not found, run `$npm install gm` in script directory to install');
@ezirmusitua
ezirmusitua / eosjs-actions-from-abi.js
Last active January 17, 2019 15:30
[Extract eosjs push_transactions actions] Generate eosjs push_transactions' actions list from abi string #eos #javascript #documentation
function tmpl(strings, ...keys) {
return (function (...values) {
const dict = values[values.length - 1] || {};
const result = [strings[0]];
keys.forEach(function (key, i) {
const value = Number.isInteger(key) ? values[key] : dict[key];
result.push(value, strings[i + 1]);
});
return result.join('');
});
@ezirmusitua
ezirmusitua / install-fira-code-patch.sh
Last active January 17, 2019 15:35
[Install FiraCode font] install powerline patched FiraCode font in linux #linux #bash
mkdir -p ~/.local/share/fonts
cd ~/.local/share/fonts
curl -fLo "FuraCodeMono-Bold.otf" "https://github.com/ryanoasis/nerd-fonts/blob/master/patched-fonts/FiraCode/Bold/complete/Fura%20Code%20Bold%20Nerd%20Font%20Complete%20Mono.otf"
curl -fLo "FuraCodeMono-Light.otf" "https://github.com/ryanoasis/nerd-fonts/blob/master/patched-fonts/FiraCode/Light/complete/Fura%20Code%20Light%20Nerd%20Font%20Complete%20Mono.otf"
curl -fLo "FuraCodeMono-Medium.otf" "https://github.com/ryanoasis/nerd-fonts/blob/master/patched-fonts/FiraCode/Medium/complete/Fura%20Code%20Medium%20Nerd%20Font%20Complete%20Mono.otf"
curl -fLo "FuraCodeMono-Regular.otf" "https://github.com/ryanoasis/nerd-fonts/blob/master/patched-fonts/FiraCode/Regular/complete/Fura%20Code%20Regular%20Nerd%20Font%20Complete%20Mono.otf"
curl -fLo "FuraCodeMono-Retina.otf" "https://github.com/ryanoasis/nerd-fonts/blob/master/patched-fonts/FiraCode/Retina/complete/Fura%20Code%20Retina%20Nerd%20Font%20Complete%20Mono.otf"