Skip to content

Instantly share code, notes, and snippets.

View andrewbt's full-sized avatar

Andrew Thompson andrewbt

View GitHub Profile
@andrewbt
andrewbt / index.html
Created July 4, 2021 00:49
Sample for FCC user
<div class="hero-image">
<!-- <img src="https://images2.imgbox.com/24/1c/FsJ4AwKi_o.jpg" alt=""> -->
<div class="portfolio">
<h2 class="portfolio-title"><span class="portfolio-title--small">Hi there, I'm</span> Esther Itolima
<hr>
</h2>
<p class="portfolio-intro">A frontend web developer with great passion for tech and fascinated <br> to solve real world problem with software.</p>
</div>
<nav id="navbar" class="not-fixed">
<ul>
@andrewbt
andrewbt / salary_and_commission_calc.py
Last active January 30, 2021 19:53
I get paid a base salary plus variable commissions. The paystubs come into Pocketsmith (love it!) as a combined net-value (after taxes), but I want to track them separately. My paystubs don't tell me what portion is "net commission" and I got tired of using my calculator. This little command-line Python3 calculator does the math for me now!
import subprocess
#from https://stackoverflow.com/questions/1825692/can-python-send-text-to-the-mac-clipboard
def write_to_clipboard(output):
process = subprocess.Popen(
'pbcopy', env={'LANG': 'en_US.UTF-8'}, stdin=subprocess.PIPE)
process.communicate(output.encode('utf-8'))
#get inputs
gcomm = float(input("Enter gross commission only: "))
@andrewbt
andrewbt / convert_json_to_geojson.py
Created January 19, 2021 05:24
Converts regular JSON to GeoJSON for Arlington County bike counters
#! usr/bin/env python
from sys import argv
from os.path import exists
import simplejson as json
#script, in_file, out_file = argv
# Step 1: get XML from http://webservices.commuterpage.com/counters.cfc?wsdl&method=GetAllCounters
# Step 2: Convert XML to JSON with https://www.freeformatter.com/xml-to-json-converter.html
@andrewbt
andrewbt / count_sum_avg_features.py
Created January 14, 2021 16:54
This python3 script uses OGR (you can run it from OSGeo4W Shell), to count all features of shapefiles in the current directory, sum the total, and give an average
import os
from osgeo import ogr
feature_count_array = []
top = os.getcwd()
for root, dirs, files in os.walk(top):
for file in files:
if file.endswith(".shp"):
dataset = ogr.Open(file)
print(dataset.name)
layer = dataset.GetLayerByIndex()
@andrewbt
andrewbt / info.json
Created December 20, 2020 05:07
TileJSON.io - test
{
"baseLayer": {
"tilejson": "2.2.0",
"name": "base",
"version": "1.0.0",
"scheme": "xyz",
"tiles": [
"https://a.tile.openstreetmap.org/{z}/{x}/{y}.png"
]
},
@andrewbt
andrewbt / index.html
Created December 3, 2019 23:11
Airship, CARTO.js and HighCharts Example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Airship, CARTO.js and HighCharts Example</title>
<link rel="stylesheet" href="https://libs.cartocdn.com/airship-style/v2.1.1/airship.css">
<script src="https://libs.cartocdn.com/airship-components/v2.1.1/airship.js"></script>
@andrewbt
andrewbt / index.html
Created October 29, 2019 20:03
Get named map layers from CARTO
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Load a public CARTO Builder URL dynamically</title>
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
<script src="https://api.tiles.mapbox.com/mapbox-gl-js/v1.4.1/mapbox-gl.js"></script>
<link href="https://api.tiles.mapbox.com/mapbox-gl-js/v1.4.1/mapbox-gl.css" rel="stylesheet" />
<style>
body { margin:0; padding:0; }
@andrewbt
andrewbt / info.json
Created October 21, 2019 17:38
TileJSON.io - test
{
"baseLayer": {
"tilejson": "2.2.0",
"name": "base",
"version": "1.0.0",
"scheme": "xyz",
"tiles": [
"https://a.tile.openstreetmap.org/{z}/{x}/{y}.png"
]
},
@andrewbt
andrewbt / info.json
Created October 21, 2019 17:24
TileJSON.io - test
{
"baseLayer": {
"tilejson": "2.2.0",
"name": "base",
"version": "1.0.0",
"scheme": "xyz",
"tiles": [
"https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"
]
},
@andrewbt
andrewbt / index.html
Created August 2, 2019 17:58
Basic CARTO VL Layer
<!DOCTYPE html>
<html>
<head>
<title>Add layer | CARTO</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="UTF-8">
<script src="https://libs.cartocdn.com/carto-vl/v1.4.1/carto-vl.min.js"></script>
<script src="https://api.tiles.mapbox.com/mapbox-gl-js/v1.0.0/mapbox-gl.js"></script>
<link href="https://api.tiles.mapbox.com/mapbox-gl-js/v1.0.0/mapbox-gl.css" rel="stylesheet" />