Skip to content

Instantly share code, notes, and snippets.

View dmreiland's full-sized avatar

Dan Reiland dmreiland

View GitHub Profile
@dmreiland
dmreiland / gist:a38f24ecbba4917f2f0463920a4c7d71
Created January 5, 2017 20:11 — forked from jmindek/gist:62c50dd766556b7b16d6
DISTINCT ON like functionality for Redshift

distinct column -> For each row returned, return only the unique members of a set. Think of it as for each row in a projection, concatenate all the column values and return only the strings that are unique.

test_db=# SELECT DISTINCT parent_id, child_id, id FROM test.foo_table ORDER BY parent_id, child_id, id LIMIT 10;
parent_id | child_id | id
-----------+------------+-----------------------------
1000040 | 103 | 1000040|2645405726|0001|103
import boto3
import json
import logging
import time
logger = logging.getLogger()
logger.setLevel(logging.INFO)
def notify_on_error(message):
@dmreiland
dmreiland / example.json
Created August 7, 2017 20:24 — forked from sevennineteen/example.json
Example using Jinja2 to populate a JSON payload template
{ "path": "/content/geometrixx/my-first-jinja-page",
"properties": [
{ "name": "jcr:primaryType",
"value": "cq:Page" }],
"nodes": [
{ "path": "jcr:content",
"properties": [
{ "name": "jcr:primaryType",
"value": "cq:PageContent"},
@dmreiland
dmreiland / README-oneshot-systemd-service.md
Created February 7, 2018 04:48 — forked from drmalex07/README-oneshot-systemd-service.md
An example with an oneshot service on systemd. #systemd #systemd.service #oneshot

README

Services declared as oneshot are expected to take some action and exit immediatelly (thus, they are not really services, no running processes remain). A common pattern for these type of service is to be defined by a setup and a teardown action.

Let's create a example foo service that when started creates a file, and when stopped it deletes it.

Define setup/teardown actions

Create executable file /opt/foo/setup-foo.sh:

@dmreiland
dmreiland / daemon.py
Created August 6, 2018 19:49 — forked from marazmiki/daemon.py
Python daemon example
#!/usr/bin/env python
# coding: utf-8
import argparse
import os
import sys
import time
import atexit
import logging
import signal
@dmreiland
dmreiland / EXCEPT.sql
Created June 13, 2019 14:51 — forked from yancya/EXCEPT.sql
INTERSECT and EXCEPT for BigQuery
#standardsql
WITH a AS (
SELECT * FROM UNNEST([1,2,3,4]) AS n
), b AS (
SELECT * FROM UNNEST([4,5,6,7]) AS n)
SELECT * FROM a
@dmreiland
dmreiland / gist:aeee461dfcd59ab6012c5169c00ada09
Created March 10, 2020 12:35 — forked from Ray33/gist:ba189a729d81babc99d7cef0fb6fbcd8
Amazon Elastic Network Adapter (ENA) on CentOS 7
sudo su
yum --enablerepo=extras install epel-release
yum -y install patch dkms kernel-devel perl
yum update
#Required for kernel num 5:
yum --enablerepo=elrepo-kernel -y install kernel-ml-devel
reboot

Stevey's Google Platforms Rant

I was at Amazon for about six and a half years, and now I've been at Google for that long. One thing that struck me immediately about the two companies -- an impression that has been reinforced almost daily -- is that Amazon does everything wrong, and Google does everything right. Sure, it's a sweeping generalization, but a surprisingly accurate one. It's pretty crazy. There are probably a hundred or even two hundred different ways you can compare the two companies, and Google is superior in all but three of them, if I recall correctly. I actually did a spreadsheet at one point but Legal wouldn't let me show it to anyone, even though recruiting loved it.

I mean, just to give you a very brief taste: Amazon's recruiting process is fundamentally flawed by having teams hire for themselves, so their hiring bar is incredibly inconsistent across teams, despite various efforts they've made to level it out. And their operations are a mess; they don't real

@dmreiland
dmreiland / LearnGoIn5mins.md
Created January 5, 2021 21:35 — forked from prologic/LearnGoIn5mins.md
Learn Go in ~5mins
@dmreiland
dmreiland / UFW_ban_country.md
Created January 14, 2021 16:54 — forked from jasonruyle/UFW_ban_country.md
UFW to block countries