Skip to content

Instantly share code, notes, and snippets.

View tym-xqo's full-sized avatar
🖤

Thomas Yager-Madden tym-xqo

🖤
View GitHub Profile
@tym-xqo
tym-xqo / cannery-result.js
Created July 7, 2018 17:18
Cannery static report prototype
require('dotenv').config()
const fs = require('fs')
const {
Client
} = require('pg')
const dbUri = process.env.DATABASE_URL
const queryName = process.env.QUERY_NAME
const db = new Client({
@tym-xqo
tym-xqo / async_app.py
Created April 26, 2018 17:55
Async Nerium
from aiohttp import web
from nerium import Query, ResultFormat
import ujson
async def resultset(request):
query = Query(request.match_info['query_name'],
**dict(request.rel_url.query))
query_result = query.result_set()
return web.json_response(query_result)
@tym-xqo
tym-xqo / whereismymac.py
Last active April 19, 2018 21:37
Simple script to get lat & long from Location Services on MacOS
# pip install pyobjc
import CoreLocation
def main():
location_mgr = CoreLocation.CLLocationManager.alloc().init()
location_mgr.startUpdatingLocation()
here = location_mgr.location()
print(list(here.coordinate()))
@tym-xqo
tym-xqo / sql_handler.py
Last active February 14, 2018 15:47
Frontmatter handler for SQL files
import re
import sqlite3
import unittest
import frontmatter
from frontmatter import YAMLHandler
class SQLHandler(YAMLHandler):
""" Subclass of YAMLHandler that uses SQL comment indicators `/* <comment> */` as frontmatter
@tym-xqo
tym-xqo / index.html
Last active December 6, 2017 17:15 — forked from gka/index.html
simple tables in D3
<!DOCTYPE html>
<html>
<head>
<title>Simple tables in D3</title>
<meta charset="utf-8">
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/build/d3-jetpack.min.js"></script>
<style type="text/css">
body { font-family: 'Helvetica Neue', Helvetica; font-weight: 300; padding: 20px;}
th { text-align: left; }
@tym-xqo
tym-xqo / example.txt
Created March 22, 2017 17:07
Export data from interactive python shell
$ python
>>> import sys
>>> v = 'some value for this variable'
>>> x = open('/path/to/somefile', 'w')
>>> sys.stdout = x
>>> print(v)
>>> x.close()
$ cat /path/to/somefile
some value for this variable
$
@tym-xqo
tym-xqo / Dockerfile
Last active December 8, 2022 22:13
pg_service.conf + psycopg2 example
FROM python:3-alpine
# install requirements for psycopg2
RUN apk update && apk add -u \
postgresql-dev \
gcc \
python3-dev \
musl-dev
RUN pip3 install psycopg2
@tym-xqo
tym-xqo / keep-docker-machine-up.bash
Last active May 10, 2016 19:16
docker-machine up and env set (good for adding to .bashrc)
#!/bin/bash
if [ $(docker-machine status default) != 'Running' ]; then
echo "start docker VM now [y/n]?"
read -n 1 start
if [ "$start" = "n" ]; then
:
else
docker-machine start default
eval $(docker-machine env default)
@tym-xqo
tym-xqo / date-loop.sh
Created March 18, 2016 20:20
loop-by-date.sh
#!/bin/bash
last="2016-02-23"
first="2015-12-31"
i=1
while [[ $last > $first ]]; do
this=$(date -I -d "$last - 3 days")
printf -v j "%02d" $i
def status_post(message, nickname, color):
token = os.getenv('STATUSTOKEN')
payload = {
'status': message,
'color': color,
'token': token
}
url = 'http://status.pedicel.xyz:5007'
headers = {'content-type': "application/json"}
url = '/'.join([url, nickname])