View stackoverflow_72031323_sha256_mac_base64.cpp
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
#include <cstdint> | |
#include <string> | |
using String = std::string; | |
#define ASSERT_MSG(cond, msg) \ | |
{ \ | |
if (!(cond)) \ | |
return Err{"Assert (" #cond ") failed at " + IntToStr(__LINE__) + "! Msg '" + Str(msg) + "'."}; \ | |
} |
View integrate_simpson.py
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 IntegrateSimpson(x, y, *, dtype = 'float64'): | |
# Integrates function f represented by (x, y) samples using Simpson's Rule. | |
# See https://en.wikipedia.org/wiki/Simpson%27s_rule | |
# Returns array a[i] = "integral on samples (x[0], y[0])..(x[i], y[i])". | |
# Hence a[-1] (last value) equals to integral on full range. | |
# First two values are approximated by Trapezoid Rule, as Simpson's Rule needs at least 3 points. | |
# Needs: python -m pip install numpy | |
import numpy as np | |
View progress_bar_iterator_wrapper_for_enlighten.py
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
# Iterator-Wrapping Helper Function for enlighten library | |
# Needs: python -m pip install enlighten | |
def pit(it, *pargs, **nargs): | |
import enlighten | |
global __pit_man__ | |
try: | |
__pit_man__ | |
except NameError: | |
__pit_man__ = enlighten.get_manager() |
View shp_to_json.py
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
# Converts ESRI Shapefile (.shp) to GeoJSON (.json, see http://geojson.org/). | |
# Usage: python shp_to_json.py SHAPEFILE_NAME.shp | |
import sys, os, json | |
# python -m pip install pyshp | |
import shapefile | |
ifn = sys.argv[1] | |
assert ifn.lower().endswith('.shp'), ifn |