Skip to content

Instantly share code, notes, and snippets.

View arashmad's full-sized avatar

Arash Madadi arashmad

View GitHub Profile
@arashmad
arashmad / fastapi_boilerplate_builder.sh
Last active December 25, 2024 09:19
A shell script to generate custom repository from fastapi-poetry-boilerplate repository
# #!/bin/bash
convert_to_snake_sep() {
echo "$1" | tr -s ' ' ' ' | tr '[:upper:]' '[:lower:]' | sed 's/-/_/g'
}
# Getting source directory
echo "Specify the path to the boilerplate directory (e.g. /home/projects/fastapi-poetry-boilerplate)":
read src_dir
if [ ! -d "$src_dir" ]; then
@arashmad
arashmad / LatLong2Merc.js
Last active December 13, 2020 08:19
A conversion from Geographic (Latitude & Longitude) to Web Mercator (X & Y)
_latLong2Merc = (_lat, _lon) => {
/*
_lat => Latitude in decimal degree (Number)
_lon => Longitude in decimal degree (Number)
*/
var r_major = 6378137.000
var lon_rad = (_lon / 180.0 * Math.PI)
var x = r_major * lon_rad
var scale = x / _lon
var y = 180.0 / Math.PI * Math.log(Math.tan(Math.PI / 4.0 + _lat * (Math.PI / 180.0) / 2.0)) * scale
@arashmad
arashmad / mxdToKMZ.py
Last active December 11, 2020 13:21
Creating .kmz file automatically using ESRI ArcPy
import os
import arcpy
def mxdToKMZ(url):
if os.path.exists(path):
mxd_dir = os.path.split(path)[0]
kmz_dir = mxd_dir + "/kml"
os.mkdir(kmz_dir)
mxd = arcpy.mapping.MapDocument(r"path\to\mxd\file\name.mxd")