Thursday, January 30, 2014

invalid byte sequence for encoding "UTF8" - sqlalchemy

Try putting ?charset=utf8 at the end of your connection string, like:

Tuesday, January 28, 2014

SQLalchemy - Print Tables In Database (Show Tables)

from sqlalchemy import create_engine, Table, MetaData

engine = create_engine('mysql+mysqldb://username:password@')
metadata = MetaData(bind=engine)
print metadata.tables.keys()

You could also use that for looping through a list of the tables in the database.

Print Flask-Restless Routes

# show api routes
for route in app.url_map.iter_rules():
print route.rule

Monday, January 27, 2014

pip install MySQLdb

In case you haven't already noticed, the command in the title won't work.

You need to use: pip install MySQL-python

This article explains the correct approach:

Tuesday, January 21, 2014

Friday, January 17, 2014

Best VNC Installation Guide

That guide gave me the least amount of hassle when I installed VNC on a server. I started by trying to get it working with 13.10, but had issues with a grey screen when tightvnc connected.

Wednesday, January 15, 2014

"Could not connect to database: Database connection "Mysql" is missing, or could not be created." - CakePHP

I got rid of this error just by creating the database manually. Shouldn't Cake do this?

"Not Found The requested URL /app/install was not found on this server." - CakePHP

Rather than dealing with my .htaccess problems to fix the error, I thought this would be a better approach:

Unfortunately, it messed up quite a few links on my site.

I ended up solving the problem by changing "AllowOverride" None to "AllowOverride All" in my /etc/apache2/sites-available/default file.

Why the heck is CakePHP using .htaccess files by default anyway? Yii has this more streamlined.

CakePHP Boilerplate

While I was searching for a some good boilerplate to start my first CakePHP project with, I found this:

There's also this one, but it has much fewer commits:

Tuesday, January 7, 2014

Exception in thread "main" java.lang.NoClassDefFoundError - Java

Got this error when I was missing a library that came with the build.

If you're getting this error, you may need to move the lib folder from your build directory into the folder of your JAR file.

Friday, January 3, 2014

How To Use Endpoint Parameter - Flask-Admin

You can access the endpoint parameter by using self.endpoint.

class displayResults(BaseView):
def index(self):
print self.endpoint

admin.add_view(displayResults(name='test', endpoint='test2'))

That will print "test2".

Thursday, January 2, 2014

UndefinedError: 'admin_base_template' is undefined - Flask Admin

This happens when you try to render a template like this:
return render_template('admin/upload.html')

You need to use self.render instead:
return self.render('admin/upload.html')