Skip to content

Instantly share code, notes, and snippets.

@mjumbewu
mjumbewu / django urlpattern list .py
Last active February 8, 2024 20:40 — forked from ashishtajane/django urlpattern list .py
Get all URL patterns in django
# Open django shell and do following.
from django.urls import get_resolver
def show_urls(urllist, depth=0):
for entry in urllist:
print(' ' * depth, entry.pattern)
if hasattr(entry, 'url_patterns'):
show_urls(entry.url_patterns, depth + 1)
@mjumbewu
mjumbewu / gist:4667649
Last active February 5, 2024 17:59
Synaptic TouchPad properties on a Dell XPS 13
mjumbewu@mjumbewu-xps ~
$ uname -a
Linux mjumbewu-xps 3.5.0-22-generic #34+kamal11~DellXPS-Ubuntu SMP Fri Jan 11 09:12:57 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
mjumbewu@mjumbewu-xps ~
$ xinput list-props 12
Device 'CyPS/2 Cypress Trackpad':
Device Enabled (132): 1
Coordinate Transformation Matrix (134): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
Device Accel Profile (255): 1
<html>
<head>
<style>
#checker-board {
width: 400px;
height: 400px;
background-color: #ffbc00;
border: 10px solid rgba(0,0,0,0.65);
border-radius: 10px;
position: relative;
@mjumbewu
mjumbewu / timeout.js
Created August 19, 2022 14:48
A simple JavaScript function to allow using setTimeout with async/await.
function timeout(duration) {
return new Promise((resolve) => {
setTimeout(resolve, duration);
});
}
/*
Example:
async function dostuff() {
@mjumbewu
mjumbewu / 1-hexgrid_illustration.svg
Last active March 25, 2021 18:17
PostGIS function to generate a grid of hexagonal cells in a PostgreSQL database
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<html>
<head>
<style>
html,body {
padding: 0;
margin: 0;
}
#left-paddle {
background-color: green;
# =============================================================================
# ON THE SERVER...
# Check the amount of disk space available on root (/) partition
df -h
# See where space is being consumed
cd /; sudo du -h --max-depth=1
# In this case, most was in /emergence; further digging and du-ing
@mjumbewu
mjumbewu / nginx.conf
Created June 2, 2016 01:27
Simple SSL-enabled nginx config to serve static files
server {
listen 80;
return 301 https://\$host\$request_uri;
}
server {
listen 443 ssl;
ssl_certificate [PATH_TO_SSL_CERT];
ssl_certificate_key [PATH_TO_SSL_CERT_KEY];
@mjumbewu
mjumbewu / xpath.md
Last active February 24, 2020 01:16
SEPTA Key Trip Grid Parser
@mjumbewu
mjumbewu / renderers.py
Last active November 28, 2019 09:19
A Django REST Framework renderer which renders data from DRF serializers into CSV. The underlying functions will render any hierarchy of Python primitive containers to CSV.
import csv
from collections import defaultdict
from rest_framework.renderers import *
from StringIO import StringIO
class CSVRenderer(BaseRenderer):
"""
Renderer which serializes to CSV
"""