Categories
post

Drobo

I have been using a Drobo and DroboShare for almost two years now and have been very happy with it. I have used it to replace a windows machine that I was using just as a file share.

The one I have is kind of slow over the network. I know the newer versions are faster. I just deal with the speed, in the long run, it doesn’t bother me that badly. And for doing backups, it’s amazing.

What is a Drobo? Click Here to Find Out

Categories
post

Conditional Statements in Mysql (if/case/etc)

I never really thought to ask the question, but was shocked to see you can do simple conditional statements in Mysql. This will make my querying far better than in the past. Plus I can pull quick data when needed instead of writing a script to analyze it.

Example, trying to find out if an order was placed in our callcenter or on the web:

SELECT orderDate, if(ipAddress = ‘XXX.XXX.XXX.XXX’, ‘CallCenter’, ‘Web’) as WherePlaced, count(*) as cnt FROM orders GROUP BY orderDate, WherePlaced

Simple, but only useful if you know about it. Now I do. 🙂

Categories
post

Getting Counts For Groupings From Mysql

My dad “beto” asked me about a topic he would like to use on his website.  I decided to share it publicly.

He has a simple select box that stores a “Yes/No/Maybe” option in a table.  He wants to include the results on a webpage.

I have to assume his Mysql table (let’s call it ReunionAttendance) has at least two columns (SelectBoxValue, GuestsAttending).  Adjust the field names for the actual table columns in your table.

There are many ways to do this.  I am going to do it this way for a demonstration:

<?php
/*  Steps needed
1) Get data from table
2) Put data into a variable
3) Display the table via HTML
*/

/* 1 */
$result = mysql_query(“SELECT SelectBoxValue, SUM(GuestsAttending) as Attending FROM ReunionAttendance GROUP BY SelectBoxValue”);

/* 2 */
while (list($comingValue, $comingCount) = mysql_fetch_row($result)) {
$list[$comingValue] = $comingCount;
}

/* 3 */
?>
<div id=”WhosComing”>
<table>
<thead>
<tr>
<th>Coming?</th>
<th>Total</th>
</tr>
</thead>
<tbody>

<?php
foreach ($list as $comingValue => $comingCount) {
?>
<tr>
<td><?php echo $comingValue?></td>
<td align=”right”><?php echo $comingCount?></td>
</tr>

<?php
}

?>

</tbody>
</table>
</div>

Categories
post

Do You Foresee Any Problems With This Approach To YouTube Videos?

I am trying to squeeze every excess byte out of my downloads. I noticed that even with the iFrame version of YouTube videos, users have to download almost 200K worth of data.

I decided to use the screenshot stored at YouTube (replace all occurrences of VIDEOID with a youtube video):
http://img.youtube.com/vi/VIDEOID/0.jpg

HTML:

 

<div align=center id='vidVIDEOID' stlye='clear: both; margin:0; padding:0;'>

<img class='YouTubeScreen' rel='VIDEOID' src='http://img.youtube.com/vi/VIDEOID/0.jpg' border='0' />

</div>

And use jQuery javascript like this:

$(".YouTubeScreen").click(function(e) {

var vid = $(this).attr('rel');

$("#vid" + vid).html('<iframe title="YouTube video player" width="640" height="390" src="http://www.youtube.com/embed/' + vid + '?autoplay=1" frameborder="0" allowfullscreen></iframe>');

});

Categories
post

How to Play/Pause iTunes With Your Magic Mouse

This was one of those things that I couldn’t believe the Magic Mouse didn’t handle automatically for you. However, you can install Magic Prefs for free. With in there you can add ActionScript. It isn’t very clear how to do this.

First copy this to your clipboard:
tell application “iTunes”
playpause
end tell

Then, choose a mouse action, follow menus down to Custom Actions => Manage ActionScript
Just type a name into the top box and click the +

You will then see it in your list of available actions for the mouse.

Categories
post

BugZilla should be renamed

We use bugzilla internally for so much more than a “bug” reporting system. I have done internal presentations about the product and have jokingly called it OrganiZilla or TicketZilla.

The software offers fantastic Organizational qualities to help us stay on top of tasks. And once you get past the idea of bugs and call them tickets, you realize that there is a much broader use of it.

From updates on a website to telling someone to take out the trash, it works! But only if everyone is on board.

Categories
status

Been looking into some of the facebook …

Been looking into some of the facebook “magic”. I decided to add the recommendations on the right hand side here. I have also implemented some of the like buttons on bowlingball.com.

Categories
Programmer's Mindset

PHP User Groups (Orlando and Daytona Beach)

I am a member of two PHP user groups.  Each one runs a little bit differently.  I am looking for feedback from other people in other PHP user groups to find ways we may be able to make these better.

The East Central Florida PHP User Group (Daytona Beach area) is new/restarting.  They have only had one meeting so far, and finally scheduled another a few months later.  They seem to be more geared towards teaching new PHP developers.  While we haven’t done anything so far, they are leaning towards a mentor/student type of group.

The Orlando PHP User Group is quite different.  They lean towards more presentation style meetings.  Someone proposes a topic, and then someone volunteers to be the presenter.  If there isn’t a presentation, then they do some coding in DjangoDojo.  I have not been to a meeting without a topic yet, so I am not sure how those go.  I probably should since I am not very familiar with Django (or Dojo for that matter) at all.

Of the two, I prefer the Orlando version because I am growing my skills.  However, I may like the mentor version because I feel I am a decent programmer and love teaching.

