Skip to content

Instantly share code, notes, and snippets.

View mmontagna's full-sized avatar

Marco Montagna mmontagna

  • San Francisco, CA
View GitHub Profile
@mmontagna
mmontagna / 0_reuse_code.js
Created December 21, 2015 03:50
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@mmontagna
mmontagna / gist:32e2053425326947976bb63c5e66928d
Created August 30, 2016 22:52
benchmark_downloads_gcs.py
from gcloud import storage
import bson
import StringIO
import csv
import gzip
import time
import numpy
from multiprocessing import Process
@mmontagna
mmontagna / benchmark_storage_formats.py
Created August 30, 2016 22:52
benchmark_storage_formats.py
import bson
import json
import random
import time
import datetime
import pandas as pd
import numpy
import os, sys
import csv
@mmontagna
mmontagna / P
Created September 1, 2016 05:21
Process control PI sketch
def scope():
pv = [0]
def actuate(x):
pv[0] += x
def read():
return pv[0]
return actuate, read
@mmontagna
mmontagna / loggly-format.conf
Created November 18, 2016 00:11 — forked from okhwaja/loggly-format.conf
Loggly syslog tag regex for docker containers
$template LogglyFormat,"<%pri%>%protocol-version% %timestamp:::date-rfc3339% %HOSTNAME% %app-name% %procid% %msgid% [<token>@<port> tag=\"%syslogtag:R,ERE,1,ZERO,0:docker\/([^[]+)\[--end%\"] %msg%\n"
@mmontagna
mmontagna / memusg
Created July 26, 2017 19:06 — forked from netj/memusg
memusg -- Measure memory usage of processes
#!/usr/bin/env bash
# memusg -- Measure memory usage of processes
# Usage: memusg COMMAND [ARGS]...
#
# Author: Jaeho Shin <netj@sparcs.org>
# Created: 2010-08-16
############################################################################
# Copyright 2010 Jaeho Shin. #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #
@mmontagna
mmontagna / kill redshift connections to db.sql
Created November 25, 2017 21:07
kill redshift connections to db
select pg_terminate_backend(procpid) from pg_stat_activity where datname='data';
@mmontagna
mmontagna / ruby alias methods
Created February 9, 2018 19:48
ruby alias methods
class A
class << self
def set_opt
self.instance_eval do
define_method(:foo) do
puts "wrapped!"
super()
puts "end wrap"
@mmontagna
mmontagna / redis_usage.py
Created April 10, 2019 01:58 — forked from sherin/redis_usage.py
redis space usage report grouped by prefixes on keys
#!/usr/bin/env python
# production friendly
# slow if there are too many keys but the script will print partial outputs
# usage is an approximation for complex objects
import math
import redis
import urlparse
import os
@mmontagna
mmontagna / Postgres - Find Columns which are nearing capacity.sql
Last active September 4, 2019 19:33
Postgres - Find Columns which are nearing capacity
DO $$
DECLARE
sequence text;
columntype text;
warning_threshold bigint;
result bigint;
alerts text[];