Fixing missing libssl library when using Django/Anaconda

09 Apr 2017

Here’s the fix for this nasty error message on OSX:

raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: dlopen(/Users/anaconda/lib/python2.7/site-packages/psycopg2/_psycopg.so, 2): Library not loaded: libssl.1.0.0.dylib
# Run this in your terminal
# Credit: http://stackoverflow.com/questions/27264574/import-psycopg2-library-not-loaded-libssl-1-0-0-dylib
export DYLD_FALLBACK_LIBRARY_PATH=$HOME/anaconda/lib/:$DYLD_FALLBACK_LIBRARY_PATH

Publishing with React VR

17 Mar 2017

Here are some steps you might have overlooked when publishing your React VR project for the first time.

Here’s my first finished project: http://daviseford.com/tcpi-react-vr/

Here’s my VR resume

1.) You have to upload the static_assets folder yourself - it’s not included in the build folder.

2.) You need to modify your vr/build/index.html file to resemble this

<!-- When you are ready to deploy your app, update this line to point to your compiled client.bundle.js -->
    <script src="./build/client.bundle.js"></script>
    <script>
      // Initialize the React VR application
      ReactVR.init(
        // When you are ready to deploy your app, update this line to point to
        // your compiled index.bundle.js
        "./build/index.bundle.js",
        // Attach it to the body tag
        document.body
      );
    </script>

3.) Seriously, pay careful attention to the index.html file

4.) If you’ve included any images using the source=require(‘img.png’) style of import, you need to update those images with their URI’s, like so

source={ { uri: 'http://domain.com/your-image.png' } }

5.) Read the docs carefully - it’s all there, but scattered all over the place.


Release - Bootstrap CRUD Generator

20 Mar 2016

Go to the CRUD Generator

I’m pleased to announce that I’ve developed a Bootstrap CRUD application generator. Tired of manually building forms for basic SQL events? Use my tool to generate CRUD pages for your tables.

A painless way to create PHP/MySQL/Bootstrap CRUD apps

Generate a basic Bootstrap-themed CRUD (Create, Read, Update, Delete) application based on your MySQL SELECT, UPDATE, or CREATE query.

This application takes advantage of GreenLion’s PHP SQL Parser.

Download the source from Github.


PHP - Naturally Sort Nested Arrays by Key

07 Mar 2016

Let’s say we have an array of objects like so that are coded incrementally like so: OBJ1, OBJ2, OBJ3..

One problem with MySQL is that there’s no easy way to naturally sort a returned array, so if you have 15 objects, you’ll end up with an array like:

array(26) {
  [0]=>
  array(2) {
    ["key"]=>
    string(3) "OBJ1"
    ["value"]=>
    string(21) "Something something"
  }
  [1]=>
  array(2) {
     ["key"]=>
    string(3) "OBJ10"
    ["value"]=>
    string(21) "Something something"
  }
  [2]=>
  array(2) {
    ["key"]=>
    string(3) "OBJ11"
    ["value"]=>
    string(21) "Something something"
  }
  [3]=>
  array(2) {
     ["key"]=>
    string(3) "OBJ2"
    ["value"]=>
    string(21) "Something something"
  }
}

The problem is that MySQL is sorting the keys in the manner of a computer, not a human. Not desirable.

Luckily, we’ve got the benefit of naturally sorting things as a human would.

Use the following function to sort the array by a nested key (such as “key” in the example above)

usort($array, function ($a, $b) {
            return strnatcasecmp($a["key"], $b["key"]);
        });

Enjoy :)