Skip to content

Instantly share code, notes, and snippets.

View crazyzlj's full-sized avatar
🎯
Focusing

Liang-Jun Zhu crazyzlj

🎯
Focusing
View GitHub Profile
@crazyzlj
crazyzlj / build_gdal_and_depends.sh
Created November 14, 2018 01:03 — forked from robe2/build_gdal_and_depends.sh
This script is for building gdal and gdal dependencies under mingw64, needed by both PostGIS and ogr_fdw
#my windows 64-bit build chain described here is available at http://www.bostongis.com/postgisstuff/ming64gcc48.7z
#(with most of these libraries already built)
#My 32-bit chain is much the same except uses gcc 4.8.1, I'll be posting that as well after I clean it up a bit
#Paul's instructions for setting up mingw on 32-bit are pretty close in concept - https://github.com/pramsey/postgis-build-windows
#Although these are built with mingw64 chain, they are designed to work with the EDB VC++ distributions of PostgreSQL
export OS_BUILD=64
export GCC_TYPE=gcc48
PROJECTS=/projects
SOURCES=/sources
@crazyzlj
crazyzlj / OpenSSL-1_1_0-stable-VS2015.md
Created February 4, 2018 12:07 — forked from terrillmoore/OpenSSL-1_1_0-stable-VS2015.md
Building OpenSSL 1.1.0 with Microsoft VS 2015

Building OpenSSL 1.1.0 with Microsoft VS 2015

MCCI needs OpenSSL for a Windows project (that will be cross-platform). A casual search didn't turn up either a good source for cross-platform libraries, which meant we have to build them ourselves. A deeper search found a detailed guide here, and yet the details don't match what I found when I checked out the code; and the post doesn't talk about doing it directly from GitHub (which I wanted to do).

Here's the procedure for building OpenSSL on 64-bit Windows 10, with Visual Studio 2015.

  1. If you don't have it, please install git bash from git-scm.com.
  2. Start a git bash window.

    In the following, I'll use lines beginning with {dir} $ to designate input to a bash Window. We'll also have to use a cmd.exe Window for much of the build, and those lines will be marked {dir}>, just as on Windows..

@crazyzlj
crazyzlj / string_contains.sh
Created November 24, 2017 09:09
useful_shell
# contains(string, substring)
#
# Returns 0 if the specified string contains the specified substring,
# otherwise returns 1.
# https://stackoverflow.com/questions/2829613/how-do-you-tell-if-a-string-contains-another-string-in-unix-shell-scripting
contains() {
string="$1"
substring="$2"
if test "${string#*$substring}" != "$string"
then
@crazyzlj
crazyzlj / err.txt
Last active October 17, 2017 08:29
compile_mongo-c-driver_by_mingw64_windows
In file included from C:/peacock/windows/windows/mingw-4/x86_64/include/libbson-1.0/bson-compat.h:38:0,
from C:/peacock/windows/windows/mingw-4/x86_64/include/libbson-1.0/bson.h:23,
from D:/compile/mongoc-1.8.1/src/mongoc/mongoc.h:22,
from D:\compile\mongoc-1.8.1\tests\test-mongoc-topology.c:1:
D:\compile\mongoc-1.8.1\tests\test-mongoc-topology.c: In function '_test_topology_invalidate_server':
D:\compile\mongoc-1.8.1\tests\test-mongoc-topology.c:347:32: error: 'mongoc_server_description_t' has no member named 'compressors'
BSON_ASSERT (bson_empty (&sd->compressors));
@crazyzlj
crazyzlj / RelativeImportModules.py
Last active August 16, 2017 02:21
python_utilities
from pathlib2 import Path
# Supplement for http://stackoverflow.com/a/28154841/2301450
# Generic boilerplate code for setting __package__ attribute for relative imports
# Code from https://gist.github.com/vaultah/d63cb4c86be2774377aa674b009f759a
# Usage:
# 1_level_example
#
# if __name__ == '__main__' and __package__ is None:
if __name__ == '__main__':
import os
from seims.pygeoc.pygeoc.hydro.hydro import D8Util
dirname = r'C:\z_data\ChangTing\dem\dem_v1986_bj1954\watershed_delineation\youwuzhen_10m_omp\spatial_raster'
infile = dirname + os.sep + r'flow_dir.tif'
outfile = dirname + os.sep + r'flow_dir_ag.tif'
D8Util.convert_code(infile, outfile, "taudem", "arcgis", 2)
# Export to GeoTIFF tool in Whitebox GAT not work in my computer, so export as ASCII file, and use raster_to_gtiff() to convert.
inasc = r'hillslope_wb.asc'
outtif = r'hillslope_wb.tif'
@crazyzlj
crazyzlj / collect_runtime_linux.sh
Last active June 10, 2017 05:11
Run several times for collecting runtime information on linux and windows
_runtimef=<your path>/rt_test.txt
echo "Run XXX runtime test..." >$_runtimef
for time in 1 2 3
do
for proc in 32 16 8 4 2 1
do
echo "current process number is: $proc " >>$_runtimef
outputfile=<>/outfile_$proc.tif
[ -f "$outputfile" ] && { rm -rf $outputfile; }
'your exec command' >>$_runtimef