Skip to content

Instantly share code, notes, and snippets.

View loretoparisi's full-sized avatar
🐍
NightShift

Loreto Parisi loretoparisi

🐍
NightShift
View GitHub Profile
@loretoparisi
loretoparisi / bounded_pool_executor.py
Last active August 5, 2021 16:58
Python Thread Support with Bounder Thread Pool or Process Executor
import multiprocessing
import concurrent.futures
import threading
name = 'bounded_pool_executor'
class _BoundedPoolExecutor:
semaphore = None
@loretoparisi
loretoparisi / github_colors.css
Created May 7, 2021 16:54
Github CSS Colors HEX scale
{
--color-scale-black: #010409;
--color-scale-white: #f0f6fc;
--color-scale-gray-0: #f0f6fc;
--color-scale-gray-1: #c9d1d9;
--color-scale-gray-2: #b1bac4;
--color-scale-gray-3: #8b949e;
--color-scale-gray-4: #6e7681;
--color-scale-gray-5: #484f58;
--color-scale-gray-6: #30363d;
@loretoparisi
loretoparisi / s3_delete_object_version_id.js
Last active May 6, 2021 18:58
S3 Delete Object with VersionId
function deleteVersionedObject(bucket, key, callback) {
var params = {
Bucket: bucket,
Key: key
};
s3.deleteObject(params, function (error, data) {
if (error) {
console.error("S3Dataset delete error key:%s error:%@", params.key, error);
return callback(error);
}
@loretoparisi
loretoparisi / trace_mem.py
Created May 6, 2021 12:49
Python Memory Alloc Trace
def trace_mem(nframe=6,top=8):
'''
naive memory trace
'''
import tracemalloc
is_tracing = tracemalloc.is_tracing()
if not is_tracing:
# start tracing
tracemalloc.start(nframe)
return {}
@loretoparisi
loretoparisi / aws_s3_get_object_put_object_async.js
Last active July 6, 2022 18:12
NodeJS JavaScript AWS S3 getObject, putObject, deleteObject with async await and recursive approach for nested S3 folders
async function getObjectAsync(bucket, key) {
try {
const data = await s3
.getObject({ Bucket: bucket, Key: key })
.promise();
var contents = data.Body.toString('utf-8');
return contents;
} catch (err) {
console.log(err);
}
@loretoparisi
loretoparisi / stripJSON.js
Created April 22, 2021 15:32 — forked from usmansbk/stripJSON.js
Recursively remove json keys in an array
/**
* @function stripJSON
* @desc - This function removes selected object keys
* @param {Object} json - JavaScript object to strip
* @param {Object[]} keys - array of selected keys (string)
* @return {Object} - deep copy of object without keys
*/
function stripJSON(json, keys) {
if (json === null || json === undefined) return json;
let obj = {}, key;
@loretoparisi
loretoparisi / macos_mojave_disappearing_icons_fix.sh
Created April 14, 2021 08:30
OSX Mojave Disappearing Icons Fixed
find "${HOME}/Library/Application Support/Dock" -name "*-*.db" -maxdepth 1 -delete;
sudo rm -rf /Library/Caches/com.apple.iconservices.store;
sudo find /private/var/folders/ -name com.apple.dock.iconcache -exec rm -rf {} \;;
sudo find /private/var/folders/ -name com.apple.iconservices -exec rm -rf {} \;;
sudo touch /Applications/*;
defaults write com.apple.dock ResetLaunchPad -bool true;
killall Dock;
killall Finder;
# To control logging level for various modules used in the application:
import logging
import re
def set_global_logging_level(level=logging.ERROR, prefices=[""]):
"""
Override logging levels of different modules based on their name as a prefix.
It needs to be invoked after the modules have been loaded so that their loggers have been initialized.
Args:
- level: desired level. e.g. logging.INFO. Optional. Default is logging.ERROR
@loretoparisi
loretoparisi / twitter_topic.json
Created April 2, 2021 17:29
Twitter Topic - as seen on twitter.com
["Technology", "Investing", "Books", "Gaming", "Computer programming", "Tech news", "Machine learning", "Travel", "Web development", "Arts & culture news", "World news", "Movies", "Home improvement", "Arts & crafts", "Dogs", "Philosophy", "Comedy", "Space", "Business & finance", "Pets", "Information security", "Neon Genesis Evangelion", "Cybersecurity", "Science", "Interior design", "Bitcoin cryptocurrency", "Education", "Architecture", "National parks", "Movies & TV", "Business news", "Food", "PlayStation 5", "Disney", "Fashion", "Psychology", "Language learning", "Gardening", "Fitness", "Music", "Sci-fi & fantasy films", "Science news", "Artificial intelligence", "Visual arts", "Home & family", "Cats", "Cooking", "Harry Potter", "Gaming consoles", "Animal Crossing", "Digital creators", "Sci-fi & fantasy", "Animation", "Star Wars", "Art", "Classic rock", "Tattoos", "Painting", "Travel guides", "Guitar", "History", "PlayStation", "Inspirational quotes", "Running", "PC gaming", "Mobile Suit Gundam", "Gaming ne
@loretoparisi
loretoparisi / twitter_topic_grouped.json
Created April 2, 2021 17:27
Twitter Topics grouped - as seen on twitter.com
[
["Technology", "Investing", "Books"],
["Gaming", "Computer programming", "Tech news"],
["Machine learning", "Travel", "Web development"],
["Arts & culture news", "World news", "Movies"],
["Home improvement", "Arts & crafts", "Dogs"],
["Philosophy", "Comedy", "Space"],
["Business & finance", "Pets", "Information security"],
["Neon Genesis Evangelion", "Cybersecurity", "Science"],
["Interior design", "Bitcoin cryptocurrency", "Education"],