I am looking forward to doing a presentation sometime, because I really want to improve my speaking skills.

How does your user group run?  What is your preference?

Categories
post

Multiple WordPress Blogs in One Installation

I have been hosting multiple wordpress blogs in one installation for a few years now. I like that I can upgrade one installation, and they all upgrade. I don’t have to go through 10 different installs/upgrades.

There are a few things that can be considered either a pro or a con based on your point of view. If one blog uploads a theme or a plugin, it is available to all the others. This doesn’t mean that if one enables it, they all have to have it enabled. It’s just there, so each can install if they need to.

One serious downside is customization. If one blog customizes a template, another blog can’t use it unless they too want that customization.

On to the nitty-gritty, all I do is change the wp-load.php file and copy the wp-config.php file. I copy the wp-config.php to wp-config-DOMAINNAME.php (example wp-config-www.johncongdon.com.php). Each config file changes the database table prefix.

Here is a diff for the wp-load.php file. It just changes an if statement to load our individual config, if it doesn’t exist, it loads the original wp-load.php.

--- wp-load-orig.php	2011-03-07 15:18:12.000000000 -0500
+++ wp-load.php	2011-03-07 10:30:04.000000000 -0500
@@ -24,7 +24,12 @@
 else
 	error_reporting(E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING);
 
-if ( file_exists( ABSPATH . 'wp-config.php') ) {
+if ( file_exists( ABSPATH . 'wp-config-'.$_SERVER['SERVER_NAME'].'.php') ) {
+
+  /** The config file resides in ABSPATH */
+  require_once( ABSPATH . 'wp-config-'.$_SERVER['SERVER_NAME'].'.php' );
+
+} elseif ( file_exists( ABSPATH . 'wp-config.php') ) {
 
 	/** The config file resides in ABSPATH */
 	require_once( ABSPATH . 'wp-config.php' );

Categories
post

Patching osticket for PHP 5.3

OSTicket is a decent piece of software for customer service. I upgraded to PHP 5.3 and had some problems because they are trying to keep it working all the way back to PHP 4. 🙁

Here is a patch to fix the eregi_replace deprecated errors.

diff --git a/osticket/include/class.format.php b/osticket/include/class.format.php
index 6cbb414..0380268 100644
--- a/osticket/include/class.format.php
+++ b/osticket/include/class.format.php
@@ -78,10 +78,10 @@ class Format {

     //make urls clickable. Mainly for display
     function clickableurls($text) {
-        $text=eregi_replace('(((f|ht){1}tp(s?)://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)','\\1', $text);
-        $text=eregi_replace("(^|[ \n\r\t])(www\.([a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+)(/[^/ \n\r]*)*)",
+        $text=preg_replace('#(((f|ht){1}tp(s?)://)[-a-zA-Z0-9@:%_\+.~\#?&//=]+)#','\\1', $text);
+        $text=preg_replace("#(^|[ \n\r\t])(www\.([a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+)(/[^/ \n\r]*)*)#",
                 '\\1\\2', $text);
-        $text=eregi_replace("(^|[ \n\r\t])([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,4})",'\\1\\2', $text);
+        $text=preg_replace("#(^|[ \n\r\t])([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,4})#",'\\1\\2', $text);

         return $text;
     }

diff --git a/osticket/include/class.validator.php b/osticket/include/class.validator.php
index 284d7c7..697d99c 100644
--- a/osticket/include/class.validator.php
+++ b/osticket/include/class.validator.php
@@ -126,15 +126,15 @@ class Validator {

     /* Functione below can be called directly without class instance. Validator::func(var..); */
     function is_email($email) {
-        return eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$",trim($email));
+        return preg_match("#^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$#",trim($email));
     }
     function is_phone($phone) {
-        $stripped=eregi_replace("(\(|\)|\-|\+)","",ereg_replace("([  ]+)","",$phone));
+        $stripped=preg_replace("#(\(|\)|\-|\+)","",preg_replace("/([  ]+)#/","",$phone));
         return (!is_numeric($stripped) || ((strlen($stripped)<7) || (strlen($stripped)>13)))?false:true;
     }

     function is_url($url) { //Thanks to 4ice for the fix.
-        $urlregex = "^(https?)\:\/\/";
+        $urlregex = "#^(https?)\:\/\/";
         // USER AND PASS (optional)
         $urlregex .= "([a-z0-9+!*(),;?&=\$_.-]+(\:[a-z0-9+!*(),;?&=\$_.-]+)?@)?";
         // HOSTNAME OR IP
@@ -149,9 +149,9 @@ class Validator {
         // GET Query (optional)
         $urlregex .= "(\?[a-z+&\$_.-][a-z0-9;:@/&%=+\$_.-]*)?";
         // ANCHOR (optional)
-        $urlregex .= "(#[a-z_.-][a-z0-9+\$_.-]*)?\$";
+        $urlregex .= "(\#[a-z_.-][a-z0-9+\$_.-]*)?\$#";

-        return eregi($urlregex, $url)?true:false;
+        return preg_match($urlregex, $url)?true:false;
     }


@@ -161,7 +161,7 @@ class Validator {
             return false;

         $ip=trim($ip);
-        if(ereg("^[0-9]{1,3}(.[0-9]{1,3}){3}$",$ip)) {
+        if(preg_match("#^[0-9]{1,3}(.[0-9]{1,3}){3}$#",$ip)) {
             foreach(explode(".", $ip) as $block)
                 if($block<0 || $block>255 )
                     return false;