Skip to content

Instantly share code, notes, and snippets.

dankrause /
Last active Jul 27, 2022
Example code to use the (unofficial, unsupported, undocumented) DNS API.
import requests
class HoverException(Exception):
class HoverAPI(object):
def __init__(self, username, password):
params = {"username": username, "password": password}
r ="", params=params)
freakboy3742 /
Last active Feb 25, 2022
An Android app written in Python
from android.util import TypedValue
from android.view import ViewGroup
from android.view import Gravity
from android.widget import LinearLayout
from android.widget import TextView
from android.widget import EditText
from android.widget import Button
from android.widget import ScrollView
from android.util import Log
mastbaum /
Created May 10, 2012
Example of a custom ReST directive in Python docutils
'''Example of a custom ReST directive in Python docutils'''
import docutils.core
from docutils.nodes import TextElement, Inline
from docutils.parsers.rst import Directive, directives
from docutils.writers.html4css1 import Writer, HTMLTranslator
class foo(Inline, TextElement):
'''This node class is a no-op -- just a fun way to define some parameters.
There are lots of base classes to choose from in `docutils.nodes`.
maxim75 /
Created May 22, 2011
Setting GPS location EXIF tags using Python script and pyexiv2 library
#!/usr/bin/env python
import pyexiv2
import fractions
from PIL import Image
from PIL.ExifTags import TAGS
import sys
def to_deg(value, loc):
if value < 0:
ehazlett / gist:38ba224ae8bba348da2e
Last active Mar 28, 2019
Using NFS with boot2docker
View gist:38ba224ae8bba348da2e

NFS Server

OS X Host

Note: you will need sudo access. Add the following to /etc/exports

/Users -alldirs -maproot=root:wheel -network -mask

Restart NFS:

codeinthehole /
Last active Mar 20, 2019
Comparison of three ways of assigning excluded fields to a model when creating via a form
# Question - how best to handle model fields that are excluded from a form's
# fields.
# ------------------------------------------------------------
# Option 1: assign fields to instance before passing into form
# ------------------------------------------------------------
instance = Vote(review=review, user=request.user)
form = VoteForm(data=request.POST, instance=instance)
readevalprint /
Created Sep 25, 2013
django-haystack SearchResultSerializer from django-rest-framework
==== SNIP ====
class DistanceSerializer(serializers.Serializer):
km = serializers.FloatField()
m = serializers.FloatField()
mi = serializers.FloatField()
ft = serializers.FloatField()
class SearchResultSerializer(serializers.Serializer):
View mysql_to_postgres.txt
Maybe the closest analogue to this is the PHP "debate":
Basically, MySQL works and you can definitely use it to build and run successful applications. Facebook uses it. But the point is that Postgres..... is better. That's the point. How and why? There are numerous articles out there for you to google up but [here's one] ( that gives you a resaonable breakdown, by example.
So if you're currently a still running MySQL why not give Postgres a go, especially if you're starting a new project. Hell, why not use it even on existing projects which are using MySQL? Maybe because you have existing MySQL databases full of data and tables that you'd need to convert over to PostgreSQL? True this is a barrier, but it's by no means insurmountable. Which is what this post is about: easy conversion of your existing MySQL databases (schema and dat