0

Google Analytics Custom Segmentation by Role in Drupal

Posted by stuporglue on Apr 30, 2010 in Computers, Programming

At the company I work for, I was already using Google Analytics to track visitors to the website, but I wanted a little more information. I wanted to see how many visitors were staff, versus other visitors. Put the Pieces on the Table The first piece we needed was already in place. We are using Drupal for our website, and every staff member needs to log in from time to time for various staff only resources. Regardless of any other permissions they may have, everyone who is staff is made part of the role “staff”. Google lets you add up…Read the Rest

Tags: , , , ,

 
2

Update Multiple Rows At Once With Different Values in MySQL

Posted by stuporglue on Apr 22, 2010 in Programming

I’ve had to figure this out on my own twice now, so I guess it’s time to document it. It is possible, and fairly easy, to update multiple rows of a MySQL table at the same time, with different values for each row. Unfortunately it’s not as easy as inserting, but once you see what’s being done you will probably say “Oh, of course!”. The key to the multiple row update query is the CASE statement.  MySQL’s CASE reference page doesn’t even have the word “UPDATE” on the page anywhere, but don’t let that fool you, it can be used…Read the Rest

Tags: , , , ,

 
0

Segmenting Drupal Users By Role in Google Analytics

Posted by stuporglue on Mar 26, 2010 in Programming, Projects

We use Google Analytics and Drupal at work. We have been tracking our website usage for quite a while now, but we had no idea what percentage of our visitors were staff. We have 13 main locations, so IP filtering could’ve gotten us most of the way, but staff members do work from home and on the road quite a bit too. In the end I decided that the best route would be to use Google Analytics _setCustomVar funcitons to record the data we wanted. Staff members at work have the role “staff”, so that’s what I wanted to select…Read the Rest

Tags: , , ,

 
4

Recieve E-mail and Save Attachments with a PHP script

Posted by stuporglue on Mar 24, 2010 in Programming, Projects

Here’s something fun! If you can tell your server to send e-mail to a script, you can send e-mails to PHP. Once you are processing the e-mail with PHP you can save attachments, automatically respond to the e-mail, save it to a database, make a webpage from it…really whatever you want! Here’s a script I am currently using. My brother is on a mission for our Church, in Peru for two years and has near weekly e-mail access but can’t do much more than e-mail. He wanted a way to easily send photos to the server via e-mail; this script…Read the Rest

Tags: , , , , , ,

 
0

ISOlator

Posted by stuporglue on Mar 20, 2010 in Programming, Projects

Got a Linux CD you want another copy of, but don’t want to download it again? Got a CD that needs to be in the computer to play your game, but you don’t want to risk scratching the original? Need to make backups to protect against kids? ISOlator is for you. ISOlator takes a CD, DVD, or other mounted volume and makes an ISO out of it. The ISO can then be burned to CD, stored on your backup disk (you DO backup, right?), or put to use however you like. ISOlator uses the Unix command line program ‘dd’ to…Read the Rest

Tags: ,

 
0

Writing a daemon with PHP

Posted by stuporglue on Mar 20, 2010 in Programming, Projects

PHP isn’t used to write daemons very often, and other languages (like Perl or C) might be more suited to your typical daemon. There are times when PHP is the right choice though, for instance if the rest of your project is a PHP website and you want to keep the same code language across the project. Everything here is available elsewhere online, but I couldn’t find a page that brought it all together neatly (fork, exec, waitpid, signal handling), so here it is. In this case, I wanted to be able to use the same DB connection file and…Read the Rest

Tags: , , , , , , , ,

 
1

Handling Signals in PHP

Posted by stuporglue on Mar 20, 2010 in Programming, Projects

Handling signals in PHP is really not to difficult once you get the hang of it. What’s a signal? When an operating system wants a process to terminate, it will usually send the SIGTERM signal (terminate). SIGTERM is essentially a request. It tells the program “I would really really really like you to shut down”. Most programs, being polite do so. There are many signals which you can see in your man pages (man 7 signal), but just a couple of important ones. kill sends a SIGTERM, Ctrl-C sends SIGINT, closing your terminal sends SIGHUP. SIGKILL can’t be handled and…Read the Rest

Tags: ,

 
0

Add OpenSearch search to your site

Posted by stuporglue on Mar 18, 2010 in Programming, Projects

One of the original reasons I switched to Firefox was the built-in Google search box. Now even Internet Explorer has built in search. You can search Google, Bing, Wikipedia, etc, but what if you want people to be able to search your site from their browser? What if you want to search some other site from your browser? Enter OpenSearch. OpenSearch describes a format for a special XML file you host on your site. When an OpenSearch compatible client comes along, they can detect that file and allow the user to search using the parameters you specify. Basically, it’s a…Read the Rest

Tags:

 
0

Custom CSS Stylesheets for Small Screens

Posted by stuporglue on Mar 18, 2010 in Programming, Projects

I’ve gotten a good handfull of visitors from EeePC related sites, so I assume that some visitors are coming on their EeePCs. I was playing with some other site layout issues at the same time anyways, so I decided to do a couple of things to make it easier on those with small screens. Notice: This info is old and probably out of date. A better method of doing this probably exists. If it’s helpful, great, but please take it with a grain of salt. Smart Chunking The main reason this site doesn’t play well with small screens is because…Read the Rest

Tags: ,

 
0

Convert an image to fake Sepia with PHP

Posted by stuporglue on Mar 18, 2010 in Programming, Projects

It’s pretty easy to do image manipulation with PHP.  Here’s a sample of converting an image from color into sepia using PHP’s imagefilter. Be sure that your memory_limit will handle the image sizes you want to process. @imagecreatefromjpeg will return FALSE if it can’t load the image (because of a bad file path, file size or whatever).  This isn’t a real sepia conversion, but it’s a decent fake. The image is converted to greyscale, the brightness turned down, and then colorized with a red tint. PHP’s imagefilter has lots of other neat tricks it can do, so be sure to…Read the Rest

Tags: , ,

Original content on this page is under the Creative Commons Attribution-ShareAlike 3.0 License unless otherwise noted.

If you found this page particularly helpful, I'd love to hear from you. A link to this page from your blog or website would also be appreciated.

I'm the real Michael Moore