This file contains hidden or 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
#!/bin/bash | |
function __awscat { | |
if [ "$1x" != 'x' ]; then | |
aws s3 cp --quiet "$1" /dev/stdout | |
fi | |
} | |
__awscat $1 |
This file contains hidden or 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 functools import wraps | |
from .bounded_pool_executor import BoundedThreadPoolExecutor | |
from .bounded_pool_executor import BoundedProcessPoolExecutor | |
_DEFAULT_POOL = BoundedThreadPoolExecutor(max_workers=5) | |
_PROCESS_POOL = BoundedProcessPoolExecutor(max_workers=5) | |
def threadpool(f, executor=None): | |
@wraps(f) | |
def wrap(*args, **kwargs): |
This file contains hidden or 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
import multiprocessing | |
import concurrent.futures | |
import threading | |
name = 'bounded_pool_executor' | |
class _BoundedPoolExecutor: | |
semaphore = None |
This file contains hidden or 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-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; |
This file contains hidden or 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 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); | |
} |
This file contains hidden or 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 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 {} |
This file contains hidden or 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
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); | |
} |
This file contains hidden or 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 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; |
This file contains hidden or 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
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; |
This file contains hidden or 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
# 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 |