Skip to content

Instantly share code, notes, and snippets.

View waszi's full-sized avatar

Bartosz Waszak waszi

View GitHub Profile
@LucasRoesler
LucasRoesler / middleware.py
Last active June 27, 2023 17:01
A Django middleware that process JSON data into the appropriate GET or POST variable. I use this with AngularJS, by default POST requests are sent as JSON instead of the urlencoded data expected by Django.
class JSONMiddleware(object):
"""
Process application/json requests data from GET and POST requests.
"""
def process_request(self, request):
if 'application/json' in request.META['CONTENT_TYPE']:
# load the json data
data = json.loads(request.body)
# for consistency sake, we want to return
# a Django QueryDict and not a plain Dict.
@gauravvjn
gauravvjn / admin.py
Last active August 17, 2023 20:27
Use JSONField properties in Django admin filter Raw
"""
More details on the implementation and usage can be found at
https://www.pyscoop.com/django-jsonfield-attributes-in-admin-filter/
"""
from django.contrib import admin
from django.core.exceptions import ImproperlyConfigured
class JSONFieldFilter(admin.SimpleListFilter):
@mystix
mystix / RDS_INSTALL.bat
Last active June 19, 2023 01:42 — forked from anthonyeden/RDS_INSTALL.bat
Let's Encrypt & Microsoft Remote Desktop (Windows Server 2016) - Installation Script
@echo off
"C:\Program Files\letsencrypt-win-simple\letsencrypt.exe" --renew --baseuri "https://acme-v01.api.letsencrypt.org/"
REM run powershell script, bypassing security warnings for 3rd-party script
powershell -ExecutionPolicy bypass -File "C:\Program Files\letsencrypt-win-simple\RDS_INSTALL_CERT.ps1"
@dunglas
dunglas / example.php
Created April 19, 2018 06:25
A minimalist GraphQL client for PHP
<?php
$query = <<<'GRAPHQL'
query GetUser($user: String!) {
user (login: $user) {
name
email
repositoriesContributedTo {
totalCount
}