Skip to content

Instantly share code, notes, and snippets.

View zedr's full-sized avatar
👾

Rigel Di Scala zedr

👾
View GitHub Profile
@mw3i
mw3i / django-database-standalone.py
Last active April 13, 2025 19:38
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
step 1: apply the subscription
cat <<EOF | oc create -f -
apiVersion: v1
kind: Namespace
metadata:
labels:
openshift.io/run-level: "1"
name: openshift-performance-addon
---
@productiveme
productiveme / fixmouselag.sh
Created December 21, 2020 10:15
Fix bluetooth mouse lag on Ubuntu
#!/bin/bash
MouseIdentifierString="Mouse"
writeOpts() {
sudo cat <<'EOF' | sudo tee -a /var/lib/bluetooth/$1/$2/info
[ConnectionParameters]
MinInterval=6
MaxInterval=7
Latency=0
@aalhour
aalhour / fib_micro_service.py
Created December 2, 2015 12:26
Fibonacci microservice using Python & Tornado.
import tornado.web
import tornado.ioloop
from tornado.options import define, options
define('port', default=45000, help='try running on a given port', type=int)
def fib():
a, b = 1, 1
while True:
yield a
@michaelBenin
michaelBenin / mustache.py
Created June 10, 2013 22:18
Problem: Sharing templates between backbonejs and django. I found that Backbone never needs to actually render out a whole page, only specific views, this allows me to render those views with the same templating language. If it is initial pageload, Backbone js just binds events and allows SEO and a faster page load time, as well as the page func…
from django import template
from django.conf import settings
import pystache
# Needed to register a custom template tag
register = template.Library()
# Decorator to register a tag that takes the context
@register.simple_tag(takes_context=True)
# Function which takes the django context class and the template string
@malthe
malthe / abstractrecordsproxy.py
Created December 12, 2010 16:38
Abstract records proxy for Plone's settings registry
from zope.component import getUtility
from zope.interface import Interface
from zope.interface import alsoProvides
from plone.registry.interfaces import IRegistry
from plone.app.registry.browser.controlpanel import ControlPanelFormWrapper
from plone.app.registry.browser.controlpanel import RegistryEditForm
from plone.z3cform import layout