Archive | LAMP

Linux Apache MySQL Python Perl PostgreSQL

rbenv on Fedora 19: for want of a nail,…

… a kingdom was lost.

Fortunately, I don’t have a kingdom at stake. My tale is more like the House That Jack Built. I had to spend a little time building the tools to build the code to build the language upon which I build solutions for clients. And the path was strewn with gotchas, but I persevered. Since I’ll likely need to do it again some day, I’ll record it here in hopes I can retrace my patch, er, path.

I’ve installed Fedora 19 on my main development laptop, replacing an older Mint 12 install that had gotten too old to maintain easily. I’ve spent some time updating and configuring the machine in my spare time. With FireFox already installed, Chromium was an early addition. Thanks to syncing, these browsers retain the history and passwords of the sites I spent all day on. I moved over my ssh keys and configurations and vim configurations and installed git and the basic development setup is ready to go: most of my coding occurs on remote systems. Next came Apache and PHP in order to develop locally. Finally, I started on Ruby and Rails. Here, I took a tangent from past installs and installed rbenv rather than RVM, the Ruby Versions Manager. I have seen problems with RVM and the 2.0 version is coming along slowly. In the meantime, Bundler has come along and solved a number of problems with gems, gemsets and disk clutter, but in a different and incompatible way with RVM. I thought that this was a good opportunity to inform myself of a new tool, should I run across it on a new gig. Also, I had seen a Drew Neil videocast in his VimCasts series recently where he showed some very useful tools, but rbenv was a pre-requisite. Due to the way RVM works, rbenv can’t be installed side-by-side, so I had to remove RVM. No time like the present!

However, there’s a catch. Isn’t there always? Fedora 19 uses a version of OpenSSL which is configured differently than what used to be typical. I am no crypto expert, but I understand they disallowed some form of elliptical curve (EC) encryption. Ruby, as part of its build process, tests for that specific functionality, so builds will break on Fedora 19 (and recent Red Hat, too). There is a fix in the pipeline: https://bugs.ruby-lang.org/projects/ruby-trunk/repository/revisions/41808, which changes the behavior from requiring this specific form of encryption, which wasn’t really required, just a poorly chosen hard-coded test) and instead tests to confirm that there are some algorithms for encryption by iterating through them. So. Now, I knew there was a fix, I just had to figure out how to wedge it into my system. Thank goodness for internet search engines! Here http://philippe.bourgau.net/how-to-install-a-patched-ruby-interpreter-wit/ was a similar enough situation that I could interpret the process for my system, with different version numbers, of course, and a few tweaks. After a few false starts, I had my own custom patched versions of Ruby 2.0 and 1.9 installed a ready to go.

It may not be clear why I didn’t just install the version of Ruby that comes with Fedora 19. At the moment, that version is the same (p247) as the current version, but as a developer, I don’t want to have to count on the distribution to keep their versions up to date in order to have the most recent version on my systems. Since I’ll be deploying systems into production, and therefore exposed to potential attack from the internet, I need to have the ability to build from the latest source code and to apply patches as needed. This provides the best possible security to my clients for this app. I also need to support older versions, so having worked out the recipe for 2.0, I was able to backport the same changes into Ruby 1.9.3 and install that on the system as well. At the moment, I don’t have any need for Ruby 1.8.7, but now that I’ve worked out the build routine, I’m confident I could deploy that if needed.

0

Linux printing on a Lexmark E312L via IOGear GPSU01 print server

Just updated the Lenovo ThinkPad T61 to Fedora 19, and it went pretty smoothly. I alternate between two distros on separate partitions, so one can act as the recovery partition for the other, and as a general fall-back. I can pretty much bulk-copy most of my home partition from one to the other and the fresh install will update what’s changed, while I can still retain much of the customization I’ve done.
In this case, I was updating from Linux Mint 12, which had gotten too old to keep up to date. I was replacing an even older Fedora 16 install. The initial versions of Fedora with GNOME3 had just proven too unstable to rely on as my primary development workstation. This new Fedora 19 install put most of the daily tools on the machine, and I’ve been installing utilities —— vim, vim-X11, GIMP, ack —— as I found the need for them.
One of the things that’s better to just redo from scratch is the printing configurations, as the Ubuntu-based Mint and RedHat-related Fedora part ways in this and several other aspects of running an OS. Both are running CUPS, but that’s about as far as it goes.
My laser is an old Lexmark E312L which has its own interesting story: the ‘L’ model was supposed to be Lightweight or Lame or something, sold cheaply in office supply stores, a weaker sibling of the 312 model, with a half-filled toner cartridge and limited to HP-PCL with no PostScript, but it seems that Lenovo had some issues and just slip-streamed the full 312 engine, PostScript and all, into the L models. The only clue are the internal diagnostics you can run by holding down the reset button on startup. Finding the PPD to run that was a bit tricky, but here’s the one that worked for me: PPD page at OpenPrinting.Org. Lesson learned: don’t judge a printer by its cover.

