Skip to content

Instantly share code, notes, and snippets.

View Scarysize's full-sized avatar

Franz Scarysize

View GitHub Profile
-- The view
CREATE VIEW session(
id,
visitor_id,
start_utc_time,
next_start_utc_time
) AS
SELECT
pi_with_inactivity.visitor_id || '-' || row_number() OVER(
PARTITION BY pi_with_inactivity.visitor_id
@Scarysize
Scarysize / cloudSettings
Created March 16, 2019 10:59
Visual Studio Code Settings Sync Gist
{"lastUpload":"2019-03-16T10:58:57.829Z","extensionVersion":"v3.2.7"}
@Scarysize
Scarysize / dash.py
Created July 20, 2018 19:09
Toggle Sonos speaker between two volume settings using an Amazon dash button
import soco
from scapy.all import *
# MAC address of your Amazon dash button
DASH_MAC_ADDRESS = ''
# Name of your Sonos speaker
SPEAKER_NAME = ''
# Volume values to toggle between
@Scarysize
Scarysize / mapbox-animation.js
Created April 14, 2018 12:48
Basic mapbox-gl animation loop necessary for smoothly animating GeoJSON sources.
const source = this.map.getSource('my-source');
function loop() {
source.on('data', requestFrame);
source.setData(updatedGeoJson);
}
function requestFrame(event) {
if (event.dataType !== 'source') {
return;
@Scarysize
Scarysize / wpa_supplicant.conf
Created March 24, 2018 17:23
Wifi configuration for Raspberry Pi 3 Model B+
# wpa_supplicant.conf
# The country code is manadatory, otherwise wifi will be disabled
country=DE
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="your-ssid"
psk="your-password"
@Scarysize
Scarysize / with-config.py
Last active March 13, 2018 14:00
Run 'gcloud' commands and look for a "gcloud.yaml" file relative to the command to automatically set the commands project id
#!/usr/bin/env python
import re
from pathlib import Path
from subprocess import call
from sys import argv
from yaml import load, YAMLError
config_file_path = Path("gcloud.yaml")
@Scarysize
Scarysize / addresses.md
Last active January 18, 2018 09:36
Retrieve MAC addresses via SNMAP or ping sweep.
-- create indices to speed up queries
-- TRIPS
create index trips_trip_id on trips (trip_id);
create index trips_service_id on trips (service_id);
-- STOP_TIMES
create index stop_times_trips on stop_times (trip_id);
create index stop_times_stop_id on stop_times (stop_id);
-- get all trips happening on a regular monday
SELECT
trips.trip_id
FROM
trips,
calendar
WHERE
calendar.monday == 1
AND
trips.service_id == calendar.service_id
-- get all stop ids & times of a given trip
SELECT
stop_times.stop_id,
stop_times.arrival_time
FROM
trips,
stop_times
WHERE
stop_times.trip_id = '<trip-id>'
;