Stumbled upon this article today: AngularJS – Sort, Filter and Paging – A Table Directive — and I’m reading it as we speak…
Creating a user and database in PostgreSQL
To create a database and user account for use on PostgreSQL:
root@devotion:~# su - postgres
postgres@devotion:~$ psql
psql (8.4.21)
Type "help" for help.
postgres=# create user "www-data" superuser;
CREATE ROLE
postgres=# create database mydb with owner "www-data";
CREATE DATABASE
postgres=# \c mydb
psql (8.4.21)
You are now connected to database "mydb".
^
mydb=# alter user "www-data" with password 'secret';
ALTER ROLE
AngularJS: Error: Duplicates in a repeater are not allowed
Using AngularJS I was getting the error “Error: Duplicates in a repeater are not allowed.” I found a comment on StackOverflow that suggested instead of:
<div ng-repeat="row in [1,1,1]">
To use:
<div ng-repeat="row in [1,1,1] track by $index">
A magical ‘track by $index’!
Installing PostgreSQL on Debian
Postgres is only an apt-get away!
# apt-get install postgresql postgresql-client
To integrate with PHP PDO:
# apt-get install php5-pgsql
PHP urlencode
Used PHP’s urlencode today…
psql fatal role does not exist
I was setting up a postgres server and I got the message “psql fatal role ‘user’ does not exist”. Found a solution over here, basically:
CREATE USER jj5 SUPERUSER; CREATE DATABASE dbname WITH OWNER jj5;
Sorting Arrays in PHP
Everything you ever wanted to know about sorting arrays in PHP.
PHP instance of Closure vs is_callable or function_exists
The problem is that is_callable and function_exists check a string to see if it’s a function. But I wanted to check to see if it was an anonymous function and not a string. Turns out you can do this by checking for an instance of Closure:
if ( $fn instanceof Closure ) { $fn( ... ); }
Design by Contract
Just read the Design by Contract article on Wikipedia… a good read!
MySQL INET_ATON and INET_NTOA
You can convert an IP address to an int, and vice versa, with these two MySQL functions. Of course I learned about this after I’d already implemented IP address support using BINARY(4) and my own parser/formatter… now that I have my own implementation I can’t bring myself to let it go, and I worry about support for signed/unsigned 32-bit ints (perhaps my concerns are unfounded..?)