IOGear GPSU01 print server

IOGear GPSU01 print server, decade-old and humming along.

The print server is another thing. The Lexmark only came with parallel and USB ports, so to host it on a network, I bought a IOGear GPSU01 print server over a decade ago. That wild $60 extravagance doesn’t seem so crazy now, after a decade of nearly flawless printing. It serves up nearly every protocol under the sun from Apple File Sharing to Novell (remember them?) to its own HTTP and CUPS servers. The trick with this one was to remember which of the myriad protocols and settings to choose. I found a blog post that set me on the right track, and learned that the optimal settings for my use was to address the printer using the Internet Printing Protocol and the CUPS port as ipp://laser.in.tedroche.com:631/lp1 With those clues in hand, a couple of tweaks to my localhost:631 (my local CUPS server admin interface) and I was printing flawlessly.

0

Notes from Manchester WordPress Meetup, 16-Oct-2013

The Manchester WordPress Meetup met at The Farm restaurant (Elm Street, Manchester) on Wednesday October 16th. Their regular meeting night is the 2nd Monday of the month, which they’ll resume November 11th.) A smaller crowd that usual made it to the event, but it just gave us each more time to talk, get our questions answered, and quiz the speaker.

Craig Fifield (www.craigfifield.com) was the featured speaker, talking about Google Authorship. (A second speaker had an accident and was unable to make it. Best wishes for a speedy recovery!). Google Authorship is a means of tagging your written content on the web and linking it to your Google Plus profile. Craig has a lot of experience in the SEO space, as he’s worked with the web since 1995, “before SEO or Google existed.” Craig was very fired-up about the Google Authorship concept, and showed us how to to link our WordPress posts to our Google Profile. Like many Google processes, it’s a two-way operation: establish a Google Plus profile and point it to the publications you’ve written, and edit the publications and include a link that points back to your profile. While there are several WordPress plugins that claim to support this feature, Google Authorship is still a moving target, and none seem to follow the current guidance.

Craig also emphasized that it’s important to test your setup once you get it in place; it’s not enough to embed the links and assume everything works. He recommended using the Google Structured Data Testing Tool on several of the pages to ensure your author information was showing up correctly on individual articles, but not on streams of articles (front pages, archives, etc.) or places where a byline would be inappropriate (About Me or Contact pages, for example).

We had some time for announcements and Q&A as well. Meetup organizer Jonathan May will be teaching Advanced Topics in WordPress at the Nashua Adult Learning Center. Jeff (missed his last name) spoke about the Fossil Fuel Age Challenge Ecosite Competition: a nonprofit effort to promote sites with a green focus by holding a competition and promoting the ecological movement as well as a bit of self-promotion for the developers. Things are still coming together, but it looks like one WordPress site would be selected at random and the winner would get a dinner with Matt Mullenweg, while a winning Drupal site would get a dinner with Dries. It sounds like good fun, and a good chance to get soem promotion of your authoring skills. More details can be found at EcoEnlighten.com and EcoSiteCompetition.org.

Also mentioned: several upcoming meetings: GNHLUG meets at The Farm on October 22, lots of good meetups like the Web-Developers group and the Seacoast WordPress group at AlphaLoft in Portsmouth. And tickets are getting scarce for WordCamp Boston, held October 25-26-27 — get yours soon!

Thanks to Craig for presenting, Jonathan for organizing the meetup, and all for attending and participating!

0

Seacoast WordPress notes, October 2, 2013

The October meeting of the Seacoast WordPress Meetup was held on October 2, 2013, at the AlphaLoft coworking space. Thanks to owner Josh for encouraging groups to use the space!

Of course, you never get techies together when they don’t just jump into talking about what they’re up to! We had a question on using Content Delivery Networks (CDNs) to improve responsiveness for an international site. David talked about his experience with CloudFlare. A quick Google showed that there were a number of plugins that claim to offer some CDN functionality, and that initial offers the member had gotten might have been inflated.

