Skip to content

Instantly share code, notes, and snippets.

@mrtj
mrtj / local_ref.py
Last active March 13, 2022 14:07
Use local references in jsonschema python package
import os
import json
from pathlib import Path
from urllib.parse import urljoin
import jsonschema
def add_local_schemas_to(resolver, schema_folder, base_uri, schema_ext='.schema.json'):
''' Add local schema instances to a resolver schema cache.
@underchemist
underchemist / setup-gdal-compile-env.bat
Created October 10, 2019 02:13
Compiling GDAL python bindings on windows
rem Assumes visual studio build tools installed
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvars64.bat
conda activate <env name>
conda install -c conda-forge gdal
rem Uninstalling pre-installed python bindings to show that we can compile ourselves
pip uninstall gdal
rem Set environment variables
set INCLUDE=C:\<conda install location>\envs\<env name>\Library\include;%INCLUDE%
@nijave
nijave / metered.ps1
Created June 23, 2019 14:56
Powershell check if on metered network
[void][Windows.Networking.Connectivity.NetworkInformation, Windows, ContentType = WindowsRuntime]
$cost = [Windows.Networking.Connectivity.NetworkInformation]::GetInternetConnectionProfile().GetConnectionCost()
$cost.ApproachingDataLimit -or $cost.OverDataLimit -or $cost.Roaming -or $cost.BackgroundDataUsageRestricted -or ($cost.NetworkCostType -ne "Unrestricted")
#!/bin/bash
# source: https://gist.github.com/francoisromain/e28069c18ebe8f3244f8e4bf2af6b2cb
# and another script to create the directories deleted by this script
# project-create.sh: https://gist.github.com/francoisromain/58cabf43c2977e48ef0804848dee46c3
# Call this file with `bash ./project-delete.sh project-name`
# - project-name is mandatory
# This will delete 4 directories
@jacksonpradolima
jacksonpradolima / install_source-pro_font.sh
Last active June 17, 2024 09:59
Installing Adobe's Source Pro fonts in Ubuntu: Source Code Pro, Source Serif Prof, and Source Sans Pro
#!/bin/bash
mkdir /tmp/adodefont
cd /tmp/adodefont
mkdir -p ~/.fonts
wget https://github.com/adobe-fonts/source-code-pro/archive/2.030R-ro/1.050R-it.zip
unzip 1.050R-it.zip
cp source-code-pro-2.030R-ro-1.050R-it/OTF/*.otf ~/.fonts/
wget https://github.com/adobe-fonts/source-serif-pro/archive/2.000R.zip
@francoisromain
francoisromain / project-create.sh
Last active June 14, 2024 09:55
A bash script to create a Git post-receive hook to deploy after a Git push
#!/bin/bash
# source: https://gist.github.com/francoisromain/58cabf43c2977e48ef0804848dee46c3
# and another script to delete the directories created by this script
# project-delete.sh: https://gist.github.com/francoisromain/e28069c18ebe8f3244f8e4bf2af6b2cb
# Call this file with `bash ./project-create.sh project-name`
# - project-name is mandatory
# This will creates 4 directories and a git `post-receive` hook.
# code used for the following map : http://datagistips.blogspot.fr/
library(raster)
library(rgdal)
library(rgeos)
clc = raster("DATAS/CLC12_RIDF_RGF.tif") # here is the 200m Corine Land Cover GeoTiff
reg = readOGR("DATAS", "idf_geofla") # ile de france GéoFla Departments
# RECLASS
@cecepm
cecepm / postgis_administration.md
Last active March 28, 2016 15:40
PostgreSQL cheatsheet

PostGIS Administration

Create Database with Spatial Support (PostGIS v2.0)

Connect to your database, example using psql command line

\connect mydb

then install extensions

@jsyeo
jsyeo / install_dist_pip.bat
Last active February 15, 2022 05:10
Batch file to create virtualenv, download and install distribute + pip on Windows 7 machines (Python 3.3)
cd %USERPROFILE%
REM create the venv
C:\Python33\python.exe C:\Python33\Tools\Scripts\pyvenv.py %USERPROFILE%\venv
REM download get-pip.py and distribute_setup.py
powershell.exe -Command (new-object System.Net.WebClient).DownloadFile('https://raw.github.com/pypa/pip/master/contrib/get-pip.py','%USERPROFILE%\get-pip.py')
@apetrone
apetrone / winpath_startup.py
Last active May 14, 2022 14:51
Set win32 environment variable on startup via python
# This must be run with Administrator privileges in order to set environment variables
# http://code.activestate.com/recipes/55993/, Wolfgang Strobl
import _winreg
import sys
import traceback
import win32gui
import win32api
# this ensures that changes propagate immediately