Skip to content

Instantly share code, notes, and snippets.

@mangopudding
mangopudding / python-aws-lambda-to-slack
Created January 12, 2017 00:27
AWS-Lambda Function To Trigger Notification To Slack Channel
# OVERVIEW
#
# AWS Lambda Function To Trigger A Notification Into Slack Channel.
#
from __future__ import print_function
import boto3
import json
import logging
@joshisa
joshisa / URL Parsing
Created February 3, 2017 02:27
Parsing of URLs using bash sh scripting
#!/bin/bash
# Referenced and tweaked from http://stackoverflow.com/questions/6174220/parse-url-in-shell-script#6174447
proto="$(echo $1 | grep :// | sed -e's,^\(.*://\).*,\1,g')"
# remove the protocol
url="$(echo ${1/$proto/})"
# extract the user (if any)
userpass="$(echo $url | grep @ | cut -d@ -f1)"
pass="$(echo $userpass | grep : | cut -d: -f2)"
if [ -n "$pass" ]; then
@jgravois
jgravois / post.py
Last active April 22, 2022 18:15
what's required to use python requests to POST to AGOL/ArcGIS Server?
import requests
import json
agol_url = r'http://services1.arcgis.com/uRIm5IkWjDXybgFb/arcgis/rest/services/LA_Nhood_Change/FeatureServer/0/query'
server_url = r'http://sampleserver6.arcgisonline.com/arcgis/rest/services/EmergencyFacilities/FeatureServer/0/query'
# i tried several different headers, to no avail
# headers={"Content-type": "application/x-www-form-urlencoded","Accept": "text/plain"}
# headers = {"Content-Type": "application/x-www-form-urlencoded", "Accept":"/*/", "Accept-Encoding":"gzip, deflate", "Accept-Language":"en-US,en;q=0.8,ar;q=0.6"}
headers={"content-type":"application/json","Accept":"application/json"}
@JeffJacobson
JeffJacobson / GetArcGis-Token.ps1
Last active March 30, 2023 20:32
ArcGIS Online / Portal Powershell scripts
class Token {
[string] $token
[System.DateTimeOffset] $expires
Token($response) {
$this.token = $response.token;
$this.expires = [System.DateTimeOffset]::FromUnixTimeMilliseconds($response.expires)
}
}
$rootUri = "https://www.arcgis.com/sharing/rest"
@kingspp
kingspp / logging.py
Created April 22, 2017 07:14
Python Comprehensive Logging using YAML Configuration
import os
import yaml
import logging.config
import logging
import coloredlogs
def setup_logging(default_path='logging.yaml', default_level=logging.INFO, env_key='LOG_CFG'):
"""
| **@author:** Prathyush SP
| Logging Setup
@nygeog
nygeog / csv-to-shapefile-geopandas.py
Last active July 18, 2024 00:31
Read a CSV with Pandas and set as GeoDataFrame with geopandas and save as Shapefile with fiona
import pandas as pd
from geopandas import GeoDataFrame
from shapely.geometry import Point
import fiona
df = pd.read_csv('data.csv')
geometry = [Point(xy) for xy in zip(df.x, df.y)]
crs = {'init': 'epsg:2263'} #http://www.spatialreference.org/ref/epsg/2263/
geo_df = GeoDataFrame(df, crs=crs, geometry=geometry)
@SMSAgentSoftware
SMSAgentSoftware / New-WizTreeDiskUsageReport.ps1
Created August 15, 2018 13:27
Creates csv and html disk usage reports using WizTree portable
# Script to export html and csv reports of file and directory content on the system drive
# Use to identify large files/directories for disk space cleanup
# Uses WizTree portable to quickly retrieve file and directory sizes from the Master File Table on disk
# Download and extract the WizTree64.exe and place in the same directory as this script
# Set the running location
$RunLocation = $PSScriptRoot
#$RunLocation = "C:\temp"
$TempLocation = "C:\temp"
@maphew
maphew / arcpy-overhead.py
Last active March 11, 2020 13:00
What is your "import arcpy" overhead?
'''Measure and report the time it takes to simply `import arcpy`
Part of https://community.esri.com/message/914048-re-what-is-your-import-arcpy-overhead?
'''
from timeit import default_timer as timer
start = timer()
from datetime import datetime, timedelta
from uuid import uuid4
eventid = datetime.now().strftime('%Y%m-%d%H-%M%S-') + str(uuid4())
@alexandramartinez
alexandramartinez / 01-Postman-Scripts.md
Last active April 30, 2025 06:24
Postman scripts cheatsheet

Postman Scripts Cheatsheet

Here you can find some of the most used scripts for Postman testing.

At least some of the most used by me :-)

Postman Objects

(pm-objects.js)

  • Global variables
  • Environment variables