robfelty.com


Postgres tip of the day – show size of all databases

Posted in sql

Quarter note = 03262015 robfelty
Treble clef 4/4 Time
Here is a handy little query to show the size of all the databases on a particular postgres server: SELECT pg_database.datname, pg_size_pretty(pg_database_size(pg_database.datname)) AS size FROM pg_database; datname | size --------------+--------- template1 | 6369 kB template0 | 6361 kB postgres | 6589 kB foo | 55 MB bar | 5129 MB foobar | 85 GB (6 rows)

Random featured images in wordpress

Posted in php, sql, wordpress

Quarter note = 07292011 robfelty
Treble clef 4/4 Time
I’ve had random header images on the Fedibblety Family blog for quite some time. I originally implemented this by looking for images in a particular directory. However, I had to manually add pictures to this directory, which was a bit cumbersome. I started thinking, why not just select randomly from all the featured images I have for my posts? So I hacked up a quick function to do that. Here it is: function get_random_header_images() { global $wpdb; $featured_image_query = "select […] (Read more)

Site redesign

Posted in (x)html, bash, css, php, sql, wordpress

Quarter note = 12012010 robfelty
Treble clef 4/4 Time
I started my website in 2003. At the time it was hosted by the University of Michigan, where I was a graduate student. They gave all students some space for a personal website. It was really great, though it did come with some limitations, like no php or cgi allowed. I managed to kludge some server side includes and javascript together to get a fairly decent food website. I also had some other stuff on my site like some academic […] (Read more)

New WordPress plugin – Image Browser

Posted in photography, php, sql, wordpress

Quarter note = 08042010 robfelty
Treble clef 4/4 Time
Today I released my 8th wordpress plugin. This one is quite a bit different from all the other plugins I have written. A friend of mine was looking for a way to create a gallery on his family blog. “No problem!”, I told him, “there are lots of plugins for that”. But I then quickly realized that no plugins were available for what he was looking for. All of the other image gallery plugins for wordpress function by creating galleries […] (Read more)

Showing total number of replies in bbpress

Posted in php, sql

Quarter note = 04092010 robfelty
Treble clef 4/4 Time
For awhile now I have been wanting to show the total number of topics started and replies in a bbpress forum on the profile page. Today I finally figured out how. I like bbpress quite a bit, as it integrates very nicely into wordpress. The main downside of bbpress right now is that the documentation is still basically nonexistent. Maybe someday I will help out with it. Anyways, to get the total number of replies, simply use the following little […] (Read more)