Tag Archive: php

Tweet This 1.8 Developers’ Screencast 1

By Richard X. Thripp at 2011-03-09T22:05:43Z in Technology, with these tags: mysql, php, plugins, screencasts, tweet this, twitter, video, wordpress, 0 Comments. 44 words.

Tweet This is a WordPress plugin for Twitter developed by me. In this 1-hour screencast, I talk over the first 440 lines of the main file, tweet-this.php.

Watch the screencast (.html, Flash, 33MB) or download the source file (.fbr, BB FlashBack Express 2 Player, 54MB).

Post to Twitter Post to Bebo Post to Delicious Post to Digg Post to Facebook Post to FriendFeed Post to Google Buzz Send Gmail Post to LinkedIn Post to MySpace Post to Ping.fm Post to Reddit Post to Slashdot Post to Squidoo Post to StumbleUpon

PHP echo quotes

By Richard X. Thripp at 2011-02-27T08:33:14Z in Technology, with these tags: php, 0 Comments. 278 words.

Whenever I write PHP code, I always use single quotes to echo text, escaping apostrophes and necessary single quote marks with backslashes. Since “double quotes” are much more common in English than ’single quotes,’ this requires less escaping, and the PHP parser parses single quotes slightly faster because it does not check the string for variables. For example,<?php $test = 100; echo ‘$test’; ?> will return “$test” whereas <?php $test = 100; echo “$test”; ?> will return “100″. Expanding on this, to include variables in single quote echo s, print s, printf s, die s, etc., they must be concatenated like so: <?php echo ‘Today is ‘ . $date . ‘ and the weather is ‘ . $current_weather . ‘!’; ?>. As you can see, I included spaces around the single quotes around the concatenation because those are the English spaces on the left and right sides. This is not necessarily the best way to write statements, but it’s the way I prefer and it’s best to stick with one style of programming (house style) and use it consistently. The same statement could be written as <?php echo “Today is $date and the weather is $current_weather!”; ?>, but that could get confusing later due to the way the human mind works.

Sometimes, it may be necessary to construct conditions based on idiosyncrasies in the English language, i.e. plural forms like <?php if($dog_count == 1) $word = ‘dog’; else $word = ‘dogs’; ?> or suffixes like <?php if(substr($num, -1) == ‘1′) $suffix = ’st’; elseif(substr($num, -1) == ‘2′) $suffix = ‘nd’; elseif(substr($num, -1) == ‘3′) $suffix = ‘rd’; else $suffix = ‘th’; ?>. These are best handled with reusable functions.

Post to Twitter Post to Bebo Post to Delicious Post to Digg Post to Facebook Post to FriendFeed Post to Google Buzz Send Gmail Post to LinkedIn Post to MySpace Post to Ping.fm Post to Reddit Post to Slashdot Post to Squidoo Post to StumbleUpon

ShareThis   Printable Version      
More stuff:   Scheduled Posts    Photo: CFLs    Photo: Ice  

Virtual Thripp.com Subdomains

By Richard X. Thripp at 2010-11-20T00:01:34Z in Technology, with these tags: domains, internet, php, programming, richard x. thripp, thripp.com, wordpress, 2 Comments. 186 words.

I’ve set up some virtual Thripp.com subdomains for pages on richardxthripp.thripp.com that used to subdirectories. All the old URLs 301 to these new URLs. Check out the first batch of subdomains:

about.thripp.com
contact.thripp.com
domains.thripp.com
index.thripp.com
gallery.thripp.com
portfolio.thripp.com
portraits.thripp.com

All of these are for me only and are completely part of richardxthripp.thripp.com. In 2008, I intended Thripp.com to be a social network built on WordPress MU with subdomains for each user, but that never worked out so I feel comfortable owning the *.thripp.com namespace for my own projects now. I will never be changing the URL of this blog from richardxthripp.thripp.com since it’s been that way for so long, though.

This was actually very hard to implement. I’m using WordPress MU 2.7 and the WP Subdomains plugin, but I had to do hacking on both and I can’t get any subdirectories on these virtual subdomains to work so I have to use query strings. For example, gallery.thripp.com is paginated so page 2 is gallery.thripp.com/?page=2/ because I couldn’t get gallery.thripp.com/2/ to work. However, I’m glad I set this up since I will be using Thripp.com subdomains for many pages and ad campaigns in the months to come.

