Skip to content

Instantly share code, notes, and snippets.

View gideonthomas's full-sized avatar

gideonthomas gideonthomas

  • Toronto, Canada
View GitHub Profile
@gideonthomas
gideonthomas / middleware.py
Created May 24, 2018 01:37
Log Django Query count
from django.db import connection
class QueryCountDebugMiddleware:
def __init__(self, get_response):
self.get_response = get_response
"""
This middleware will log the number of queries run
and the total time taken for each request (with a
status code of 200). It does not currently support
@gideonthomas
gideonthomas / read-tuple-env.py
Created February 21, 2018 21:19
Read tuple environment variable
import environ
env = environ.Env(TESTVAR=(str, '[]'))
CORS_ORIGIN_REGEX_WHITELIST = eval(env('CORS_ORIGIN_REGEX_WHITELIST'))
## .env possibilities
# CORS_ORIGIN_REGEX_WHITELIST=[r'foobar\d{3,}']
# CORS_ORIGIN_REGEX_WHITELIST=[r'network-pulse-staging-pr-\d{3,}.herokuapp\.com']
# CORS_ORIGIN_REGEX_WHITELIST=[r'network-pulse-staging-pr-\d{3,}.herokuapp\.com', r'randomdomain\.com']
const fs = require("fs");
const path = require("path");
const propertiesParser = require("properties-parser");
const colors = require("colors/safe");
const async = require("async");
const locale = process.argv[2];
const clientKeys = [
"popularTags",

Keybase proof

I hereby claim:

  • I am gideonthomas on github.
  • I am gideonthomas (https://keybase.io/gideonthomas) on keybase.
  • I have a public key whose fingerprint is B306 F0E5 6E55 324D B896 1E98 74F9 A0A9 013E BAAF

To claim this, I am signing this object:

it('should successfully sync changes in a long file', function (done) {
var content;
var strcontent = "<!DOCTYPE html>\n<html>\n<head>\n <meta charset=\"utf-8\">\n <title>Sample HTML File</title>\n</head>\n<body>\n <h1>Webmaker</h1>\n <img src=\"webmaker-logo.jpg\">\n</body>\n</html>\n I have now changed this file";
fs.mkdir('/test', function (err) {
expect(err).to.not.exist;
fs2.mkdir('/test', function (err) {
expect(err).to.not.exist;
fs.writeFile('/test/index', strcontent, function (err) {
expect(err).to.not.exist;