This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"color": { | |
"default": { | |
"bg": "#FFDA5E", | |
"text": "black" | |
}, | |
"programming": { | |
"bg": "skyblue", | |
"text": "white" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* -------------------------------------------- | |
* 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(''); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
OlderNewer