Skip to content

Instantly share code, notes, and snippets.

View steinbring's full-sized avatar

Joe Steinbring steinbring

View GitHub Profile
@steinbring
steinbring / CocktailList.vue
Created November 13, 2023 03:08
An example of how to use a Vue composable
<template>
<div>
<router-view/>
<h1>Cocktails</h1>
<ul>
<li v-for="cocktail in cocktails" :key="cocktail.url_slug">
<router-link :to="`/${level}/${cocktail.url_slug}`">{{ cocktail.name }}</router-link>
</li>
</ul>
@steinbring
steinbring / useCocktails.js
Created November 13, 2023 02:56
An example of a Vue composable
import { ref, onMounted } from 'vue';
import simpleCocktails from '../data/simple_cocktails.json';
import intermediateCocktails from '../data/intermediate_cocktails.json';
import advancedCocktails from '../data/advanced_cocktails.json';
export default function useCocktails(level) {
const cocktails = ref([]);
onMounted(() => {
switch(level) {
@steinbring
steinbring / cocktails.json
Created November 8, 2023 03:49
30 3-Ingredient Cocktails
{
"cocktails": [
{
"name": "Classic Margarita",
"ingredients": ["2 oz Tequila", "1 oz Triple sec", "1 oz Lime juice"],
"instructions": "Shake all ingredients with ice and strain into a salt-rimmed glass.",
"characteristics": ["Tangy", "Citrusy", "Refreshing"]
},
{
"name": "Mojito",
[
{
"title": "Joe's Vacation",
"start": "2022-06-15",
"end": "2022-06-29"
},
{
"title": "Sam's Vacation",
"start": "2022-06-20",
"end": "2022-07-05"
@steinbring
steinbring / index.js
Created November 22, 2021 02:57
The code behind https://addresstocoordinates.joe.workers.dev/?q=87714 (An API for converting from a municipality or zip code to latitude/longitude coordinates)
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
function getUrlVars(url) {
var vars = {};
var parts = url.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
vars[key] = value;
});
return vars;
@steinbring
steinbring / cityStateToLatLong.json
Created November 20, 2021 20:44
JSON file of municipalities (Cities/States) and their corresponding latitude/longitude coordinates. (Source: 2021_Gaz_place_national.zip from https://www.census.gov/geographies/reference-files/time-series/geo/gazetteer-files.html)
This file has been truncated, but you can view the full file.
[
{
"state": "AL",
"city": "Abanda CDP",
"latitude": 33.091627,
"longitude": -85.527029
},
{
"state": "AL",
"city": "Abbeville city",
@steinbring
steinbring / zipCodeToLatLong.json
Created November 20, 2021 20:42
JSON file of five-digit ZIP codes and their corresponding latitude/longitude coordinates. (Source: 2021_Gaz_zcta_national.zip from https://www.census.gov/geographies/reference-files/time-series/geo/gazetteer-files.html)
This file has been truncated, but you can view the full file.
[
{
"zip": 601,
"latitude": 18.180555,
"longitude": -66.749961
},
{
"zip": 602,
"latitude": 18.361945,
"longitude": -67.175597
@steinbring
steinbring / zipCodeToLatLong.csv
Created November 20, 2021 20:07
CSV file of five-digit ZIP codes and their corresponding latitude/longitude coordinates. (Source: 2021_Gaz_zcta_national.zip from https://www.census.gov/geographies/reference-files/time-series/geo/gazetteer-files.html)
We can't make this file beautiful and searchable because it's too large.
zip,latitude,longitude
601,18.180555,-66.749961
602,18.361945,-67.175597
603,18.458497,-67.123906
606,18.158327,-66.932928
610,18.294032,-67.127156
611,18.276316,-66.807165
612,18.416727,-66.70009
616,18.420412,-66.671979
617,18.446889,-66.561154
@steinbring
steinbring / cityStateToLatLong.csv
Created November 20, 2021 19:55
CSV file of municipalities (Cities/States) and their corresponding latitude/longitude coordinates. (Source: 2021_Gaz_place_national.zip from https://www.census.gov/geographies/reference-files/time-series/geo/gazetteer-files.html)
We can't make this file beautiful and searchable because it's too large.
state,city,latitude,longitude
AL,Abanda CDP,33.091627,-85.527029
AL,Abbeville city,31.564724,-85.259123
AL,Adamsville city,33.602315,-86.971527
AL,Addison town,34.202681,-87.178004
AL,Akron town,32.879066,-87.740899
AL,Alabaster city,33.244399,-86.847372
AL,Albertville city,34.26313,-86.21066
AL,Alexander City city,32.92724,-85.937122
AL,Alexandria CDP,33.760819,-85.872008
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
function getUrlVars(url) {
var vars = {};
var parts = url.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
vars[key] = value;
});
return vars;