Skip to content

Instantly share code, notes, and snippets.

@dankrause
dankrause / _hover_example.py
Last active March 8, 2024 18:31
Example code to use the (unofficial, unsupported, undocumented) hover.com DNS API.
import requests
class HoverException(Exception):
pass
class HoverAPI(object):
def __init__(self, username, password):
params = {"username": username, "password": password}
r = requests.post("https://www.hover.com/api/login", params=params)
@freakboy3742
freakboy3742 / voctestapp.py
Last active December 8, 2022 11:21
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
mastbaum / custom_directive.py
Created May 10, 2012 20:32
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
maxim75 / set_loc.py
Created May 22, 2011 01:07
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
ehazlett / gist:38ba224ae8bba348da2e
Last active March 28, 2019 18:32
Using NFS with boot2docker

NFS Server

OS X Host

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

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

Restart NFS:

@codeinthehole
codeinthehole / comparison.py
Last active March 20, 2019 06:13
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
# ------------------------------------------------------------
# views.py
instance = Vote(review=review, user=request.user)
form = VoteForm(data=request.POST, instance=instance)
@readevalprint
readevalprint / serializer.py
Created September 25, 2013 20:39
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):
Maybe the closest analogue to this is the PHP "debate":
(http://www.codinghorror.com/blog/2012/06/the-php-singularity.html)
(http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/)
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] (http://www.youtube.com/watch?v=1PoFIohBSM4) 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