Skip to content

Instantly share code, notes, and snippets.

View dschep's full-sized avatar

Daniel Schep dschep

View GitHub Profile
import { useState } from "react";
const useLocalStorageState = (storageKey, defaultValue) => {
const [value, setValue] = useState(
JSON.parse(localStorage.getItem(storageKey) || "null") || defaultValue
);
const wrappedSetValue = (newValue) => {
localStorage.setItem(storageKey, JSON.stringify(newValue));
setValue(newValue);
@dschep
dschep / metro.svg
Created January 23, 2020 00:42
Metro SVG from DC Metro Pro
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dschep
dschep / top9.py
Last active January 1, 2022 03:16
Instagram Top 9 - example output: https://www.instagram.com/p/B6vVp93Bb5F/
"""
An Instagram Top 9 generator that doesn't require connecting your account
to an untrustworthy 3rd party Instagram app.
Install the requirements with `pip3 install igramscraper Pillow click`
then run `python3 top9.py`
When done, you will have a YOURUSERNAME-top9.jpg in your working directory.
"""
from datetime import datetime
{
"features": [
{
"geometry": {
"coordinates": [
[
[
-76.99545991625094,
38.8494249445368
],
@dschep
dschep / bookmarklet.js
Last active March 3, 2020 14:55
Restore AWS shortcuts
javascript:(() => {
const newSc = prompt('enter shortcuts to restore');
/* Parse cookies into a map */
const cookies = new Map(document.cookie.split(/\s*;\s*/g).map(kv => kv.split('=')));
/* decode and parse the noflush_awscnm cookie */
const noflush_awscnm = JSON.parse(decodeURIComponent(cookies.get('noflush_awscnm')));
/* set shortcuts to those input by user */
noflush_awscnm.sc = newSc.split(',');
/* set the noflush_awscnm cookie (stringified & encoded) */
document.cookie = `noflush_awscnm=${encodeURIComponent(JSON.stringify(noflush_awscnm))}`;
@dschep
dschep / bookmarklet.js
Last active November 28, 2018 22:28
Get list of current AWS shortcuts
javascript:(() => {
/* Parse cookies into a map */
const cookies = new Map(document.cookie.split(/\s*;\s*/g).map(kv => kv.split('=')));
/* decode and parse the noflush_awscnm cookie */
const noflush_awscnm = JSON.parse(decodeURIComponent(cookies.get('noflush_awscnm')));
/* display the comma delimited shortcuts to user */
alert(`current shortcuts: ${noflush_awscnm.sc.join(',')}`);
})()
#!/usr/bin/env python
from requests_html import HTMLSession
session = HTMLSession()
resp = session.get('https://mailchi.mp/badcee76d7db/groupcamping?e=f74653273d')
groups = resp.html.find('#docs-internal-guid-242d83ee-6477-f6f4-5448-18ced87471f3', first=True).text.split('\n')
sites = resp.html.find('#docs-internal-guid-349ccfaa-6479-e25f-134f-289c9f089e3a', first=True).text.split('\n')
for group, site in zip(groups, sites):
print(f'{group}: {site}')
@dschep
dschep / JMSEPath-GBFS2GeoJSON.md
Last active June 12, 2019 18:03
JMSEPath Expressions to turn GBFS into GeoJSON

GBFS Bikes to GeoJSON

This creates a feature collection from the bikes endpoint of a GBFS service, such as JUMP DC's feed: https://dc.jumpmobility.com/opendata/free_bike_status.json

{type: `FeatureCollection`, features: data.bikes[*].{id: bike_id, geometry: {type: `Point`, coordinates: [lon, lat]}, properties: @}}

Example

GBFS Input:

{
@dschep
dschep / nvim-terminal-edit.py
Last active January 9, 2018 18:52 — forked from tarruda/nvim-terminal-edit.py
Edit file in host Neovim instance from a :terminal buffer
#!/usr/bin/env python
"""Edit a file in the host nvim instance."""
import os
import sys
from neovim import attach
args = sys.argv[1:]
addr = os.environ.get("NVIM_LISTEN_ADDRESS", None)
@dschep
dschep / Makefile
Last active December 26, 2017 14:13
Turn make into any task runner's entry point. in this example npm run-script
.PHONY: Makefile
%: Makefile
npm run -- $@