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
# Configuration file for starship prompt | |
# see https://starship.rs/ | |
# This file must be copied into ~/.config/starship.toml | |
# Get editor completions based on the config schema | |
"$schema" = 'https://starship.rs/config-schema.json' | |
# Inserts a blank line between shell prompt | |
add_newline = false |
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 functools | |
import time | |
def timer(func): | |
"""Print the runtime of the decorated function""" | |
@functools.wraps(func) | |
def wrapper_timer(*args, **kwargs): | |
start_time = time.perf_counter() # 1 | |
value = func(*args, **kwargs) | |
end_time = time.perf_counter() # 2 |
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 | |
#set -x | |
# Shows you the largest objects in your repo's pack file. | |
# Written for osx. | |
# | |
# @see https://stubbisms.wordpress.com/2009/07/10/git-script-to-show-largest-pack-objects-and-trim-your-waist-line/ | |
# @author Antony Stubbs | |
LANG=C |
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
class DottedKeyDict(dict): | |
def get(self, path, default = None): | |
keys = path.split(".") | |
val = None | |
for key in keys: | |
if val: | |
if isinstance(val, list): | |
val = [ v.get(key, default) if v else None for v in val] | |
else: |
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
list1 = ['a', 'c', 'e'] | |
list2 = ['b', 'd', 'f'] | |
list3 = [ item for tmp in zip(list1, list2) for item in tmp] | |
# list3 = ['a', 'b', 'c', 'd', 'e', 'f'] |
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
setproxy() | |
{ | |
proxyhostport="my.proxy.com:portnbr" | |
authok=0 | |
while [ $authok -eq 0 ] ; do | |
echo "Setting proxy environment variables:" | |
echo -n " Username: " | |
read -e username | |
echo -n " Password: " | |
read -es password |
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
gdal_calc.py -A IMG.tif -B IMG.tif --B_band=2 --outfile=titi.tif --calc="1.0*((A.astype(float)*A.astype(float))+(B.astype(float)*B.astype(float)))" --type=Float32 --overwrite |
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
/** | |
* Creates and returns a {@link java.lang.String} from <code>t</code>’s stacktrace | |
* @param t Throwable whose stack trace is required | |
* @return String representing the stack trace of the exception | |
*/ | |
public String getStackTrace(Throwable t) { | |
StringWriter stringWritter = new StringWriter(); | |
PrintWriter printWritter = new PrintWriter(stringWritter, true); | |
t.printStackTrace(printWritter); | |
printWritter.flush(); |
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
# | |
# this gist can be used to list all targets, or - more correctly - rules, | |
# that are defined in a Makefile (and possibly other included Makefiles) | |
# and is inspired by Jack Kelly's reply to a StackOverflow question: | |
# | |
# http://stackoverflow.com/questions/3063507/list-goals-targets-in-gnu-make/3632592#3632592 | |
# | |
# I also found this script - http://www.shelldorado.com/scripts/cmds/targets - which does | |
# something similar using awk, but it extracts targets from the "static" rules from a single | |
# Makefile, meaning it ignores any included Makefiles, as well as targets from "dynamic" rules |
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 logging | |
import sys | |
class StreamToLogger(object): | |
""" | |
Fake file-like stream object that redirects writes to a logger instance. | |
""" | |
def __init__(self, logger, log_level=logging.INFO): | |
self.logger = logger | |
self.log_level = log_level |
NewerOlder