Skip to content

Instantly share code, notes, and snippets.

View vigo's full-sized avatar
📺
Everything that has a beginning has an end.

Uğur Özyılmazel vigo

📺
Everything that has a beginning has an end.
View GitHub Profile
@ogrrd
ogrrd / dnsmasq OS X.md
Last active May 22, 2026 03:13
Setup dnsmasq on OS X

Never touch your local /etc/hosts file in OS X again

To setup your computer to work with *.test domains, e.g. project.test, awesome.test and so on, without having to add to your hosts file each time.

Requirements

Install

@tobiasmcnulty
tobiasmcnulty / decorators.py
Last active May 5, 2019 07:29
Django database router, based on django-balancer, that sends reads for the specified models to the RoundRobinMasterSlaveRouter router in django-balancer. Uses thread locals to determine whether or not the it has been enabled for the current request. Will raise an exception if views or other code attempt to use it for write queries.
from functools import wraps
from routers import ForceReadForModelsRouter
__all__ = ['uses_forced_read_router']
def uses_forced_read_router(func):
@wraps(func)
def wrapper(req, *args, **kwargs):
@tobiasmcnulty
tobiasmcnulty / writecache.py
Created September 2, 2013 20:11
Simple write-through cache for Django querysets
def get_cache_key(model, pk):
"""
Generates a cache key based on ``WRITE_CACHE_PREFIX``, the cache key prefix
defined in the settings file (if any), the Django app and model name, and
the primary key of the object.
"""
params = {
'prefix': getattr(settings, 'WRITE_CACHE_PREFIX', ''),
'app': model._meta.app_label,
'model': model._meta.object_name,
@fkei
fkei / example-gunicorn.py
Last active December 22, 2015 04:49
gunicorn sample config
import multiprocessing
# Turn on debugging in the server. [False]
debug=True
# Install a trace function that spews every line executed by the server. [False]
spew=False
# The Access log file to write to. [None]
#accesslog='/var/log/gunicorn.access.log'
@dnmellen
dnmellen / test_views.py
Last active May 29, 2023 13:31
How to create a unittest for a "View" Mixin (Django Testing)
from django.test import TestCase, RequestFactory
from django.views.generic import TemplateView
from ..lib.views import YourMixin
class YourMixinTest(TestCase):
'''
Tests context-data in a Django Mixin like a boss
'''
@millermedeiros
millermedeiros / osx_setup.md
Last active April 4, 2026 00:28
Mac OS X setup

Setup Mac OS X

I've done the same process every couple years since 2013 (Mountain Lion, Mavericks, High Sierra, Catalina) and I updated the Gist each time I've done it.

I kinda regret for not using something like Boxen (or anything similar) to automate the process, but TBH I only actually needed to these steps once every couple years...

@plentz
plentz / nginx.conf
Last active May 27, 2026 03:31
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@justinas
justinas / 1_singlehost.go
Last active November 29, 2023 11:41
Go middleware samples for my blog post. http://justinas.org/writing-http-middleware-in-go/
package main
import (
"net/http"
)
type SingleHost struct {
handler http.Handler
allowedHost string
}
@janily
janily / Breakpoints
Created January 16, 2014 11:36
Mobile-first CSS Media Queries Breakpoints
@media (min-width:320px) { /* smartphones, portrait iPhone, portrait 480x320 phones (Android) */ }
@media (min-width:480px) { /* smartphones, Android phones, landscape iPhone */ }
@media (min-width:600px) { /* portrait tablets, portrait iPad, e-readers (Nook/Kindle), landscape 800x480 phones (Android) */ }
@media (min-width:801px) { /* tablet, landscape iPad, lo-res laptops ands desktops */ }
@media (min-width:1025px) { /* big landscape tablets, laptops, and desktops */ }
@media (min-width:1281px) { /* hi-res laptops and desktops */ }
@okunishinishi
okunishinishi / Remove all git tags
Created March 8, 2014 03:12
Delete all git remote tags
#Delete local tags.
git tag -l | xargs git tag -d
#Fetch remote tags.
git fetch
#Delete remote tags.
git tag -l | xargs -n 1 git push --delete origin
#Delete local tasg.
git tag -l | xargs git tag -d