960gs Margin Mod July 23rd, 2009

Michael Hartmayer

Lately I’ve been working with the marvelously easy to use and understand CSS framework, 960 Grid System. After getting started with it, I very quickly noticed that, while easy and efficient, it has a flaw. You absolutely can NOT extend your elements to end after a margin, touching the next grid element. And so, one becomes effectively shackled to having margins between any horizontally placed grid elements.

Here’s a quick Mod that I wrote that will allow you to negate that problem, without modifying the 960gs CSS itself. Also, it is important to note, that while this does allow you to push your grid class over the margin, you still can’t pull the next element back. Still, another mod could be written using the same flavor to accomplish that as well.

So, without further adieu, here it is:

960.overExtend.css

/*
 
Modifies the 960gs to allow elements to carry over
into the margins, so that they may snugly touch
the next grid over. Simply use the appropriate grid,
as you normally would, and then attach the additional
overExtend class to it, to make it over extend into
the margin. 
 
Example:
 
<div id="myContainer" class="grid_5 grid_5_overExtend">
...
</div>
 
*/
 
/* Margin Mod 12 Col */
.container_12 .grid_1_overExtend { width:80px !important; margin-right:-10px !important; }
.container_12 .grid_2_overExtend { width:160px !important; margin-right:-10px !important; }
.container_12 .grid_3_overExtend { width:240px !important; margin-right:-10px !important; }
.container_12 .grid_4_overExtend { width:320px !important; margin-right:-10px !important; }
.container_12 .grid_5_overExtend { width:400px !important; margin-right:-10px !important; }
.container_12 .grid_6_overExtend { width:480px !important; margin-right:-10px !important; }
.container_12 .grid_7_overExtend { width:560px !important; margin-right:-10px !important; }
.container_12 .grid_8_overExtend { width:640px !important; margin-right:-10px !important; }
.container_12 .grid_9_overExtend { width:720px !important; margin-right:-10px !important; }
.container_12 .grid_10_overExtend { width:800px !important; margin-right:-10px !important; }
.container_12 .grid_11_overExtend { width:880px !important; margin-right:-10px !important; }
 
/* Margin Mod 16 Col */
.container_16 .grid_1_overExtend { width:60px !important; margin-right:-10px !important; }
.container_16 .grid_2_overExtend { width:120px !important; margin-right:-10px !important; }
.container_16 .grid_3_overExtend { width:180px !important; margin-right:-10px !important; }
.container_16 .grid_4_overExtend { width:240px !important; margin-right:-10px !important; }
.container_16 .grid_5_overExtend { width:300px !important; margin-right:-10px !important; }
.container_16 .grid_6_overExtend { width:360px !important; margin-right:-10px !important; }
.container_16 .grid_7_overExtend { width:420px !important; margin-right:-10px !important; }
.container_16 .grid_8_overExtend { width:480px !important; margin-right:-10px !important; }
.container_16 .grid_9_overExtend { width:540px !important; margin-right:-10px !important; }
.container_16 .grid_10_overExtend { width:600px !important; margin-right:-10px !important; }
.container_16 .grid_11_overExtend { width:660px !important; margin-right:-10px !important; }
.container_16 .grid_12_overExtend { width:720px !important; margin-right:-10px !important; }
.container_16 .grid_13_overExtend { width:780px !important; margin-right:-10px !important; }
.container_16 .grid_14_overExtend { width:840px !important; margin-right:-10px !important; }
.container_16 .grid_15_overExtend { width:900px !important; margin-right:-10px !important; }
Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • Live
  • MySpace
  • Reddit
  • StumbleUpon

Continue reading...


 

Alternating Styles in jQuery (Plug-In) July 16th, 2009

Michael Hartmayer

This is a little script that I wrote, that lets you easily alternate the style of repeating class elements, or w/e elements you want to select. This is particularly useful for lists, and the like.

