Skip to content

Instantly share code, notes, and snippets.

@seanickle
seanickle / year extract from timestamp.md
Last active December 26, 2018 19:30
athena sql notes
  • useful functions, applicable when using a groupby,
AVG(*)
min(*) max(*)
count(*)
  • conversions
from_unixtime()
@seanickle
seanickle / gist:6a66c90d0f8a41342b9ed19785fcbc6d
Created November 2, 2018 22:35
line profiler profile yay
* great tool!
https://github.com/rkern/line_profiler
@seanickle
seanickle / blah.md
Created November 2, 2018 16:03
cool python trace hanging stall hang debug tool

python -m trace --trace YOURSCRIPT.py
@seanickle
seanickle / API Gateway notes.md
Created October 29, 2018 21:56
API Gateway notes

mock endpoint

  • Integration Request
    • -> Integration type: mock

    • -> Mapping template

      • application/json
       {"statusCode": 201,
       "message": "{\"hi\":\"0.345\"}"}
      
@seanickle
seanickle / .bashrc colors prompt.md
Created October 17, 2018 15:41
.bashrc colors prompt
export PS1="\e[0;36mblah\e[m \$"
@seanickle
seanickle / my_ssh_tunnel
Created October 5, 2018 20:43
ssh tunnel
# common
local_port=55432
destination_port=5432
#
db=blahblah.rds.amazonaws.com
tunnel_box=my-tunnel-box-blah
echo "Run tunnel on ${local_port}:${db}:${destination_port} on \"${tunnel_box}\"."
ssh -N -L ${local_port}:${db}:${destination_port} ${tunnel_box}
@seanickle
seanickle / .block
Last active October 2, 2018 03:25 — forked from kerryrodden/.block
Sequences sunburst
license: apache-2.0
@seanickle
seanickle / AWS Athena timestamp select query .md
Last active September 4, 2023 00:51
AWS Athena timestamp select query

Doing a SELECT on a specific timestamp range

  • Here, the Athena table athena_table has the columns timestamp, day, month, year, id
select timestamp,month,day,year,id
from athena_table

WHERE month = 8 and day = 15
AND (CAST(timestamp as varchar) BETWEEN '2018-08-15 22:00:00' AND '2018-08-15 22:10:00')
 
@seanickle
seanickle / quick slices.md
Created July 13, 2018 20:47
quick slices

what

Partition a vector. Note for now, this leaves out any leftover items that do not fit in a slice.

code

import math

def get_partitions(vec, slice_size):
    num_slices = int(math.ceil(len(vec)/slice_size))
 slices = [vec[k*slice_size:k*slice_size+slice_size] for k in range(num_slices)]
@seanickle
seanickle / json encoding notes.md
Last active June 30, 2018 14:49
json encoding

json encoder , special

from decimal import Decimal
import json

class S3JSONEncoder(json.JSONEncoder):
    def default(self, obj):
        if isinstance(obj, Decimal):
            return obj.to_eng_string()
 if isinstance(obj, datetime):