Skip to content

Instantly share code, notes, and snippets.

View pdeaudney's full-sized avatar

Paul De Audney pdeaudney

View GitHub Profile
@pdeaudney
pdeaudney / gist:28d991c3831c2f5963461dd47669bedd
Created July 17, 2023 23:04
there is no parameter $1 error
iot_devicereadings=# \d+ iot.device_reading
Table "iot.device_reading"
Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description
-----------+-----------------------------+-----------+----------+---------+----------+-------------+--------------+-------------
asset_id | character varying(36) | | not null | | extended | | |
vendor | character varying(36) | | not null | | extended | | |
vendor_id | character varying(36) | | not null | | extended | | |
type | character varying(36) | | not null | | extended | | |
value | real | | not null | | plain | | |
created | timestamp without time zone | | not null |
@pdeaudney
pdeaudney / jsonb_merge.sql
Created June 1, 2020 08:23 — forked from phillip-haydon/jsonb_merge.sql
Deep Merge two jsonb documents in PostgreSQL
CREATE OR REPLACE FUNCTION jsonb_merge(left JSONB, right JSONB) RETURNS JSONB AS $$
var mergeJSON = function (target, add) {
function isObject(obj) {
if (typeof obj == "object") {
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
return true; // search for first object prop
}
}
@pdeaudney
pdeaudney / query_planner.markdown
Created May 29, 2020 15:13 — forked from hgmnz/query_planner.markdown
PostgreSQL query plan and SQL performance notes

Types of index scans

Indexes

Sequential Scan:

  • Read every row in the table
  • No reading of index. Reading from indexes is also expensive.

Tuning Storm+Trident

Tuning a dataflow system is easy:

The First Rule of Dataflow Tuning:
* Ensure each stage is always ready to accept records, and
* Deliver each processed record promptly to its destination
#!/bin/bash
usage()
{
cat << EOF
usage: $0 options
This script set ownership for all table, sequence and views for a given database
Credit: Based on http://stackoverflow.com/a/2686185/305019 by Alex Soto
#!/bin/bash
usage()
{
cat << EOF
usage: $0 options
This script sets ownership for all tables, sequences, views, and functions for a given schema.
Run this script as your postgres OS user.
### Keybase proof
I hereby claim:
* I am pdeaudney on github.
* I am pdeaudney (https://keybase.io/pdeaudney) on keybase.
* I have a public key whose fingerprint is C6EF ED7A 301C 9785 1799 D249 0C8F D09B D8FD A3E3
To claim this, I am signing this object:
@pdeaudney
pdeaudney / warranty.rb
Created February 18, 2012 01:14 — forked from frimik/warranty.rb
Dell warranty fact
# Dell Facter module
#
# Author: Mikael Fridh <mfridh@marinsoftware.com>
# Date: 2011-11-24
#
# this is a rather substantial rewrite of the camptocamp puppet module
# https://github.com/camptocamp/puppet-dell
#
# The regex matching has been ripped out completely and replaced with
# some xpath expressions from Nokogiri. Unfortunately this means another
/*
* Write a Java program that reads one 6-digit integer from the user.
* It then prints out these 6 digits, each separated from the preceding one by 2 spaces.
*/
import java.util.*;
public class Week2Exercise6{
public static void main(String[] args){
System.out.println("Please enter in a single six digit integer:");
Scanner i = new Scanner(System.in);