Skip to content

Instantly share code, notes, and snippets.

@jriquelme
jriquelme / redshift_py_uuid5_udf.sql
Created April 23, 2020 21:06
Redshift UDF in Python to get an UUID v5
-- Use:
-- select f_py_uuid5('30fb0513-dddf-4801-ac98-dacc8b7953e5', 'jorge@larix.cl');
-- > d6d2210e-b94c-5a26-95b7-ccf97f29ad1f
create or replace function f_py_uuid5(namespace varchar, name varchar)
returns varchar
immutable
as $$
import uuid
return uuid.uuid5(uuid.UUID(namespace), name).__str__()
$$ language plpythonu;
@jriquelme
jriquelme / elastic_sample.go
Created November 29, 2019 15:14
Signing of Elastic requests (https://github.com/elastic/go-elasticsearch) according to AWS v4 Signing process
cfg, err := external.LoadDefaultAWSConfig()
if err != nil {
panic(err)
}
esCfg := elasticsearch.Config{
Transport: &awssigner.V4Signer{
RoundTripper: http.DefaultTransport,
Credentials: cfg.Credentials,
Region: cfg.Region,
},
@jriquelme
jriquelme / build-img.py
Created March 23, 2018 19:09
Python script to build simple Docker images using GO binaries (located in $GOPATH/bin)
import argparse
import io
import os
import tarfile
import docker
parser = argparse.ArgumentParser()
parser.add_argument('app', help='GO app name (located in $GOPATH/bin/)')
parser.add_argument('tag', help='Docker image tag')
@jriquelme
jriquelme / unmarshal.go
Last active March 14, 2018 01:18
Custom UnmarshalJSON implementation to support a single property with string/object values
package main
import (
"encoding/json"
)
type Business struct {
ID string `json:"id"`
Name string `json:"name"`
}
@jriquelme
jriquelme / clone_redis.py
Last active May 9, 2016 14:56 — forked from jimmyislive/clone_redis.py
Redis Elasticache Export
from optparse import OptionParser
import sys
import redis
__author__ = 'Jimmy John'
__doc__ = '''
This is a script to make a copy of a redis db. Mainly to be used for cloning AWS Elasticache
instancces. Elasticache seems to disable the SAVE/BGSAVE commands and you do not have access to
the physical redis instances. The UI allows you to create 'Snapshots', but no way to download
@jriquelme
jriquelme / kstest.go
Created January 20, 2016 14:43
random errors in kinesalite using NextShardIterator
package main
import (
"fmt"
"log"
"strconv"
"sync"
"time"
"github.com/aws/aws-sdk-go/aws"