Three Good Things

Three Good Things: Building and deploying a project with Laravel

David Nash laravel, linux, mysql, php 2 Comments

What do developers do in their spare time? Code! Three Good Things is a little app that I started over the holidays, and have been working on in my spare time. During the Christmas/New Year holiday period I read Flourish: A Visionary New Understanding of Happiness and Well-being, by Dr Martin Seligman. In it he describes an exercise called “What-Went-Well” (or “Three Blessings”). The idea is, every night you write three good things that happened in the last 24 hours, and why they happened. I thought it would be a good idea for an app, so I set to work. It was a …

Linux for WordPress Developers – Part 2

David Nash mysql, wordpress Leave a Comment

In Part 1 of Linux for WordPress developers I covered the Apache web server, domain names, .htaccess and .htpasswd files, and extracting the WordPress files. WordPress uses the MySQL database, which can be a little daunting if you’ve never set one up before. I use Ubuntu and I find the easiest way is to use phpMyAdmin, which if you’ve used cpanel as a WordPress developer you’ve probably used this to import the MySQL dump file. You can install it on Ubuntu by following the phpMyAdmin community docs. Creating a database for WordPress Once you’ve installed phpMyAdmin just visit http://localhost/phpmyadmin/index.php and log …

WordPress: Limit Archives to Single Category

David Nash mysql, php, wordpress 9 Comments

Late yesterday afternoon a client asked if I could look at a business’s WordPress installation. They had posts in several categories but only wanted to show the “Latest News” posts in the archives. WordPress is designed around blog posts, whereas I find that many business or company sites are designed around pages (eg About Us, Contact Us) – and don’t use WordPress’ powerful blogging tools on the front page. My site is an example – the content on the home page doesn’t change that much. This means that many of the solutions are also geared around blog-post design. While searching …

Duplicate WordPress site for local development and testing environment

David Nash mysql, wordpress 4 Comments

Update: This is not the best way to do this – use Search and Replace for WordPress databases instead. 1. Download all files from eg, upload to eg http://localhost/example/. 2. Export mysql database from 3. Create a local mysql database with the same user, password and database name. These can be found in wp-config.php 4. Import the database into your new local account 5. Log in to the database, and do: update wp_options set option_value=’http://localhost/example/’ where option_id=1 You’ll now be able to log in at http://localhost/example/wp-admin, using the same username and password as 5. In WordPress, click ‘Settings’ …

Unix Time in MySQL and bash

David Nash bash, mysql Leave a Comment

A quick one today. I was working on a mysql database that used unix timestamp produced by PHP’s time() function. I needed to be able to quickly convert this time to a human-readable format. In bash, date -d @timestamp is a quick way to convert. In a terminal shell eg: # date -d @1224992980 Sun Oct 26 14:49:40 EST 2008 In a MySQL client, you could also use select date(from_unixtime(column_name)) from table_name; Or if you want a little more flexibility in the output, for example outputting 27/02/09, you could do: select date_format(from_unixtime(column_name), ‘%d/%m/%y’) from table_name; This post is one of …

Create a MySQL database

David Nash mysql Leave a Comment

I generally only need to do this once for each project, which means I don’t do it often enough to remember. Log in to the MySQL server as root, then: create database newdb; grant all on newdb.* to ‘newuser’@’localhost’ identified by ‘newuser’; set password for ‘newuser’@’localhost’ = password(‘newpass’); And you’re ready to go! Replace newdb, newuser and newpass with whatever you like.