Skip to content

Instantly share code, notes, and snippets.

View kezabelle's full-sized avatar

Keryn Knight kezabelle

View GitHub Profile
@mitsuhiko
mitsuhiko / .gitconfig
Last active January 30, 2021 20:22
Adds the ultimate of all pull request commands to git
# Alternatively don't use slog but something else. I just like that more.
[aliases]
slog = log --pretty=format:"%C(auto,yellow)%h%C(auto)%d\\ %C(auto,reset)%s\\ \\ [%C(auto,blue)%cn%C(auto,reset),\\ %C(auto,cyan)%ar%C(auto,reset)]"
addprx = "!f() { b=`git symbolic-ref -q --short HEAD` && \
git fetch origin pull/$1/head:pr/$1 && \
git fetch -f origin pull/$1/merge:PR_MERGE_HEAD && \
git rebase --onto $b PR_MERGE_HEAD^ pr/$1 && \
git branch -D PR_MERGE_HEAD && \
git checkout $b && echo && \
git diff --stat $b..pr/$1 && echo && \
@Bouke
Bouke / gist:11261620
Last active March 4, 2025 11:36
Multiple Python installations on OS X

Previous versions used homebrew to install the various versions. As suggested in the comments, it's better to use pyenv instead. If you are looking for the previous version of this document, see the revision history.

$ brew update
$ brew install pyenv
$ pyenv install 3.5.0
$ pyenv install 3.4.3
$ pyenv install 3.3.6
$ pyenv install 3.2.6
$ pyenv install 2.7.10

$ pyenv install 2.6.9

@mtayseer
mtayseer / watch_n_serve.py
Last active August 29, 2015 13:57
Launch a webserver to view generated output & at the same time watch the content for changes & rebuild it.
# [Pelican](http://docs.getpelican.com/) is a static site generator. I'm using it for building [my own website](http://mtayseer.net/).
# To make the editing experience easier, I created this script to launch a webserver to view generated output & at the same time watch
# the content for changes & rebuild it.
#
# I'm using [Bottle](http://bottlepy.org/) for the webserver & [watchdog](https://pythonhosted.org/watchdog/) to watch directory
#
from bottle import route, run, static_file
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
@kezabelle
kezabelle / semistatic.md
Last active January 2, 2016 09:29
Implement a semistatic handler app for Django?
  • Provide middleware;
    • If user is anonymous, look for file in BUILD_DIR
      • If it exists, return it immediately
      • If it doesn't exist, call the view
      • If it doesn't exist and it returns a 2xx, write it to the builder
      • If it doesn't exist and it returns a 3xx, write the 30x.html template to the builder, pointing at the redirect endpoint
      • If it doesn't exist and it returns a 404, write the 404.html to the builder
    • If the user is not anonymous, render the original view, including other middlewares etc.
    • Middleware has an inclusions regex -- see django-moreloaders for regex ideas.
  • Provide builders;
#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
require 'base64'
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay`
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten
http://fluentconf.com/fluent2014
http://2013.jsconf.us/
http://cssconf.com/
http://events.jquery.org/2013/austin/
http://backboneconf.com/
http://www.ng-conf.org/
http://aneventapart.com/
http://2013.cascadiajs.com/
International:
@kezabelle
kezabelle / paginator.py
Created September 24, 2013 11:16
Expose a method on the paginator for treating the original input as chunks, without needing to have nested forloops. This is so that big querysets can be chunked into smaller result sets (ie: less memory usage), at the cost of increased query throughput. I thought this'd be harder.
from django.core.paginator import Paginator
class ChunkingPaginator(Paginator):
def chunked_objects(self):
"""
Usage:
bigqs = ChunkingPaginator(Model.objects.all(), 100)
for obj in bigqs.chunked_objects():
# do something with the obj
pass
@hubgit
hubgit / README.md
Last active March 11, 2025 17:21
Remove metadata from a PDF file, using exiftool and qpdf. Note that embedded objects may still contain metadata.

Anonymising PDFs

PDF metadata

Metadata in PDF files can be stored in at least two places:

  • the Info Dictionary, a limited set of key/value pairs
  • XMP packets, which contain RDF statements expressed as XML

PDF files

anonymous
anonymous / gist:5730195
Created June 7, 2013 15:38
dev log setting
###########
# LOGGING #
###########
# port of django logger w/ enhancement
# @see
# http://docs.python.org/2/library/logging.config.html#logging-config-dictschema
LOGGING = {
'version': 1, # only valid version @ present
'disable_existing_loggers': False,
@mattmcc
mattmcc / models.py
Created March 27, 2013 00:24
Quick & dirty "read-only" model for using SQL views
class ViewManager(models.Manager):
def bulk_create(self, *args, **kwargs):
raise NotImplementedError
def create(self, *args, **kwargs):
raise NotImplementedError
def get_or_create(self, *args, **kwargs):
raise NotImplementedError