David also showed the Dynamik theme add-on to the Genesis theme that generates a set of media queries to support mobile devices.

We started off the more formal meeting with a round of introductions: Amanda, Chris, me, Jim, Laurel, Dylan, David, Andy, Tina, and Tom.

Off we go into questions and comments. One member did some troubleshooting of a plugin-laden site using P3, the plugin performance profiler. Others offered their opinions that excessive plugin use can be the source of a lot of compatibility and/or performance problems.

The main presentation of the evening was from Amanda Giles and the Canvas theme from Woo Themes. Wow! This theme can do a lot, lay out in a number of different ways, and has great administrative functions off the dashboard to make lots and lots of changes from within the interface, and not having to fork off a child theme and mess with the code directly. The Premium theme is $119 for developer version or $99 basic. Both include a year of support and upgrades. The Developer version includes PSD files for designers to customize the theme in PhotoShop. A yearly upgrade is obviously what Woo would like everyone to do (who wouldn’t?) but Amanda indicated it’s okay to stick with the version you buy in perpetuity or until they come out with a compelling feature you want.

The number of features were remarkable. Here are a few I remembered to record: easy file structure, lots of hooks, extensive admin functions, support for short codes. Amanda set up a website for attendees to follow along with the various pages of the dashboard and do a little experimenting. Obviously, the access can’t be made public to the entire internet. See www.canvas.client-look.com. We worked our way through many the Canvas options, for an hour! If you don’t have Photoshop, check out pixLR.com for an online utility that will do many of the basic functions.

Woo Themes also includes “templates” within the theme that allows more complex layouts: Magazine has a full-width slider, followed by full-width article, followed by a grid of articles. Also, a second template, Business, with a different layout.

In the header of the Woo Themes dashboard, “View Theme Documentation” takes you to the WooThemes web pages of documentation, which are extensive!

Amanda reminded us that WordCamp Boston will be happening at the NERD Center October 25-27. Well worth the effort to attend. Seacoast WordPress folks will try to get together for a birds-of-a-feather session or lunch; watch the Meetup group for details.

0

Three Lightning talks at Alphaloft: September 2012 Seacoast Web Dev Meetup

An excellent time as always at the Seacoast Web Developers Meetup held at AlphaLoft in Portsmouth on September 25th.

Josh Cyr presented his initial research on Google Drive. Josh worked with a client to develop a workflow process using events occurring in Google Drive to process documents. The API from Google allows you to iterate through files and folders, change properties. up- and down-load.

Paul Finn presented Vagrant, a shell around virtual machines that allows simple and easy download of pre-made images, spinning up the VM and talking to it (ssh) via Ruby scripts. Paul’s slides are here: http://slid.es/paulfinn/vagrant/fullscreen

Ted Pennings (@thesleepyvegan) talked about cryptography: the basic concepts, aspects of concern, best practices and more! A very informative 20 minutes from a man who’s obviously deeply involved and enthused about the subject. Slides are here: http://prezi.com/kplh0mz6ptjt/cryptography-in-20-fast-minutes/

0

Calculate your BMI using Wolfram Alpha

Harness the power of the Wolfram Alpha computational engine to see how your height/weight ranks against the currently-accepted BMI calculations and populations:

[wolframalphawidget id=”bd2271d0eb320a2e2f27536bce47b91d” ]

Wolfram Alpha provides a WordPress plugin that allows the WordPress author to use a shortcode to place a widget in a post. There’s also (separate) support for putting a Wolfram Alpha widget inside a WordPress sidebar or widget. There’s a gallery with lots of pre-created widgets and an interface to create your own. Pretty cool.

Note that you need to specify the units (“lb” for pounds, “in” for inches, or 5′ 7.5″ for typical foot-inches height expressions) otherwise the widget seems to make some really poor choices, deciding that weight of 67 means aged 67 years.

0

The Web is about People, if we let it be

I was recently contacted by a company interested in having me consult on their development efforts. As I usually do, I did some background research to figure out who they are and what they do. I was appalled: their web site is one of tens of thousands of generic business sites, pretty but empty. All the buzzterms were there, the generic stock photos of the properly demographically-disparate team meetings, leaning over shiny laptops not wired to anything and pointing to pie charts with no labels. The ‘About Us’ page is filled with slogans and buzz words on how awesome “the team” was, without the single mention of who the team is.  The “Contact Us” page is a generic web-based form, with direct links to “sales@example.com” or “info@example.com.” Want a job? Jobs@example.com or hr@example.com.

