Skip to content

Instantly share code, notes, and snippets.

View dschep's full-sized avatar

Daniel Schep dschep

View GitHub Profile
@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 -- $@
javascript: function runDownloadThing(howManyToDownload) {
if (!howManyToDownload) {
howManyToDownload = 3;
}
if (window['downloadSome']) {
window.downloadSome();
return;
}
var iter = $('div.download a.a:not([download])').toArray();
iter = iter.concat($('div.row a[download]').toArray());
@dschep
dschep / py
Last active September 13, 2022 18:55
Shortcut for commandline python use
#!/usr/bin/env python3
"""
More convinient than `python -c`.
Automatically imports python modules and prints the repr of the last statement.
for example:
`py 'json.load(sys.stdin)'`
instead of
`python -c 'import json,stdin;print(repr(json.load(sys.stdin)))`
'use strict';
module.exports.hello = (event, context, callback) => {
const response = {
statusCode: 200,
body: JSON.stringify({
message: 'Go Serverless v1.0! Your function executed successfully!',
input: event,
}),
};
@dschep
dschep / py-comp-to-js.md
Last active September 10, 2024 00:15
Python Comprehensions to JS

Python list & dict comprehensions translated to JavasScript

Comprehensions are a really useful feature of Python that aren't available in JavaScript (or many languages). These concepts of course can be tranlsated into using map instead. But especially the dictionaries are a bit trickier.

Lists / Arrays

>>> foobar = range(5)
>>> [x + 1 for x in foobar]
[1, 2, 3, 4, 5]
@dschep
dschep / post-merge
Last active July 8, 2020 14:00 — forked from sindresorhus/post-merge
git hook to run a command after `git pull` if a specified file was changed.In this example it's used to run `yarn` if yarn.lock changed.Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
#!/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
# git hook to run a command after `git pull` if a specified file was changed
# Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"
import json
import requests
def hello(event, context):
body = {
"message": "Go Serverless v1.0! Your function executed successfully!",
"input": event
}
response = {
@dschep
dschep / ntfy.yml
Created March 24, 2017 12:26
Multiple ntfy pushover backends
backends:
- desktop
- cellphone
pushover: &pushover
backend: pushover
user_key: uiRM6s9BEXY5BPE78J3CBK3mb6rMe1
api_token: aUnsraBiEZVsmrG89AZp47K3S2dX2a
desktop:
<<: *pushover
device: desktop