Skip to content

Instantly share code, notes, and snippets.

@otov4its
otov4its / null_char_field.py
Last active January 16, 2017 15:48
Django NullCharField subclass of the CharField that allows empty strings to be stored as NULL in database
from django.db.models import CharField
from django.core.exceptions import ImproperlyConfigured
from django.utils.translation import ugettext_lazy as _
class NullCharField(CharField):
"""
Subclass of the CharField that allows
empty strings to be stored as NULL in database
"""
Benchmark results:
Date: 2016/03/20
Version: asgi_redis 0.8.3 / daphne master / channels master / cpython 2.7.11
Environment: AWS, 3x m3.large (1 daphne, 1 worker, 1 redis)
Source: 1x m3.medium, different AZ, ab for HTTP, channels benchmarker for WS
HTTP GET, Django View (concurrency 10, 10,000 total)
Failures: 0.0%
Rate: 160 req/s
@AnthonySheetz
AnthonySheetz / cronitor.sh
Last active October 21, 2019 10:25 — forked from erchn/cronitor.sh
Cronitor wrapper script for start/stop notifications, now with proper encoding of stderror and optional dumping of stdout
#!/bin/bash
#
# This script surrounds the command passed in with start and finish notifications
# to the cronitor monitoring application.
#
# === SETUP
#
# * Make sure the cronitor script is executable.
#
# chmod +x cronitor
@gmr
gmr / timespent_ranking.py
Created January 5, 2012 22:09
Reads in a minecraft server log ranking users by time spent
"""
Minecraft Server Log Time Spent Ranking
"""
__author__ = 'Gavin M. Roy'
__email__ = 'gavinmroy@gmail.com'
__since__ = '2012-01-05'
import datetime
import operator
@boxrick
boxrick / image-cleanup.sh
Created October 29, 2018 17:59
Script to cleanup Google Cloud - GCP - virtual machine images based on project and number of desired images
#!/bin/bash
# Script to cleanup GCP virtual machine images
# How many images of this family do we wish to retain
desired_images=8
image_project="PROJECTHERE"
clean_images()
{
# Function to clean up images, set the default family to megatron base
@lavoiesl
lavoiesl / process-mysqldump.c
Last active October 4, 2024 20:10
Add newlines before parenthesis for a SQL mysqldump
// gcc -O2 -Wall -pedantic process-mysqldump.c -o process-mysqldump
// Usage: cat dump.sql | process-mysqldump
// Or : process-mysqldump dump.sql
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#define BUFFER 100000
@mw3i
mw3i / django-database-standalone.py
Last active July 18, 2025 06:52
Truly Standalone Django-ORM Wrapper
'''
Proof of Concept:
Django devs built an ORM that seems way more straightforward than many existing tools. This class lets you leverage the django-orm without any project settings or other aspects of a django setup.
There are probably weak points and functionality missing, but it seems like a relatively intuitive proof of concept
'''
import os
import django
from django.conf import settings
@oleq
oleq / _README.md
Last active November 16, 2025 12:17
A2DP audio streaming using Raspberry PI (Raspbian Jessie)

What is this all about?

This tutorial will turn your Raspberry PI into a simple Bluetooth audio receiver, which plays music through connected speakers. It's like a regular car audio system, but it can be used anywhere and it's a good value.

   Audio source (i.e. smartphone) 
                |
                v
 (((  Wireless Bluetooth Channel  )))
 |
@perrygeo
perrygeo / base64_padding.md
Last active December 9, 2025 17:50
Avoiding TypeError: Incorrect padding with Python's base64 encoding

Avoiding padding errors with Python's base64 encoding

>>> import base64
>>> data = '{"u": "test"}'
>>> code = base64.b64encode(data)
>>> code
'eyJ1IjogInRlc3QifQ=='