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 function_name():
# function body
And then in your program you could decorate it like this
from lib import function_name
function_name = decorat...
Written by Sean Behan on 03/04/2017
Get Method Name as String in Python
Here is how to get the string representation of a method in Python
def my_method_name():
print "Hello World"
my_method_name.__name__
# => 'my_method_name'
Short and sweet!
Written by Sean Behan on 03/04/2017
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'
Written by Sean Behan on 03/04/2017
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 uuid_generate_v1();
For more info on which version of the algorithm you should use refer to the documentation.
...
Written by Sean Behan on 03/03/2017
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/ to https://upload.pypi.org/legacy/
Upload failed (403): Invalid or non-existent authentication information.
error: Upload failed (403): Invalid or non-existent...
Written by Sean Behan on 03/02/2017
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 (HY000): Operation CREATE USER failed for 'someuser...
Written by Sean Behan on 03/02/2017
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` module.
import re
text = ' asdfladf ljklasfj 2324...
Written by Sean Behan on 03/02/2017
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 `command_line_blog` and is available [on Github](https://github.com/seanbehan/command_line_blog) and [on ...
Written by Sean Behan on 03/02/2017
Turn Off SSL Verification In Ruby
The following code will disable SSL verification when using Open SSL.
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
It is probably not a good idea to do this in production. But if you are just testing on your development
machine it might...
Written by Sean Behan on 03/02/2017
How To Get A Dict from Flask Request Form
The `request.form` object is an immutable dictionary. An `ImmutableMultiDict` object to be exact. Immutable means that you cannot change its values. It's frozen.
However, you might want to change the values. Say for instance, creating a slug from a ti...
Written by Sean Behan on 03/02/2017