Skip to content

Instantly share code, notes, and snippets.

Paul Guelpa pguelpa

  • New York, NY
Block or report user

Report or block pguelpa

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@pguelpa
pguelpa / delete.sh
Created Sep 16, 2015
Postgres limited delete with filter
View delete.sh
export BATCH_SIZE=100000
export PGPASSWORD=xyz
export PGHOST=x.y.z
export PGUSER=abc
export PGDATABASE=def
count=0
until psql -c "DELETE FROM <table> WHERE id IN (SELECT id FROM <table> WHERE <time filter> <= NOW() - INTERVAL '24 hours' LIMIT ${BATCH_SIZE});" | grep -v "DELETE ${BATCH_SIZE}"
do
count=$((count + BATCH_SIZE))
View dnsmasq.service
[Unit]
Description=dnsmasq
After=docker.service
Requires=docker.service
[Service]
TimeoutStartSec=10m
ExecStartPre=-/usr/bin/docker kill dnsmasq
ExecStartPre=-/usr/bin/docker rm dnsmasq
ExecStartPre=/usr/bin/docker pull jamesawesome/dnsmasq:latest
@pguelpa
pguelpa / schema.json
Last active Aug 28, 2015
Event Schema
View schema.json
{
"$schema": "https://gist.githubusercontent.com/pguelpa/4d1ee633a43df9ba52b7/raw/6ff330bad658f9543d296589e23828310d6e8f4f/schema.json",
"title": "v0_platform_request_traces",
"description": "A schema to track events through a system",
"properties": {
"request_id": {
"type": "string",
"minLength": 36,
"maxLength": 36
},
View keybase.md

Keybase proof

I hereby claim:

  • I am pguelpa on github.
  • I am pguelpa (https://keybase.io/pguelpa) on keybase.
  • I have a public key whose fingerprint is 665D 1EA3 5930 70F2 B03E 91A9 8815 62F9 76B3 A0C8

To claim this, I am signing this object:

View gist:5935df7e90a46d49f681
DO $$DECLARE row record;
BEGIN
FOR row IN SELECT pid, query FROM pg_stat_activity WHERE query_start < NOW() - interval '30 minutes' LOOP
RAISE NOTICE 'Killing query: %s', row.query;
PERFORM pg_cancel_backend(row.pid);
END LOOP;
END$$;
@pguelpa
pguelpa / gist:5c13fa5949dd995c042d
Created Feb 4, 2015
Ruby / Redis + iterate through keys
View gist:5c13fa5949dd995c042d
iterator = nil
keys = []
while iterator != '0'
iterator, list = Redis.current.scan(iterator || 0, count: 1000)
keys += list.map { |l| l.split(':') }
puts "Found another #{list.length} keys, iterator at #{iterator}"
end
@pguelpa
pguelpa / gist:d7489184a124f3f75fa2
Created Jan 29, 2015
"rebalance" fleet units
View gist:d7489184a124f3f75fa2
#!/bin/sh -e
if [ ! -z ${DEBUG+x} ]
then
set -x
fi
if [ $# -eq 0 ]
then
echo "Usage: $0 unit ..."
@pguelpa
pguelpa / deis-upgrade
Created Dec 5, 2014
Upgrade a Deis cluster that doesn't use the standard database or cache
View deis-upgrade
#!/bin/bash -ue
#
# Rolling upgrade procedure
#
if test $# -lt 1; then
echo "Usage:"
echo " upgrade-deis seed-ip [number-of-routers]"
echo " by default the number-of-routers is 3"
You can’t perform that action at this time.