This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pip install pyobjc | |
import CoreLocation | |
def main(): | |
location_mgr = CoreLocation.CLLocationManager.alloc().init() | |
location_mgr.startUpdatingLocation() | |
here = location_mgr.location() | |
print(list(here.coordinate())) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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 | |
$ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) |