Skip to content

Instantly share code, notes, and snippets.

@josegonzalez
josegonzalez / Dockerfile
Last active May 29, 2022 21:06
bootstrap a new dev server
FROM gitpod/openvscode-server:latest
USER root
ARG GO_VERSION=1.18.2.linux-amd64
RUN curl -o /tmp/go.tar.gz -sSL https://go.dev/dl/go1.18.2.linux-amd64.tar.gz && \
tar -C /usr/local -xzf /tmp/go.tar.gz && \
rm -rf /tmp/go.tar.gz
USER openvscode-server
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/go/bin
@josegonzalez
josegonzalez / redis_migrate.py
Last active January 15, 2024 14:39 — forked from iserko/redis_migrate.py
A simple script to migrate all keys from one Redis to another
#!/usr/bin/env python
import argparse
import redis
def connect_redis(conn_dict):
conn = redis.StrictRedis(host=conn_dict['host'],
port=conn_dict['port'],
db=conn_dict['db'])
return conn

Keybase proof

I hereby claim:

  • I am josegonzalez on github.
  • I am savant (https://keybase.io/savant) on keybase.
  • I have a public key ASBouJt4s02dheQkrfrsCQNKqsaHzxuhBpjL1RxtoMoEjQo

To claim this, I am signing this object:

@josegonzalez
josegonzalez / docker_sleep
Last active August 29, 2015 14:25
wait until a docker container has no more incoming traffic
#!/usr/bin/env python
#
# Returns once a container no longer has open connections
# Only works for containers using internal dns
# Sleeps 2 seconds between checks
#
# Usage:
#
# # wait until all traffic drains from a container before killing it
# docker_sleep $CONTAINER_ID $MAX_WAIT
<?php
/**
* APC-based WordPress Database Access Abstraction Object
*
* Extends the wpdb class in order to cache queries in APC
*
* Falls back to non-APC database when requesting an admin resource or
* the query modifies the database.
*
* Using something like Memcached might be better as we can namespace
<?php
class StatsD {
// StastD::timing("www.php.sql_query", 645);
public static function __callStatic($name, $arguments) {
if (!in_array($name, array('counter', 'gauge', 'timing'))) {
throw new Exception("Invalid function");
}
if (empty($arguments[0])) return false;
@josegonzalez
josegonzalez / README.md
Last active December 16, 2015 11:39 — forked from mbostock/.block

This choropleth encodes unemployment rates from 2008 with a quantize scale ranging from 0 to 15%. A threshold scale is a useful alternative for coloring arbitrary ranges.

@josegonzalez
josegonzalez / access.lua
Created December 3, 2012 18:26
Simple lua file enabling oauth support for nginx via nginx-lua and access_by_lua.
- certain endpoints are always blocked
if nginx_uri == "/_access_token" or nginx_uri == "/_me" then
ngx.exit(403)
end
-- import requirements
local cjson = require "cjson"
-- setup some app-level vars
local app_id = "APP_ID"
@josegonzalez
josegonzalez / nginx_release.sh
Last active October 11, 2019 15:46
Make an nginx release for ubuntu
#!/bin/bash
#####
# Builds a custom nginx
#
# RELEASE_TAGS="+your+tags+here"
# RELEASE_MAINTAINER="Your Name Here"
# RELEASE_MAINTAINER_EMAIL="hi@example.com"
# RELEASE_MESSAGE="Some message"
#
@josegonzalez
josegonzalez / nginx_release.sh
Created November 21, 2012 18:55
Make an nginx release for ubuntu
#!/bin/bash
#####
# Builds a custom nginx
#
# RELEASE_TAGS="+your+tags+here"
# RELEASE_MAINTAINER="Your Name Here"
# RELEASE_MAINTAINER_EMAIL="hi@example.com"
# RELEASE_MESSAGE="Some message"
#