Skip to content

Instantly share code, notes, and snippets.

View ergo70's full-sized avatar

Ernst-Georg Schmid ergo70

View GitHub Profile
@ergo70
ergo70 / __init__.py
Last active April 1, 2019 09:43
OpenWeatherMap FDW
import requests
from multicorn import ForeignDataWrapper
from multicorn.utils import log_to_postgres, ERROR
__author__ = "Ernst-Georg Schmid"
__copyright__ = "Copyright (c) 2019 Ernst-Georg Schmid"
__license__ = "PostgreSQL"
__version__ = "2.0"
class OWMForeignDataWrapper(ForeignDataWrapper):
@ergo70
ergo70 / orientation.py
Created January 18, 2019 09:29
orientation.py
from vectors import Vector
from math import atan2
v1 = Vector(70.47130647130646,93.56190476190476,316.37118437118437) # Schreibtisch
v2 = Vector(73.91990231990232,96.26080586080586,328.06642246642247) # Schreibtisch + 20 h
v3 = Vector(-87.71428571428571,-183.37533577533577,-63.27423687423687) # Fenster
m1 = v1.magnitude()
m2 = v2.magnitude()
m3 = v3.magnitude()
@ergo70
ergo70 / CC2650.py
Last active December 6, 2018 14:51
import time
import struct
import os
import uuid
import json
from boto3 import resource
from boto3.dynamodb.conditions import Key
from bluepy.btle import UUID, Peripheral, Scanner
from decimal import Decimal
from datetime import datetime
@ergo70
ergo70 / ed25519.sql
Last active November 30, 2018 11:13
CREATE EXTENSION IF NOT EXISTS plpython3u;
CREATE OR REPLACE FUNCTION py_create_ed25519_keypair ()
RETURNS text[]
AS $$
import axolotl_curve25519 as curve
import os
import base64
randm32 = os.urandom(32)
DROP TYPE public.fraction CASCADE;
CREATE TYPE public.fraction AS
(z numeric(1000,0),
n numeric(1000,0));
CREATE OR REPLACE FUNCTION frac_make_fraction(z NUMERIC(1000,0), n NUMERIC(1000,0))
RETURNS fraction AS $$
declare retval fraction;
BEGIN
@ergo70
ergo70 / cats.py
Last active November 19, 2016 21:51
psycopg2 asynchronous cache updates w. LISTEN/NOTIFY and tcn
# -*- coding: utf-8 -*-
"""
Created on Sun Nov 13 00:00:06 2016
@author: ergo
"""
import select
import psycopg2
import psycopg2.extensions
import threading
@ergo70
ergo70 / notify.py
Created November 13, 2016 17:54
psycopg2 asynchronous notifications w. LISTEN/NOTIFY
# -*- coding: utf-8 -*-
"""
Created on Sun Nov 13 00:00:06 2016
@author: ergo
"""
import select
import psycopg2
import psycopg2.extensions
@ergo70
ergo70 / __init__.py
Created March 9, 2016 20:27
Multicorn soilgrids_fdw_json
from multicorn import ForeignDataWrapper
import urllib2
class SoilGridsForeignDataWrapper(ForeignDataWrapper):
def __init__(self, options, columns):
super(SoilGridsForeignDataWrapper, self).__init__(options, columns)
def execute(self, quals, columns):
@ergo70
ergo70 / __init__.py
Created February 12, 2016 22:00
Multicorn soilgrids_fdw
from multicorn import ForeignDataWrapper
import json
import urllib2
class SoilGridsForeignDataWrapper(ForeignDataWrapper):
def __init__(self, options, columns):
super(SoilGridsForeignDataWrapper, self).__init__(options, columns)
@ergo70
ergo70 / insert.sql
Created January 28, 2016 14:05
Insert
INSERT INTO plr_modules VALUES (0, 'library(e1071)');
INSERT INTO plr_modules VALUES (1, 'mysvm <- readRDS("mysvm.RDS")');