function($){
$.fn.styleAlternation = function(aClass, bClass) {
    var i = 0;
    return this.each(function() {
        if (++i % 2 != 0 && aClass!='') {
            $(this).addClass(aClass);
        } else if(bClass!='') {
            $(this).addClass(bClass);
        }
    });
}(jQuery);

The usage is very simple. Here’s the JavaScript:

$("#awesomeTable tr").styleAlternation("cssClass1","cssClass2");

From there, all you need to do is create your CSS. Example:

.cssClass1 { background: #000; color: #444; }
.cssClass2 { background: #999; color: #333; }

Here’s a screenshot:
Alternation Demo

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • Live
  • MySpace
  • Reddit
  • StumbleUpon

Continue reading...


 

AJAX Calendar Loader Using jQuery July 15th, 2009

Michael Hartmayer

My good pal Austin needed help turning his static calendar into one that could change the month, using AJAX. The calendar itself was written in PHP. Here is the quick and easy solution I came up with for him, using jQuery:

$(document).ready(function() {
 
   // Create Date Object
   var jsDateObject = new Date();
 
   // Create Calendar Object ( Holds all your variables, etc )
   var jsCalendar = {};
       jsCalendar.currentMonth = jsDateObject.getMonth();
 
   // Controls the NEXT button
   $("#jsCalendarNext").click(function() {
      // Update Active Month
      jsCalendar.currentMonth++;
         if(jsCalendar.currentMonth>12) { jsCalendar.currentMonth=1; }
 
      // Get New Calendar
      ajaxUpdateCalendar();
   });
 
   // Controls the PREV button
   $("#jsCalendarPrev").click(function() {
      // Update Active Month
      jsCalendar.currentMonth--;
         if(jsCalendar.currentMonth<1) { jsCalendar.currentMonth=12; }
 
      // Get New Calendar
      ajaxUpdateCalendar();
   });
 
   // Use AJAX to update the Calendar
   function ajaxUpdateCalendar() {
      $.post(
         "phpCalendarLoader.php",
         { calendarMonth: jsCalendar.currentMonth },
         function(data) {
            $("#jsCalendarContainer").html(data);
         },
         "html"
      );
   }
 
});

From here, all Austin had to do was set his $month variable to $_POST['calendarMonth'];.

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • Live
  • MySpace
  • Reddit
  • StumbleUpon

Continue reading...


 

My Dad :) June 28th, 2009

Michael Hartmayer

Just got my Dad’s CD put on YouTube. Nothing fancy~

He’s been singing and composing all his life and put out two CD’s. This is a small preview of his ‘Golden Classics’ Album. For more information about the CD, please get in touch with wolfhartmayer@gmail.com

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • Live
  • MySpace
  • Reddit
  • StumbleUpon

Continue reading...


 

PHP LoadScript Class June 27th, 2009

Michael Hartmayer

This is a really handy class I wrote that loads all your scripts Server Side so that when your page loads there aren’t so many HTTP Requests. Useful if you’re trying to load 6 different js files and 4 different style sheets, or whatever. That’s 10 requests, completely gone. Just keep in mind that it dumps all your files straight into the html document- so, as long as you don’t have a problem with that, this is a great tool.

In addition, it’s really easy to add your own script types. Check out the script for details.

( Available At: PasteBin: LoadScript Class )

Usage:

<?php
   # Include Class
   include_once('class.scriptloader.php');
 
   # Instantiate
   $jsLoader = new ScriptLoader('JS');
 
   # Add Scripts
   $jsLoader->addScript('my-javascript.js');
   $jsLoader->addScript('jquery.js');
   $jsLoader->addScript('other-scripts.js');
 
   # Dump into Document
   $jsLoader->echoScripts();
?>

On a quick note, it’d probably be a lot ‘neater’ to mod-rewrite a php file to handle at least one request per script type. That way it doesn’t all get dumped straight into the page.

Something like:

RewriteRule ^script\.(.*)$ script-loader.php?type=$1 [L]

And for script-loader.php

<?php
   switch($_GET['type']) {
      case 'js':
         // Load all of the JavaScript files here
         break;
   }
?>

That way when you load something like script.js it will dump all of your java scripts into a ‘fake’ file. Just make sure to use the default $ScriptLoader->type (don’t set one when instantiating) if you are loading it from a src=”foo.bar”.

.. or something like that xD

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • Live
  • MySpace
  • Reddit
  • StumbleUpon

Continue reading...


 

PHP TripCode June 25th, 2009

Michael Hartmayer

** EDIT **
I found some problems with my code. =) Did some research on PHP’s crypt() and found out that the salt doesn’t quite work they way I had expected it to. Going to post a revision soon.

This is my version of a PHP TripCode (that I will be using for No-Mess-Enger). The way it works is, the user chooses a name, and a key. That information along with the randomly generated URI generate an integer that will eventually be used to select a random animal or something like that. This will allow users to remain anonymous while upholding the integrity of the users authenticity, in case another user tries to choose the same name.

function utilMakeTripcode($alias,$key,$uri) {
  # generate tripcode
  $s = crypt($alias,"$key#$uri");
  $r = '';
  for($i=0;$i<strlen($s);$i++) {
     $r.= hexdec(substr($s,$i,1));
  }
 
  return bindec($r);
}

Example:

- User enters the Alias: Jon
- User enters the Key: SecretWord
- The TripCode Int generated is 101

At this point I can use something like this to select the users animal:

$usersAnimal = $allAnimals[$maxAnimals-$maxAnimals%$tripCodeInt];

In this example $allAnimals is an array holding every Animal name. $maxAnimals is the array size, and $tripCodeInt is the integer generated from the utilMakeTripCode() function.

So now when the user talks in Chat he might be called:
Jon the Koala

** Note **
I’ve only TESTED the function. Can’t verify that the second snippet works exactly that way. It’s more pseudo code.. so don’t hate me if it’s not quite right. ^.^

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • Live
  • MySpace
  • Reddit
  • StumbleUpon

Continue reading...


 

Custom Scripting Language for Items June 20th, 2009

Michael Hartmayer

I’ve been working on some new software.. Below is a prototype version of my proprietary itemScript parser, written in PHP. The goal is to have a pseudo-scripting language available for game-items that can be read dynamically by the server, so that new items can be added without additional hard coding.

function scriptToArr($str) {
   # Parse for Whitespace
   $str = preg_replace("#(\r\n|\r|\n|\t|\s)#","",$str);
 
   # Event Handlers
   preg_match_all("#(.*?)\{(.*?)\}(,|)#is",$str,$findEventHandlers);
 
   $arrEvents = array();
   for($j=0;$j<sizeof($findEventHandlers[1]);$j++) {
      # this event
      $thisEvent = $findEventHandlers[1][$j];
 
      # these functions
      $getFunctions = $findEventHandlers[2][$j];
      $allFunctions = explode(";",$getFunctions);
 
      # get all parameters
      foreach($allFunctions as $function) {
         # read and parse function
         preg_match("#(.+?)\((.*)\)#",$function,$functionAndPara);
 
         $thisFunction = $functionAndPara[1];
         $thisParaSet = $functionAndPara[2];               
 
         # parse and arr strings
         while(preg_match("#\'(.+),(.+)\'#",$thisParaSet)) {
            $thisParaSet=preg_replace("#\'(.+?),(.+?)\'#","'$1\0COMMA\0$2'",$thisParaSet);
         }
         $thisParaSet = explode(",",$thisParaSet);
 
         # get each parameter
         foreach($thisParaSet as $parameter) {
            if($addPara = str_replace("\0COMMA\0",",",$parameter))
               $arrEvents[$thisEvent][$thisFunction][] = $addPara;
         }
      }
   }
   return $arrEvents;
}

Here is a sample script I created:

      onDraw {
         setMana( 1, thisPlayer() );
         doOtherThing( 5, thisPlayer() );
      },
      onExert {
         sendToHand( thisTile(), thisPlayer(), x, y, z, 0 );
      },
      onDestroy {
         setMana( 5, thisPlayer() );
      }

The script then gets torn apart and dumped into a multi-dimensional array. See Screenshot.

PHP Item Script Parser

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • Live
  • MySpace
  • Reddit
  • StumbleUpon

Continue reading...


 

User Interface: Doodle Ragnarok Patcher June 6th, 2009

Michael Hartmayer

Threw this together for the DoodleRO project I’m working on. This serves as the launch pad and patcher for Doodle. Utilizing the existing patch software I was able to seamlessly integrate the web interface (the stoney area) with the software application. Overall, I think it looks pretty decent. ^_^

Doodle Ragnarok Patcher

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • Live
  • MySpace
  • Reddit
  • StumbleUpon

Continue reading...


 

File Compression Hax June 3rd, 2009

Michael Hartmayer

So, I was playin around with WinZIP and WinRAR today, trying to understand how those programs work. I mean- I know HOW they work, but I wanted to see which types of files compress the best, and which don’t. It came to no surprise that text documents are the easiest to pack up, since there is so much data redundancy. So, I had a little fun.

I created a 100MB text file filled entirely with whitespace. Then I RAR’d it, and then ZIP’d that. Amazingly enough, I was able to reduce a 100MB file to 222bytes. That’s even less than my minimum sector size (4kb) . Awesome.

Check it out!

Download: Compression Hax

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • Live
  • MySpace
  • Reddit
  • StumbleUpon

Continue reading...


 

The “M”pire – Just for Fun June 3rd, 2009

Michael Hartmayer

Lawl, check out my new work background.

The M Pire

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • Live
  • MySpace
  • Reddit
  • StumbleUpon

Continue reading...