Writing
Notes on building software — the decisions that age well, the ones that don't, and what I learn in between.
-
How to Fix xcrun: error: unable to find utility "instruments", not a developer tool or in PATH
I just got a new machine and downloaded XCode. I used git to clone my ReactNative project from Github. I have everything ready to go. But when I run react-native run-ios I see xcrun: error: unable...
-
How to Decorate Imported Libs in Python for Jinja Template Filters in Flask
To decorate an imported function in Python you would do something like this in ./lib.py def functionname(): function body And then in your program you could decorate it like this from lib import...
-
Get Method Name as String in Python
Here is how to get the string representation of a method in Python def mymethodname(): print "Hello World" mymethodname.name = 'mymethodname' Short and sweet!
-
Destructuring Dictionaries in Python
Here is a quick and dirty way to destructure dictionaries in [Python] d = {'a':'Apple', 'b':'Banana','c':'Carrot'} a,b,c = [d[k] for k in ('a', 'b','c')] a == 'Apple' b == 'Banana' c == 'Carrot'
-
How to Enable UUIDs in Postgres
The first thing you'll need to do is enable the extension create extension "uuid-ossp"; To test that it's working select uuidgeneratev1(); For more info on which version of the algorithm you should...
-
How to Fix Pypi Upload failed (403): Invalid or non-existent authentication information.
If you run into authentication failure when trying to upload packages Submitting dist/<package name to https://upload.pypi.org/legacy/ Upload failed (403): Invalid or non-existent authentication...
-
How to Resolve ERROR 1396 (HY000): Operation CREATE USER failed for Error in MySQL
If you run into this error when trying to create a user in mysql, chances are you already have this user account created. create user 'someuser'@'localhost' identified by 'somepassword'; ERROR 1396...
-
How to Create a Slug in Python with the Re Module
There are a few 3rd party modules that do this sort of thing. But there is a pretty solution using out of the box Python functionality. You don't have to install any dependencies if you use the re...
-
My First Python Package on PyPi - Command Line Blog
I wrote my first Python package over the weekend. It is a simple package that adds a basic blog API to an existing Flask application. It's called commandlineblog and is available on Github and on...
-
Turn Off SSL Verification In Ruby
The following code will disable SSL verification when using Open SSL. OpenSSL::SSL::VERIFYPEER = OpenSSL::SSL::VERIFYNONE It is probably not a good idea to do this in production. But if you are...
-
How To Get A Dict from Flask Request Form
You just call `to_dict` on the `request.form` object and you get a dictionary you can work with.
-
Generate a Gravatar URL with Ruby
To get a Gravatar you need to hash an email address with the MD5 algorithm. MD5 is a part of the Ruby standard library. Rails loads it by default, but otherwise you will have to require it...
-
Extract Domain Names From Links in Text with Postgres and a Single SQL Query
This query and pattern will return urls in text all within a single SQL query. select substring(columnname from '.://([^/])') as domainname from tablename; And here it is in a larger query, say for...
-
Python String Format Precision of Float
You can use string interpolation in combination with a dictionary for simple formatting. print "My name is %(name)s and I have $%(change)0.2f in change in my pocket!" % { 'name': 'Sean', 'change':...
-
How To Install Pyscopg2 Python Postgres Driver on Mac OSX with Homebrew, Postgres.app and VirtualEnv
You might have to append the path of the Postgres.app bin directory to your path in order to install the Python driver for Posgres. export PATH=$PATH:/Applications/Postgres.app/Contents/MacOS/bin...