What is it “About Us” you don’t understand? If you have a link saying “Who We Are,” you had better be ready to name names. Who are these people and what are they hiding? There’s no excuse for a web site like this. Are these people in the witness protection program? Do these people stand behind what they build? There’s no reputation to worry about losing because they never tell you who they are.

You can have the stiff corporate “Who We Are” of black and white pictures of the “Leadership Team” in suits, “Our Advisors” to name-drop your VCs or Directors, or a more playful site of caricatures and off-beat bios. Kudos go to the sites that include your Twitter and Github accounts, and let folks share their passion for mountain biking, marathons or matchbook collecting. But denying there are people behind your web storefront tells me you’re not proud of who you are, you’re uncomfortable putting yourself out there, or you’ve got something to hide.

And that’s the real problem with a “Who We Are” site like this: the publishers are telling us much more about themselves than they intend. In a customer-facing industry where personal service and attention is a key determinant in the success of the project, they’re stating they are not comfortable with that level of contact.

Food for thought.

0

Fixing shorttags in PHP source code

Short tags is a topic of some controversy in coding circles: wrapping your script in less-than, question-mark x 2, greater-than signs is easy to type and flows off the fingers but can be a source of confusion to some parsers. In PHP, it is not recommended, but there is a “shorttag” option available to override it globally or locally.

I recently was asked to edit some older PHP code and found it was littered with short tags, both the <? script goes here ?> variety and the shortcut output <?=”Print this string”?> variety, which need to be replaced by <?php script goes here ?> and <?php echo “Print this string” ?> respectively. A bit beyond my search-and-replace regex or sed skills, I found a fairly elegant solution on StackOverflow, which uses PHP to rewrite PHP:

#! /usr/bin/php
 <?php
 global $argv;
$contents = file_get_contents($argv[1]) or die;
 $tokens = token_get_all($contents);
 $tokens[] = array(0x7E0F7E0F,"",-1);
foreach($tokens as $ix => $token) {
 if(is_array($token)) {
 list($toktype, $src) = $token;
 if ($toktype == T_OPEN_TAG) {
 if (($src == "<?") && ($tokens[$ix+1][0] != T_STRING)) {
 $src = "<?php";
 if ($tokens[$ix+1][0] != T_WHITESPACE) {
 $src .= " ";
 }
 }
 }
 else if($toktype == T_OPEN_TAG_WITH_ECHO) {
 $src = "<?php echo";
 if($tokens[$ix+1][0] != T_WHITESPACE) {
 $src .= " ";
 }
 }
 print $src;
 }
 else {
 print $token;
 }
 }

It just needed a little shell wrapper to take in all the files (which I’d renamed *.php.old and archived and made a backup of) and put them out as *.php.old.new. Again, a quick rename and I was in business. I was astounded to find it ran the first time!

#! /bin/bash
FILES=./*.php.old
 for f in $FILES
 do
 echo "phpize $f >$f.new"
 ./phpize.php $f>$f.new
 done
0

Keeping up: theme changes

Astute readers (and I know who you two are!) will notice a change to a newer theme. I’ve switched over to the WordPress Twenty-Eleven base theme, with a few of my own tucks, nips and tweaks. I wanted to check out the new theme and test out the new functionality and keep up with the latest stuff.

Child themes are a piece of cake to create, and a child theme lets me override the original without messing with the original source, so updates will not erase the changes. While they are not so difficult to do manually if you are familiar with the command-line, they are even easier with the plugin One-Click Child Theme.

With the child theme in place, I was able to shorten the gap between the site description (the motto) and the header picture, just by adding CSS to the style.css in the child theme (that’s the cascading part of CSS). I added a paper-curl edge effect based on the work of Craig Buckler, published on Sitepoint.

I was disappointed that my site was not valid HTML5, according to the W3C’s validator site. Category tags used in REL links aren’t standard, so I deleted those. The Creative Commons plugins want to use Dublin Core XML namespaces, and there are issues there I’ve got to clean up. And the “generator” REL tag on the bottom of the page isn’t too standard, either. Overall, though, the pages are relatively clean of excessive markup or poorly-formed structures. Stay tuned as I tweak the last few elements into line.

0

Powered by WordPress. Designed by Woo Themes

This work by Ted Roche is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States.