Kyle D. Skrinak

Rotator.php fix?

by Kyle Skrinak on Aug.06, 2009, under Technology

Let’s say you have a rectangular section of your web page, within which you wish to have a single random image from a directory displayed there. In Drupal there are several, if complicated, ways to achieve this. Each requires the enabling of several modules, which increases rendering times and overall site maintenance. Unsatisified with current options, I explored alternatives and came across the ever-reliable site A List Apart with an article on a php-based image rotation script.

Enabling the script within Drupal was another matter. I modified the tpl.php file where I wish to render the random image (helped with the devel module) with:

<div><?php require ‘rotator.php’; showImage(); ?></div>

The original code called for “include” and not “require” but I made the change while debugging and decided to keep the change. I placed ‘rotator.php’ in the active theme’s folder; which dereferences properly. Rotator.php calls ‘image.ini’ which tells rotator.php which images, what alt and title tags, and other goodness. However, rotator.php couldn’t parse mage.ini; and I couldn’t find out exactly why.

Turns out this portion of the code in rotator.php was the problem:

# file containg your image descriptions

$IMG_CONFIG_FILE = 'images.ini';

# You shouldn't need to change anything below this point

function showImage( $ini=null ) {
global $IMG_CONFIG_FILE;
# if no custom ini file has been specified, use the default
$ini_file = $ini ? $ini : $IMG_CONFIG_FILE;
# read the config file into an array or die trying
$images = @parse_ini_file($ini_file,true);
if (! $images) {
die('Unable to read ini file.');
}

My guess was that the $IMG_CONFIG_FILE = ‘images.ini’; outside of the showImage function was being overwritten by the gloal declaration within the function — but I don’t know php, and this script was working in other environments. To get it to work on mine (MAMP) I modified the above to the following:

# You shouldn't need to change anything below this point

function showImage( $ini=null ) {
$IMG_CONFIG_FILE = 'images.ini';
# if no custom ini file has been specified, use the default
# $ini_file = $ini ? $ini : $IMG_CONFIG_FILE;
# read the config file into an array or die trying
$images = @parse_ini_file($IMG_CONFIG_FILE,true);

if (! $images) {
die('Unable to read ini file.');
}

2 Comments more...

Using Spaces virtual desktops with one application, many windows

by Kyle Skrinak on Jul.03, 2009, under Technology

I read somewhere that Mac OS X Leopard’s Spaces virtual desktop manager did not allow for a single application to have multiple windows in multiple desktops. (continue reading…)

Leave a Comment more...

My admiration grows for Drupal

by Kyle Skrinak on Jul.01, 2009, under Technology

I recently needed to add a feature to a Drupal website I didn’t start but now manage. I had to make some webforms (a.k.a., “surveys,” to my beloved customer) available to only a select group of users. I created a role for the targeted user group. There were a few pitfalls — the site is Drupal 5, not 6, (and the difference matters nowadays, as the D6 base is more robust, go figure) and the recommended modules from the webform module references D6-only modules. So I had to hunt down an alternative, and found one, “Content Access.” I plugged it in, and after the usual learning curve, I had it performing its desired functionality whereby select webforms were visible to a selected user role. (My previous post is a video tutorial and setting the content access privileges for my client.)

So, here’s the kicker, something I realized only after I was done and moved on to other things. I have a “view” (as a page) that shows all webforms in the system. This is what I needed to filter down. I added the Content Access module, made the appropriate adjustments, and then my view respected the content access settings without hitch or modification requirements. That is remarkably tight integration. I love standing on the shoulders of giants.

Leave a Comment more...

Video Tutorial: Using Content Access for node view/edit/delete control

by Kyle Skrinak on Jun.17, 2009, under Technology

This is a video tutorial on controlling who can see content in Drupal using “Content Access.”
(continue reading…)

1 Comment more...

Stuff Happens: hostmysite (now called “Hosting.com” — see update)

by Kyle Skrinak on May.29, 2009, under Technology

KDS update 2009-11-03: Title changed, removed “Highly recommended site” from title; added new company name.

This isn’t an exhaustive review of competing solutions, a la Consumer Reports. I had a bad experience rant about godaddy, and now for some good news.

After dealing with somewhere less than 10 competing hosting services, I find myself continually pleased by the web hosting provider “hostmysite.com” (HSM) I learned of them through a customer who uses them for their site. SCI recently performed a critical migration for this customer from a static web site to a dynamic CMS site. At first we experienced HSM committing a number of errors and mistakes. For the first few days, it looked rather bleak, frankly, for HSM. However, when I had an issue, I’d call, and… get support nearly immediately. I’ve never waited more than 2 minutes. Remarkable. And, I get technically competent people who are NOT following those decision flow-charts. If they don’t know the answer, they’re on it until they figure it out. So, they tripped but they did worked until they ironed matters out.

I don’t have the admin control panel (it’s the customers) and so I have a very limited access. I can’t perform a fair UI review — but, really, it’s moot. If I have a problem I can’t fix, I call them and it’s fixed in short order.

If you’re looking for a hosting solution; give them a shot: hostmysite.com


October 19, 2009 update: I just closed a support ticket with Hosting that we opened on Oct 8. 10 days to resolve a ticket (no FTP access being one of the problems) is clearly significantly problematic. While the phone support remains excellent, such core failure is fatal. I am not recommending these guys for now.


November 03, 2009 update: From bad to worse: If I need to see or update file and directory permissions, I must issue a ticket. Really. As this is the only .NET hosting vendor with which I work, I can’t say how mainstream this is, but it does seem to stink. For me, the question is; “Is this symptomatic of the vendor, or does .NET tolerate less services for higher cost?

Leave a Comment more...

My Spine is the Command Line

by Kyle Skrinak on May.19, 2009, under Technology

I love this kind of stuff. Here’s a simple command line script that will output xHTML gallery of images in a single directory. Requires ImageMagick and zsh.

for i in sponsor-logos/*.*;do
j=`identify -format "width=\"%[fx:w]\" height=\"%[fx:h]\"" $i`
echo \<div\>\<img src=\"$i\" $j alt=\"$i:t\" /\>\<\/div\>
done

Sure I could have done this in php/rails/whatever, but I needed something quick and valid and output that I later use for the jquery “cycle” plugin (which I love, you can see it in use here, look for the cycling logos on the middle right of the page) and this does the trick.

There’s a dearth of documentation on  the jquery cycle plugin; sounds like a blog post.

Leave a Comment more...

Cool vim random line shuffle trick

by Kyle Skrinak on May.17, 2009, under Technology

Recently, I needed to perform a random sort of lines in vim. After a little bit of googling, I came up with the following:

(Works on Mac OS X Leopard and ubuntu 9.4)

Create the following perl script file:
#!/usr/bin/perl -w
use strict;
use List::Util 'shuffle';
my @lines = <>;
print shuffle( @lines );

Save the file and make it executable as well as easily accessible. Such as a directory that is in your PATH variable.

Now, fire up vim and visually select the lines you want to randomly select. Now, type:

!randsort.pl

There it is — randomly sorted lines.

1 Comment more...

ubuntu 9.04: First Thoughts

by Kyle Skrinak on Apr.24, 2009, under Technology

I did a poorly-advised thing — I upgraded my ubuntu production laptop to 9.04 on the day of its release. I have noticed that each successive kernel update pushed out of become increasingly reliable, and so my comfort level with performing low-level upgrades.

So far, the update has gone smoothly. I did a “best server” check prior to the update, and very interestingly the process returned a server at Duke University, a very close distance from my house. The downloading and staging for the update was fairly quick, about 90 minutes — not bad for “release day.” Perhaps the “best server” task netted me an advantage.

As for the upgrade process, I liked the diff options when upgrading the core components, such as mysql (my.cnf) and lighttpd (lighttpd.conf) so that I won’t lose customizations that I forgot about but use daily.

After the upgrade, I restart. There’s a new, smaller (or at least the display configuration better matches the display characteristics) progress display during bootup. ubuntu touts a quicker startup. I’m not seeing it, but I wasn’t looking for one, either. After bootup, I reapply my old changes to the new lighttpd.conf file, and all my local web apps run fine. Excellent. Moving on, I lost compiz (disabled) and had to modify my compiz.conf file to fix it. (editing at /usr/bin/compiz — but the change depends on your hardware) Losing my compiz settings is a minor annoyance but not too serious either.

To be continued…

Leave a Comment more...

How to kill your own argument

by Kyle Skrinak on Apr.20, 2009, under Technology

Perhaps there’s a claim to this already; if not I’d like to offer a corollary to Godwin’s Law;

“When someone is losing a process-related discussion he will invariably invoke the number of years he’s been in his profession.”

Leave a Comment more...

fink is dead; long live macports

by Kyle Skrinak on Apr.16, 2009, under Technology

I come not to bury fink, but to check macports out. If you look over my mac os x installation recipe (which is now more stained than my wife’s kitchen recipes thanks to all the changes) fink is remarkably out-of-date, often bested by Apple hosted binaries. It all begs the question, why keep using it? MacPorts, on the other hand, is the distribution system of choice at gimp, imagemagick, to name two quickly. Let’s see how it works; installing now.

Leave a Comment more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!