Post to Twitter Post to Bebo Post to Delicious Post to Digg Post to Facebook Post to FriendFeed Post to Google Buzz Send Gmail Post to LinkedIn Post to MySpace Post to Ping.fm Post to Reddit Post to Slashdot Post to Squidoo Post to StumbleUpon

Making WordPress Tag Balancing Work with Exec-PHP

By Richard X. Thripp at 2010-10-28T11:10:17Z in Technology, with these tags: guides, html, internet, php, plugins, programming, thripp.com, tweet this, wordpress, 0 Comments. 2203 words.

I use the WordPress plugin Exec-PHP to use PHP in my posts, but under normal circumstances if I do this with “WordPress should correct invalidly nested XHTML automatically” (a.k.a. tag balancing) checked in Settings > Writing, I get this nasty error whenever I try to use PHP:

Parse error: syntax error, unexpected ‘?’ in /home/thripp/public_html/wp-content/plugins/exec-php/includes/runtime.php(42) : eval()’d code on line 1

The solution the developer provides is to simply disable that feature. That’s fine most of the time, but I encountered a tricky situation where I needed to use PHP and have WordPress close open HTML tags which I simply could not close.

My posts on this blog are usually photos with short descriptions, but occasionally I write long articles which may go on for thousands of words. Up until last year, my tag, category, and archive pages displayed the full content of my posts. WordPress excerpts were unacceptable for two reasons: 1.) they are always 55 words; 2.) I use Post Thumb Revisited to auto-convert 800×600 images to 400×300 thumbnails, but it only converts them through the_content filter, not the_excerpt. While the excerpt length is customizable in WP 2.8 or newer, I am unwilling to upgrade from WPMU 2.7. What I really needed was an excerpt that used the_content, respected all HTML tags, worked with Exec-PHP, and let me customize the excerpt length.

Enter The Excerpt Reloaded. The plugin was 5 years old, so I found an updated version with bugfixes that was only 3 years old. I quickly wrote this code for my theme’s index.php file and left it this way until today:

if(is_category() || is_archive()) the_excerpt_reloaded(200, ‘all’, ‘content’,
     true, “<strong>… continue reading</strong>”, false, 1, false, false,
     ’p’, ‘Click to see whole entry.’, true);
else the_content(__(’… CONTINUE READING’));

This has been the best of both worlds. It cuts off the …

Post to Twitter Post to Bebo Post to Delicious Post to Digg Post to Facebook Post to FriendFeed Post to Google Buzz Send Gmail Post to LinkedIn Post to MySpace Post to Ping.fm Post to Reddit Post to Slashdot Post to Squidoo Post to StumbleUpon

WiredTree Hybrid Servers Upgraded — Game-Changer for Web Hosting Industry

By Richard X. Thripp at 2010-09-15T03:04:47Z in Technology, with these tags: internet, php, programming, wiredtree, wordpress, 0 Comments. 1202 words.

WiredTree Hybrid specs

I’ve been hosting all my websites on a WiredTree Managed Hybrid VPS Server since July 2009, and the plan has not changed a bit until this week. For the past year and a half, WiredTree offered 1GB RAM, 80GB disk space, 2TB bandwidth, and 1 processor core for $99 per month. Starting Monday, this plan has changed to 2GB RAM, 100GB disk space, and 3TB bandwidth, with no increase in price. These stats are real—WiredTree does not oversell and this resources are always reserved for your account. If you aren’t using all your RAM or disk space, nobody else gets to use it—it stays unused and immediately available to you.

Hybrid Servers are actually beefed-up Virtual Private Servers—the name VPS is not used because they provide the resources of a low or medium end dedicated server without the expense. For instance, a WiredTree server might contain two 1TB hard drives, 16GB RAM, and two quad-core processors. Such a server might host 7 Hybrid Server accounts, giving each 2GB RAM, 100GB RAID10 mirrored disk space, and a processor core. The remaining core, RAM, and disk space would be used for software called Virtuozzo, which partitions the server into virtual machines. Such a powerful server may cost under $400 a month to operate—WiredTree would get almost $700 from seven different clients. While offering the server directly to clients is an option, most people do not need and cannot afford such a powerful machine. A Hybrid Server is a much better option.

