Skip to content

Instantly share code, notes, and snippets.

View ezk84's full-sized avatar

Ezequiel Muns ezk84

  • Berlin, Germany
View GitHub Profile
@ezk84
ezk84 / test-pgp-steam.js
Created October 23, 2020 14:44
Testing pg-promise query streaming with dependent secondary query for every streamed row
#!/usr/bin/env node
const pgPromise = require("pg-promise");
const Bluebird = require("bluebird");
const QueryStream = require("pg-query-stream");
const pgpInit = { promiseLib: Bluebird, capSQL: true };
const pgp = pgPromise(pgpInit);
const db = pgp({
host: process.env.POSTGRES_HOST,
port: Number.parseInt(process.env.POSTGRES_PORT || "5432"),
@ezk84
ezk84 / useful-bash-snippets.sh
Created December 20, 2017 12:06
List of useful bash snippets for common dev tasks.
#!/bin/bash
# rename files to lowercase
for F in `find -type f | grep -P '\/.*[A-Z]+.*$'`; do git mv $F ${F,,}; done;
# Search and replace: Use ack for Perl-style regexp pattern finding combined with sed for replacing
# Turn resource filenames mentions into lowercase
ack '(\w*[A-Z]+\w*\.(:?jpg|png|mp3|JPG|PNG|MP3))' src/ -o --noheading | \
while IFS=":" read -r FILE LINE MATCH; do \
sed -i "s/$MATCH/${MATCH,,}/" $FILE;
@ezk84
ezk84 / changetz.py
Created November 12, 2013 01:57
Changing timezones in python
import dateutil.parser
import pytz
input = '2013-10-13T00:59:45Z' # Zulu time = UTC
tz_syd = pytz.timezone('Australia/Sydney')
dt_utc = dateutil.parser.parse(intput)
dt_syd = dt_utc.astimezone(tz_syd)
print dt_syd.isoformat() # prints 2013-10-13T11:59:45+11:00