When converting a table column from
integer I ran into a problem.
SQLSTATE: Datatype mismatch: 7 ERROR: default for column "column_name" cannot be cast to type integer
The solution I could find on (Stackoverflow)[http://stackoverflow.com/questions/13170570/change-type-of-varchar-field-to-integer-cannot-be-cast-automatically-to-type-i] was not working:
ALTER TABLE the_table ALTER COLUMN col_name TYPE integer USING (col_name::integer);
Looking closer at the error I realised – as is often the case – the error was indicating exactly what the problem was. The default of the column could not be converted.
Not knowing how to convert the default, I simply changed it to something that could be converted:
ALTER TABLE the_table ALTER COLUMN col_name SET DEFAULT 0;
Despite it being a
varchar column, the integer value 0 was accepted. After which the earlier CAST worked.
The Debian backports repository contain packages or newer versions of packages that did not make it into the original release. You can read more about backports on the Debian website.
To install wheezy-backports you need to either add the repository line:
deb http://http.debian.net/debian wheezy-backports main
Alternatively you can create a new sources list file with this command (run as root):
# echo 'deb http://http.debian.net/debian wheezy-backports main' > /etc/apt/sources.list.d/wheezy-backports.list
Once installed, run apt-get update:
# apt-get update
Select individual packages to install:
# apt-get -t wheezy-backports install "package"
Photo credit: Giulio Turetta
If you are interested in learning what Elasticsearch has to offer you, come catch my talk at the Annual PHP Cape Town Conference.
Three days packed with interesting talks starting on the 2nd of October 2014.
Using the Elasticsearch PHP API to do an ascending sort is simple:
$params['sort'] = array('updated_at');
However I found performing a descending sort much less intuitive. Eventually I figured out it should be:
$params['sort'] = array('updated_at:desc');
Hopelessly untested – a thought inspired by Stacey.
The idea is to use BitTorrent Sync (BtSync) to sync a local development directory to a live web server directory.
Two approaches spring to mind.
DISCLAIMER: Modifying or replacing your device’s software may void your device’s warranty, lead to data loss, hair loss, financial loss, privacy loss, security breaches, or other damage, and therefore must be done entirely at your own risk. I am not responsible for your actions. Good luck.
The new CyanogenMod installer requires Windows. Most of the manual tutorials assume you’re running Windows. Hopefully my summarised experience below will help other Linux users.
Node.js is not a first class citizen in Debian yet. Installing it is easy but not entirely straight forward.
It is desirable to avoid using database functions. They are black boxes which gift only night horrors to unwary developers. A system is difficult to understand, maintain and debug when chunks of it lurk unseen in the DB.
Despite this – for certain features – using them does make sense. Provided the database function’s code is source controlled and huge lumps of comments referring to both the location and function of said code is spread evenly throughout the associated application code.
For example, in order to bill Ekaya agents accurately we needed a log of show house status changes, from upcoming to active to past or cancelled. Most of these changes were implemented in sweeping SQL statements that, while efficient at their own task, made it difficult to track individual changes.
Formatting of data should only occur in the final steps of output. Until that point, and as a rule, internally data should remain in a base format that can easily be converted into many others – without being converted into another more basic format first.
For example Unix timestamp for dates or a floating point number for money. Both can readily be converted into more expressive formats without writing code to first parse or disassemble the initial format.
However in a situation where the flow is very specific and unlikely to ever be used to generate a different output it is permissible, even desirable, to generate data in the format it will be finally outputted.
For the last few years I have listened to the podcasts from SXSW while travelling to work or more recently while at gym.
Each year the number of podcasts has increased to the point where this year I am now too lazy to click through to every page and DownThemAll!. Besides it’s more fun to write a bash script to do the heavy lifting.