Prior to this, WiredTree Hybrid Servers were not a spectacular deal—you could find faster servers at cheaper prices elsewhere. Thousands of people choose WiredTree not for their rock-bottom prices, but for their superior uptime, customer support, and reputation. You can …

Post to Twitter Post to Bebo Post to Delicious Post to Digg Post to Facebook Post to FriendFeed Post to Google Buzz Send Gmail Post to LinkedIn Post to MySpace Post to Ping.fm Post to Reddit Post to Slashdot Post to Squidoo Post to StumbleUpon

Tweet This 1.7 Released

By Richard X. Thripp at 2010-08-30T19:08:37Z in Technology, with these tags: php, programming, tweet this, twitter, wordpress, 2 Comments. 163 words.

Today I released Tweet This 1.7, the first update to my WordPress plugin in nearly a year. This version adds OAuth support, and it is an important upgrade because Twitter will be disabling basic authentication tomorrow, Aug. 31, 2010. I’ve also added support for the Bit.ly API and fixed many bugs, including problems with automatic tweeting.

Tweet This 1.7 is also available on the WordPress plugin repository and it has been downloaded 100 times since I released it an hour ago. Twitter requires each user of Tweet This to fill out a lengthy and complex application registration form and then copy and paste four API keys to the Tweet This settings, all of which long and confusing, like “5151540-ADGJeaa-dgaiojt-3ugeaei-ghq75gj-dwerty.” Even Alex King, creator of Twitter Tools, has complained about it. Unfortunately, it’s my only option, so I’ve included detailed instructions on the Tweet This options page.

Please leave me feedback and bug reports, as I will be actively developing Tweet This over the coming months.

Post to Twitter Post to Bebo Post to Delicious Post to Digg Post to Facebook Post to FriendFeed Post to Google Buzz Send Gmail Post to LinkedIn Post to MySpace Post to Ping.fm Post to Reddit Post to Slashdot Post to Squidoo Post to StumbleUpon

How to Create a Public Library

By Richard X. Thripp at 2008-07-26T03:33:47Z in Library Science, with these tags: barcoding, computer science, computers, creativity, internet, librarianship, new, openbiblio, php, programming, 5 Comments. 5613 words.

I’ve disappeared for the last few days because I’ve been working on The Thripp Public Library. While I can’t open it to the public yet (Dad won’t open our house to the world), I’m working on it now because I have time off and Dad’s generously donated lots of his books. Though I wanted to use Evergreen or Koha, I picked the simple and obscure OpenBiblio as my library system, because it’s the only thing I could find that would run on shared hosting. I was disappointed by the lack of features to start, but I’m starting to like the power and control with it, especially since the database makes sense, so adding new features is easy.

Before I even got started, the first step was to choose a barcoding format, classification system, and spine labeling format.

I don’t like Library of Congress (LC) classification because it’s arcane and confusing, so the Dewical Decimal system (DDC) was the default choice. But what to use it for? You can use it for everything, but I decided right away not to use it on fiction items, instead opting for “FICTION / *last name*” as the spine label and call number, which is the same as the Volusia County library system. It may not be ideal, but it’s much easier to use. Biographies are tougher. I chose DDC, but I put two lines above that say “BIO / *subject last name”. The DDC part is always “*numbers* *first three letters of the author’s last name*”. Large type items get “LT” at the top of the spine label. Spine labels == call numbers, always. I created a template file for spine labels in OpenOffice.org Writer, which I add to as I catalog books. Then when I get to twenty or thirty, …

Post to Twitter Post to Bebo Post to Delicious Post to Digg Post to Facebook Post to FriendFeed Post to Google Buzz Send Gmail Post to LinkedIn Post to MySpace Post to Ping.fm Post to Reddit Post to Slashdot Post to Squidoo Post to StumbleUpon