Skip to content

Instantly share code, notes, and snippets.

View arashmad's full-sized avatar

Arash Madadi arashmad

View GitHub Profile
@arashmad
arashmad / instructor.js
Created February 14, 2021 09:26
build react-node-express project using yarn
// In React JS project go to package.json
// Inside the 'scripts' block, change
"start":"react-scripts start"
// to
"start":"react-scripts build && (cd backend && yarn start)",
// in which, backen is the root directory of node-express app
// and add
"start-client": "react-scripts start", //starts react app on port=3000
// now in node-express root directory, open server.js (maybe app.js)
@arashmad
arashmad / node.config.js
Last active January 2, 2021 06:54
Buid React/Node/Express with Yarn
// add
app.use(express.static(path.join(__dirname, "..", "build")));
@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")
@arashmad
arashmad / multiprocessing.py
Last active September 5, 2020 16:03
Helps you to do a repetitive procedure by distributing it across all CPU's cores
import time
import random
from multiprocessing import Process
workers = []
def do_something(a:str, b:int):
"""
This is your main function that you want to be
execute "n" times but much faster than usual by
@arashmad
arashmad / get_tile_url.js
Created August 25, 2020 17:05
This is an example of how you can get a tile image link by click on Leaflet Tile Layer map
/*
In this example I showed that users can click on map and
get link of image tile and containt location of clicked position.
I used Leaflet.js library and a ArcGIS tile service to prove my work.
You can easily change "samplePosition" and "initialZoom" to move to
your favourite location and zoom.
Just open browser console log and click on the link that is appread
after clicking on map.
*/