Skip to content

Instantly share code, notes, and snippets.

View jfilipe's full-sized avatar

Jason Filipe jfilipe

  • theScore, Wave
  • Toronto, Canada
View GitHub Profile
@jfilipe
jfilipe / index.html
Created June 13, 2012 19:29 — forked from ilyabo/index.html
D3 tooltip using jQuery tipsy
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="jquery.tipsy.js"></script>
<link href="tipsy.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="chart"></div>
@jfilipe
jfilipe / proxy_views.py
Created September 28, 2012 21:42 — forked from joeshaw/proxy_views.py
super-hacky flask proxy
# coding:utf-8
# Copyright 2011 litl, LLC. All Rights Reserved.
import httplib
import re
import urllib
import urlparse
from flask import Blueprint, request, Response, url_for
from werkzeug.datastructures import Headers
@jfilipe
jfilipe / gist:3802277
Created September 28, 2012 21:55 — forked from anjackson/gist:2888380
Making a Bottle app that routes to a proxy
import bottle
from wsgiproxy.app import WSGIProxyApp
# Remove "hop-by-hop" headers (as defined by RFC2613, Section 13)
# since they are not allowed by the WSGI standard.
FILTER_HEADERS = [
'Connection',
'Keep-Alive',
'Proxy-Authenticate',
'Proxy-Authorization',
@jfilipe
jfilipe / gist:7809493
Created December 5, 2013 17:17
Displays Django ORM calls as they are being executed.
# %cpaste the following code in a shell_plus session
import logging
l = logging.getLogger('django.db.backends')
l.setLevel(logging.DEBUG)
l.addHandler(logging.StreamHandler())
@jfilipe
jfilipe / gist:9834103
Last active August 29, 2015 13:57
Generate time based links for private bunches (nibbler.io).
import hmac
from hashlib import sha1
from time import time
NIBBLER_CUSTOMER_ID = 'xxx'
PRIVATE_BUNCH_NAME = 'xxx'
FILENAME = 'xxx'
LINK_EXPIRE_SECONDS = 60
NIBBLER_ACCESS_KEY = 'xxx'
@jfilipe
jfilipe / keybase.md
Created June 19, 2014 19:29
keybase.md

Keybase proof

I hereby claim:

  • I am jfilipe on github.
  • I am jfilipe (https://keybase.io/jfilipe) on keybase.
  • I have a public key whose fingerprint is 851D DE4A B21B 56FD 62B0 DBFE C7A2 1F04 B319 5AA1

To claim this, I am signing this object:

@jfilipe
jfilipe / ar.rb
Created May 26, 2016 19:20
Displays ActiveRecord queries in the console as they happen.
# in a console session:
ActiveRecord::Base.logger = Logger.new(STDOUT)
@jfilipe
jfilipe / sidekiq_transfer.rake
Created January 15, 2018 18:25 — forked from jagthedrummer/sidekiq_transfer.rake
Rake task to transfer Sidekiq jobs from one redis instance to another
# This task should be run inside an environment that is already configured to connect to the redis
# instance that we're transfering AWAY FROM.
#
# The task should be handed the URL of the redis instance that we're MOVING TO.
#
# To run it and pass in the destination Redis you'd do something like this:
# rake sidekiq:transfer[redis://...]
#
# As jobs are added to the destination Redis, they're deleted from the source Redis. This
# allows the task to be restarted cleanly if it fails in the middle due to a network error
@jfilipe
jfilipe / vcl-regex-cheat-sheet
Created January 24, 2018 19:09 — forked from dimsemenov/vcl-regex-cheat-sheet
Regular expression cheat sheet for Varnish (.vcl). Examples of vcl regexp. Found here http://kly.no/varnish/regex.txt (by Kristian Lyngstøl)
Regular expression cheat sheet for Varnish
Varnish regular expressions are NOT case sensitive. Varnish uses POSIX
regular expressions, for a complete guide, see: "man 7 regex"
Basic matching:
req.url ~ "searchterm"
True if req.url contains "searchterm" anywhere.
req.url == "searchterm"
@jfilipe
jfilipe / exclude.sql
Created February 7, 2018 17:38 — forked from fphilipe/exclude.sql
PostgreSQL EXCLUDE constraint
CREATE EXTENSION btree_gist;
CREATE TABLE room_reservations (
room_id integer,
reserved_at timestamptz,
reserved_until timestamptz,
canceled boolean DEFAULT false,
EXCLUDE USING gist (
room_id WITH =, tstzrange(reserved_at, reserved_until) WITH &&
) WHERE (not canceled)