Perl for dummies

In the hours of the early morning here at work i enjoy the silence. It allows my mind to unravel the craziness of the previous day and take quiet walks around the office space. Recently i have been noting the books that people have on their shelves, and its odd - many people have the O’Reilly Programming novel sitting up on their desks/bookshelves here. I say this is odd because so many people dont know a god damned thing about or have a barely functional knowledge of how it works or how to code in it.

One such example is pertaining to a failed attempt to be a software developer. An application with a “Template engine” that is controlled by the function you run previously. This is one aspect of this application that should let you all know how complicated this has been devised. I am convinced that i could simplify the code base considerably, given the freedom to do so, but alas - i cannot.

Its odd that people purchase or borrow or share books when they are not willing to actually read them. There are a number of very interesting and necessary tidbits that sit just below the surface of that are more than useful; that are more than powerful; that are able to correct code that you have just spent four hours working on instead of reading four hours yesterday. It’s called a Map. Use it.

Posted on August 2nd, 2008 by Bob in Application Development, Web Development

This past weekend!

This past weekend was quite hectic. I went hiking, running, went to the mall, and… built out the basis of the new Atheist Nation Chat Engine. This project is my introductory project in use with JQuery publicly and I must say its been fun. The current chat engine has a few more features, but they are slowly being incorporated into the system and I think that it should be usable as a replacement in a couple days (assuming my workload doesn’t skyrocket again).

Posted on July 22nd, 2008 by Bob in Game Development, Gneu Website, Inspiration, Web Development

Code Example #5 - WinGrepReplace

In the day to day happenings of web development many of us get into binds and have problems getting out of them. Yesterday a good friend of mine came to me with a huge problem. Her website of more than 700 files needed to have certain entries replaced and the amount of time it would take to go through them all and replace the lines individually was not worth the effort. Thankfully she knows that i dont do anything that difficult by hand, i invent something to do the work for me and give my computer a smack on the butt and just wait for the results.

Here is the code to do just that:

#!/usr/bin/perl -w
################################################################################
# WinGrepReplace
#
# Replace a given line in all files in a directory of files.
################################################################################
 
use File::Find;
use File::Copy;
 
die "Usage: $0 directory find [replace]"if (@ARGV > 3 || @ARGV < 2 ||
!-e $ARGV[0] || length $ARGV[1] == 0);
 
our ($dir, $find, $replace) = @ARGV;
 
find(\&func, $dir);
 
sub func
{
   return if !stat || -d;
 
   open(FILE, "<$_");
   open(FILEO, ">$_.new");
 
   while (($line = ))
   {
       $line =~ s/$find/$replace/i if ($line =~ m/$find/i);
       print FILEO $line;
   }
 
   close FILE;
   close FILEO;
 
   move("$_.new", $_);
}

Although there are a couple of hacks and vulnerabilities in this block, it gets the job done nicely.

Posted on July 17th, 2008 by Bob in Random, Web Development

Video Bracket Tags

This plugin provides the ability to embed a number of video objects into your WP pages. The formatting is based off of the familiar BBCode tagging, so anyone who regulars forums these days will already be comfortable with their usage.

[Downloadable On Wordpress.org]

This plugin provides the ability to embed a number of video objects into your WP pages. The formatting is based off of the familiar BBCode tagging, so anyone who regulars forums these days will already be comfortable with their usage.

The current supported formats are:

  • Blip.tv [bliptv={ID}]
  • BrightCove [brightcove={ID}]
  • DailyMotion [dailymotion={ID}]
  • Google Video [google={ID}]
  • LiveLeak [liveleak={ID}]
  • MySpace Video [myspace={ID}]
  • RevveR [revver={ID}]
  • Veoh [veoh={ID}]
  • Vimeo [vimeo={ID}]
  • Youtube [youtube={ID}]
  • Youtube Custom Player [youtubecp={ID}]

The tags accept a number of parameters. Justification, Width, Aspect Ratio and a text Blurb are all editable on a per tag basis.

[youtube=-GG7sj2APpc,LEFT,340,16:9,This is my test blurb,AUTOPLAY]

This will embed a youtube video left justified with a width of 340, aspect ratio of 16:9 and the blurb of “This is my test blurb” as its link.

Ordering of these parameters does not matter, and no, its not case sensitive.

New Features

  • Options Menu has a new entry to control styling. Raw CSS is available to be tweaked on a site wide basis
  • Added two new providers - MySpace Video and Daily Motion.
  • Autoplay is now fully functional on Vimeo, Google and LiveLeak as well as Youtube Videos.
  • Corrected a linking issue for Veoh and Liveleak
  • Deprecated Float Keyword

Currently Supported Parameters

  • FLOAT - Left Justification
  • LEFT - Left Justification
  • RIGHT - Right Justification
  • NOLINK - Do not include video origin link
  • LINK - Force Inclusion of video origin link
  • Ratio - Accepted Ratios are - 16:9 16:10 1:1 221:100 5:4 - All other provided values are set to 4:3 (the most common video ratio)
  • Numerical Values - If you provide any numerical values you are setting the width of your video.
  • Alphanumeric Values - When you post your video you may want to change the text value from the default to something descriptive or to caption something in the video.

Selected video players only

  • AUTOPLAY - Autoplay video when loaded
  • NOAUTOPLAY - Don’t autoplay video when loaded - if you have autoplay defaulted to on.

Change Log

Version 2.2.1

  • Corrected Video caption mixup.

Version 2.2.0

  • Add CSS Style div around embedded video.
  • Add Autoplay to all video formats where applicable {Vimeo, Google, LiveLeak, Youtube}
  • Add Myspace, DailyMotion video formats
  • Corrected Linking Issue - Veoh & LiveLeak
  • Deprecated Float Keyword

Version 2.1.2

  • Extended Keywords {NOLINK, LINK, NOAUTOPLAY, AUTOPLAY}
  • The colon is now acceptable for use in the text blurb
  • Updated the options menu to include autoplay as a sitewide option.

Version 2.1.1

  • Properly Added Options Menu
  • Further reworking of the code
  • moved all functions into class

Version 2.1

  • Further reworking of the code
  • Added Options Menu

Version 2.0.2

  • Added RevveR
  • Corrected some code (simplification)

Version 2.0.1

  • Added Blip.tv
  • Expanded on description to include information about the parameters
  • Added NOLINK parameter to be a per item option

Version 2.0

  • Complete Revision of Plugin from previous state
  • Added a number of parameters, consult description for further information
  • Added a different mechanism for parsing the Excerpt v. the Content of the post.
  • Brought everything together in a class (serves as a namespace for now)
  • Now is much easier to add further objects, including non video items.

Posted on December 1st, 2007 by Bob in Random