Skip to content

Instantly share code, notes, and snippets.

@aidos
aidos / ak_combine_sql
Created September 5, 2024 17:37
Combine postgres log lines to put sql queries on a single line
#!/bin/awk -f
#
# Handles combining log lines from postgres since the statements can have new lines in
# We identify the 2 classes of lines by the timestamp (or not) at the start of the line
#
# This makes grepping in the logs much easier
# reset buffer to current log line
/^[0-9]{4}-[0-9]{2}-[0-9]{2}/ {
print buffer
@aidos
aidos / ak_locate_in_log
Created September 5, 2024 17:32
Quick dirty hack to find the location of a timestamp in a huge log file (assuming logs are roughly in order)
#!/bin/bash
#
# Quick dirty hack to let me find the location of a timestamp in a huge log file
file="$1"
date="$2"
if [ -z "$file" ] || [ -z "$date" ]; then
echo 'Invalid arguments! Example use:'
echo ' ak_locate_in_log ./path_to_file "2023-08-13 01:00:02.085"'
@aidos
aidos / shapley_sqla.py
Last active September 15, 2015 16:30
Using Shapley types with geoalchemy2 / sqlalchemy
import binascii
import sqlalchemy.types
import geoalchemy2.types
from geoalchemy2.shape import WKTElement
import shapely.wkb
import shapely.geometry
class ShapelyGeo(sqlalchemy.types.TypeDecorator):
#!/usr/bin/env python
import sys
import boto
import pprint
# set credentials
ACCESS_KEY = "<access key>"
SECRET_KEY = "<security key>"
@aidos
aidos / keybase.md
Created May 15, 2014 13:24
keybase.md

Keybase proof

I hereby claim:

  • I am aidos on github.
  • I am aidan (https://keybase.io/aidan) on keybase.
  • I have a public key whose fingerprint is F0FB 3CD3 53EB E21B 9508 2FA1 5041 550F 833B E5A9

To claim this, I am signing this object:

#!/bin/sh
# start with
# cd /path/to/your/django/project
# sudo keep_alive.sh start projectname portnumber
# in another window
# sudo keep_alive.sh restart/stop projectname