Skip to content

Instantly share code, notes, and snippets.

View wyleung's full-sized avatar

Wai Yi Anthony Leung wyleung

View GitHub Profile
from django.core.serializers.json import Serializer as JsonSerializer
# because of the way serializers are registered, we need to import the Deserializer
from django.core.serializers.json import Deserializer # noqa
# There's a bug in Django currently, and it doesn't look like it'll be fixed till Django 2.1.
# https://code.djangoproject.com/ticket/24607
# Changes are based on https://github.com/django/django/pull/8370
@ricjcosme
ricjcosme / dump-restore
Created September 13, 2017 17:33
DUMP / RESTORE PostgreSQL Kubernetes
DUMP
// pod-name name of the postgres pod
// postgres-user database user that is able to access the database
// database-name name of the database
kubectl exec [pod-name] -- bash -c "pg_dump -U [postgres-user] [database-name]" > database.sql
RESTORE
// pod-name name of the postgres pod
// postgres-user database user that is able to access the database
// database-name name of the database
@perliedman
perliedman / click-through-layers.js
Created March 7, 2017 15:11
Click through multiple layers of Leaflet VectorGrid
// Since overlays are VectorGrid layers with canvas rendering,
// they don't support clicking through them (the topmost canvas
// swallows the event, lower layers will not see it).
// We workaround this by this hack (inspired by
// http://www.vinylfox.com/forwarding-mouse-events-through-layers/):
//
// All overlays are in their own Leaflet pane. When a click hits a
// layer in the pane, we first handle the event like normal, and then
// hit the event handler below this comment.
//
@pbabics
pbabics / gitlab-registry-stats.py
Created January 27, 2017 11:31
Prints statistics per project in gitlab registry (usefull for debugging purposes)
#!/usr/bin/env python2.7
import os
import json
import argparse
import math
def convert_size(size_bytes):
if (size_bytes == 0):
return '0B'
@brattonc
brattonc / README.md
Last active November 20, 2023 17:14
D3 Liquid Fill Gauge

Liquid Fill Gauge v1.1 - 7/14/2015

Changes:

  • Added support for updating the gauge value after loading is complete. The loadLiquidFillGauge method now returns an object with an update method which allows the gauge value to be changed. Click any of the gauges above to randomly update their value.

Configurable features include:

  • Changeable min/max values.
  • All colors.
@jabney
jabney / setOps.js
Last active February 1, 2023 10:55
Fast JavaScript set operations: union, intersection, difference, complement, and equals. Includes support for objects.
// setOps.js MIT License © 2014 James Abney http://github.com/jabney
// Set operations union, intersection, symmetric difference,
// relative complement, equals. Set operations are fast.
(function(so) {
'use strict';
var uidList = [], uid;
// Create and push the uid identity method.
#!/bin/bash
JQPATH=$(which jq)
if [ "x$JQPATH" == "x" ]; then
echo "Couldn't find jq executable." 1>&2
exit 2
fi
set -eu
shopt -s nullglob
@drmalex07
drmalex07 / convert-geojson-to-wkt.py
Created May 12, 2014 22:13
Convert GeoJSON to/from WKT in Python. #python #geojson #geometry
import json
import geojson
from shapely.geometry import shape
o = {
"coordinates": [[[23.314208, 37.768469], [24.039306, 37.768469], [24.039306, 38.214372], [23.314208, 38.214372], [23.314208, 37.768469]]],
"type": "Polygon"
}
s = json.dumps(o)
@pjobson
pjobson / remove_mcafee.md
Last active March 26, 2024 04:26
OSX McAfee Removal

Removal of McAfee from OSX

Note: This was written in 2015, it may be out of date now.

There are a lot of commands here which I use sudo if you don't know what you're doing with sudo, especially where I rm you can severely screw up your system.

There are many reasons which you would want to remove a piece of software such as McAfee, such as not wanting it to hammer your CPU during work hours which seems like primetime for a virus scan.

I intend this to be a living document, I have included suggestions from peoples' replies.

@brettstimmerman
brettstimmerman / gist:382508
Created April 28, 2010 18:33
Show svn info in your bash prompt
# Returns (svn:<revision>:<branch|tag>[*]) if applicable
svn_prompt() {
if [ -d ".svn" ]; then
local branch dirty rev info=$(svn info 2>/dev/null)
branch=$(svn_parse_branch "$info")
# Uncomment if you want to display the current revision.
#rev=$(echo "$info" | awk '/^Revision: [0-9]+/{print $2}')