Sunday, January 27, 2008

When it rains it php's

Ever wanted to convert a camel case string into something more user friendly?

Introducing the super dupa know it all function, should be good for PHP 4+

PHP

/*
Make a camel case string user friendly ^_^
*/
function implodeCamelCase( $pStr, $delimiter = ' '){

$strArr = str_split($pStr);
$retArr = array();

foreach( $strArr as $val ){

if( ord($val) <= 90 ){
array_push($retArr, ' ');
}

//add to return array
array_push($retArr, $val);
}

//explictly destroy array
$strArr = null;

return mb_convert_case(implode('',$retArr),MB_CASE_TITLE);
}


It's a bit rough around the edges, anything thats not a lower case character or anything else with a decimal ascii number over 90, will have a space inserted before it, of course thats easy enough to tweak.

Saturday, January 26, 2008

Json Encoding

For a enterprising young developer like myself, i don't take advantage of json enough. So since i'm in the mix at the moment, with my DFTI course work, i thought now would be a good time.

Unfortunately the json_encode() function that i had seen in the PHP documentation, is only in the CVS distributions at the moment (v 5.1.2), so i came up with the below.

PHP

/*
This function converts an array to a Json string.
*/
function jsonEncode( $pArr ){
$arr = Array('{');

foreach( $pArr as $val ){

if( is_numeric( $val) ){
array_push($arr, $val );
}else{
array_push($arr, '"');
array_push($arr, $val);
array_push($arr, '"');
}
array_push($arr,',');
}
//Remove trailing comma
array_pop($arr);

return implode('',$arr);
}

/*
This function converts an associative array to a Json string.
*/
function jsonEncodeAssoc( $pArr ){
$arr = Array('{');

foreach( $pArr as $key => $val){
array_push($arr, '"');
array_push($arr, $key);
array_push($arr, '"');
array_push($arr, ':');

if( is_numeric( $val ) ){
array_push($arr, $val);
}
else{
array_push($arr, '"');
array_push($arr, $val);
array_push($arr, '"');
}

array_push($arr, ',');
}

//Remove trailing comma
array_pop($arr);

array_push($arr,'}');

return implode('',$arr);
}


Both functions take either a regular array, or a Associative and converts it to a json string, which looks like ...


{"id":1,"name":"Ham And Pineapple","description":"<p>Fusce magna sem, gravida in, feugiat ac, molestie eget, wisi.</p>","categoryId":1,"hasNuts":0,"vegetarians":0,"imagePath":"ham-and-pineapple.gif","price":4.95}



The above is just some data from my database. It's a pizza ordering system. I plan to go all ajaxan with a Drag and drop shopping cart, as well as some other shiny stuff.

I haven't a clue what i'm going to do concerning javascript, i'm looking at mootools, mochikit, and of course jquery and maybe even yahoo ui. Might be a last minute thing.

Sunday, January 13, 2008

My Broadband got upgraded!

Or at least so it would appear

Happy posting :), and don't write anything too stupid!

I don't know about you, but this is the fastest torrent speed i've witnessed, ever. Speedtest.net put the connection speed at 6mb!

Wednesday, January 09, 2008

Happy New year, have a server for 08

Happy 2008.

I'm in the middle of finishing up my Object Orientated Application Assignment, and i ran across this piece of code in my repository.


import java.io.*;
import java.net.*;

public class ServerInstance {

private Socket Connection;
private BufferedOutputStream Outbound;
private InputStream Inbound;
private HTTPData RawHttpData;

private int listeningPort;

//ClassFlags
private boolean connectionEstablished = false;
private boolean instanceComplete = false;

public ServerInstance(){
//This one Sets all variables to defaults
listeningPort = Preferences.DEFAULTPORT;
}

/*public ServerInstance(Preferences){

}*/

public boolean run(){
ServerSocket ListenSocket;

boolean retBool = false;
boolean endLoop = false;
int readValue = -1024; // Set to extreme value to show that it is default;
int i = 0;

/*
* How the Server Will work
*
* 1. Get the Data from the browser / Read the Stream
* 2. Send Data off to extract the headers
* 3. While Data is being Processed Send data back to the client
* 4. Flag that server action is complete, and shutdown and clean up
*
*/
try{
ListeningSocket = new ServerSocket( listeningPort );

Connection = ListeningSocket.accept();

connectionEstablished = true;

//1. Get Data from Browser
Inbound = Connection.getInputStream();

Outbound = new BufferedOutputStream ( Connection.getOutputStream() ); //Place output in a Buffered Stream

//Write to both Objects simultainously
while( !endLoop ){
readValue = Inbound.read();

if(readValue != -1){
Outbound.write( readValue ); //Send data to the client
RawHttpData.write( readValue ); //Write data to a HTTPData Object
}
else{
endLoop = true;
}
i++;
}

Outbound.flush(); //Make sure all the data has been sent back to the browser
//Just while we code
System.out.println("Server: has RX/TX " + i + " Bytes of data");

//4. Clean up
Inbound.close();
Outbound.close();
Connection.close();

instanceComplete = true;
}
catch(IOException e){
System.out.println("<-- Server Error -->");
System.err.print( e );
}
catch(IllegalBlockingModeException e){
//I doubt this will come up, but refer to java documentation on serversocket.accept() in the event it does
System.out.println("<-- Server says no! -->");
System.err.print( e );
}
finally{
return retBool;
}
}

public boolean isConnected(){
return connectionEstablished;
}

public boolean isComplete(){
return instanceComplete;
}
}


Code is released under the GPL 2.0 License, go forth and improve (and credit).


This is a working server implementation in java, a relic from my isolation project,( Isolation was meant to act as a personal proxy, similar to how google gears works, however their wouldn't need to modification to the web app, as isolation was meant to pre-fetch the data, based on monitor the users actions/http requests.).

Anyway as you can imagine this was a big project, coupled with my second major data disaster, it didn't really ever see the light of day.

Couple of things to mention, the Preferences class was a data structure to store, ... well user preferences, and the class was meant to implement the runnable interface, so that you could operate multiple server instances.

I learnt a lot researching for it, and thanks to it i have a very good idea of how the HTTP protocol works, however i think it was a little too complex for someone at my current level, i should really stick to trying to reverse engineer front row, and learning lisp.

On the note of the reversing of front row, a plugin called sapphire was released last year. From what i can determine they have worked out how to beat apples protection scheme governing the loading of foreign NSbundles (Yeah, i know about them!). So when i finally get around to it, i'll (try to) reverse it as well.

Quote of the Day
"Rave for business"

I love Capitalism, don't you

Saturday, December 29, 2007

rounded corners anyone?

You may notice my new rounded corners.

Well in true fashion, they're CSS corners.

Instead of loading up one of the many css corner library, i decided to take the opportunity to write my own. The other plus is that as this is a blogger account, i have no real file storage, so linking against the jquery lib makes way more sense.


//Corner rounding function
roundCorners = function( pElement, pSize, pForeground, pBackground ){
//Logging
/*
console.log( 'Corner size ' + pSize);
console.log( 'Fore color ' + pForeground );
console.log( 'Back color ' + pBackground );
*/
if( pBackground.match('none') != null ){
pBackground = 'transparent';
//console.log('transparent background');
}

//constants
containerStr = '<div class="cornerContainer" style="margin:0px 0px;height:auto;background:'+ pBackground +'"></div>';
cornerAttributesStr = 'border:none;overflow:hidden;height:1px;background-color:'+ pForeground +';';


//Reset the parent element
$( pElement).parent().css('padding','none');

//Insert container Div and set background color
$(pElement).prepend( containerStr );
$(pElement).append( containerStr );

for(i=1;i < pSize; i++){
$('div.cornerContainer').eq(0).append('<div style="' + cornerAttributesStr + 'margin: 0 '+ Math.round(pSize/i) +'pt"></div>');
//console.log('Insert element ' + pSize/i);
}

for(i=pSize; i > 1; i--){
$('div.cornerContainer').eq(1).append('<div style="' + cornerAttributesStr + 'margin: 0 '+ Math.round(pSize/i) +'pt"></div>');
}

}


Currently it doesn't support chaining, however according to my understanding, you just have to encapsulated within a jquery.extend, and change the passed object references call and your good to go.

Tuesday, December 25, 2007

New Design

Just a quick note to say here is the new design. Nice and light weight, no shiny stuff (yet). I'll add in some javascript nuts and bolts later, but now i have to set the table for christmas dinner. Btw, this took me like 3 hours, not too bad considering i have to cut and paste into the online editor.

Merry Christmas

Saturday, December 22, 2007

And to think people think i waste my time

I've been hitting the Dev Trail pretty hard over the last week or so. My fringe Cocoa/Objective-C skills are getting better each day. To give you an idea of what my Programming space looks like here's a screenshot.
The Work zone
To summerize, i'm in the middle of linking the mysql-cocoa framework into my project. Now i have hit a slight snag on that front. The snag being that it looks like i can't sell the app.

Why? Because the use of the GPL'd open source framework means that i have to release the source code. Now for a long time, i have considered releasing an application that one has to pay for, but is also open source. However with this kinda of app, my target market, most likely already has xcode installed, and would find it trivial to download the source and hit 'build'.

I'm gonna email the FSF, and find out what they have to say. But i think i might try and release this as an open source application. I love open source as much as the next guy, so maybe this is the way it should go down.

In other news i've finally popped for a Western digital 250GB notebook hard drive. After some stupidity (and a trip to Eastleigh) on my part it's churning away inside my Macbook. The old drive is now a Time machine Drive, speaking of time machine ...

Interface design at it's wildest

It's a nutty excuse for an interface, but it really is fantastic. Pre-Time Machine, i used a backup script i 'wrote' in automator, however it wasn't as flash as this. However it did zip my documents folder from almost 2GB to 700MB which always impressed me, or at least one side of me.

Well it's almost the end of another year and this blog has seen quite a few annual transitions now, 4 to be correct. In keeping with RSS tradition i'll have the usual wrap up posts, plus a 4/5 redesign. Hopefully this time done properly with more ajax than you can shake a stick at, and a cleaner ui, after all i'm a professional now ........



Quote of the Day

Caption

Sunday, December 16, 2007

One byte

Not sure what all the moaning was about, but i must say i like the look of the new iplayer from the bbc. It's not a big slab of flash. Nice ajax like effects. Works in safari. A nice job i would say overall.

I doubt it works for those outside these fair shores, but if it does work i would recommend.

Btw this is post 255, hence the title.

Merry Christmas

Wednesday, December 12, 2007

Reg Exp

In case you ever need them, here are a couple of regular expressions for dealing with dates.

For dates like this: December 19, 2008

[A-z]{3,8}.[0-9]{1,2}.{1,2}[0-9]{4}


For dates like this: 05/03/87

[0-9]{1,2}/[0-9]{1,2}/[0-9]{1,2}


They form part of my fantastic plan to .... write loads of regular expressions ^_^

Tuesday, November 13, 2007

Google's Android: My two cents

I love it. At least from a developers point of view. Now the real question is, can they get the devices with the right form factors to really complete with the big boys, MS, Symbian, and now Apple.

With HTC behind them, there is no reason why they can't. So why does a tech skeptic like me like this FOB (Fresh off the boat) platform so much. Well here's why

  • SDK for OS X, Linux & Windows (Take note Apple!)
  • It uses Java as the language of choice.
  • Each app runs in VM, they borrowed an idea from palm os(kinda)
  • They provided a C Api
  • XML GUI layouts, nice and open
  • The Platform is wide open
If you wanna look at this from a web 2.0 mashup point of view, its like the following

Microsoft's level developer support + Googles Open-ness + Apples inovation

Alternatively Lets compare it to it's rivals

Symbian - 'Modern' widely supported Language (Java vs C++).
Microsoft - It doesn't look like it was retrofitted to be used in a phone
Palm - Multiple device makers, means better form factors + it's a brand new os
Apple - It's not a Objective-C only world, and locked down like a [insert word of choice]
Others - It's got traction, and the developer community behind it, we all love google.

I'm getting to work on developing some apps for this platform. As i said it's got my support, it's solid under the hood, and i look forward to queuing for my first device. 

BTW i hate the iphone if anyone is wondering.


Quote of the Day
Red Light District

Some are more hungry than others...

Tuesday, November 06, 2007

Quick and Dirty Leopard Dock Image replacement script

This one is for all the dock hackers out there. I'm gonna try and roll this into a application during my lectures today ^_^

Cut and paste the script into a text editor of your choice, and save it as "dockSwitcher.sh"

To use this save your new dock images on the desktop and then run the script. Beware i haven't tested as i A. Use the non-glass dock, and B. didn't have time. So use with caution.


#!/bin/bash
## Quick and dirty Dock Image Replacement script
## Jonathan Dalrymple
## November 6, 2007

##Root Checking
## Thanks to
## http://blog.mecworks.com/articles/2006/02/23/bash-scripting-tip-running-a-script-as-root/
CMDLN_ARGS="$@" # Command line arguments for this script
export CMDLN_ARGS

# Run this script as root if not already.
chk_root () {

if [ ! $( id -u ) -eq 0 ]; then
echo "Please enter root's password."
exec su -c "${0} ${CMDLN_ARGS}" # Call this prog as root
exit ${?} # sice we're 'execing' above, we wont reach this exit
# unless something goes wrong.
fi

}

# Check if user is root
chk_root

##Back up dock
cp /System/Library/CoreServices/Dock.app ~/Dock.backup.app

##Remove the old files
rm /System/Library/CoreServices/Dock.app/Contents/Resources/scurve-l.png

rm /System/Library/CoreServices/Dock.app/Contents/Resources/scurve-m.png

rm /System/Library/CoreServices/Dock.app/Contents/Resources/scurve-sm.png

rm /System/Library/CoreServices/Dock.app/Contents/Resources/scurve-xl.png

##Put in the new files
mv ~/Desktop/scurve-l.png /System/Library/CoreServices/Dock.app/Contents/Resources/

mv ~/Desktop/scurve-m.png /System/Library/CoreServices/Dock.app/Contents/Resources/

mv ~/Desktop/scurve-sm.png /System/Library/CoreServices/Dock.app/Contents/Resources/

mv ~/Desktop/scurve-xl.png /System/Library/CoreServices/Dock.app/Contents/Resources/

##Remove dock images from desktop
rm ~/Desktop/scurve-l.png

rm ~/Desktop/scurve-m.png

rm ~/Desktop/scurve-sm.png

rm ~/Desktop/scurve-xl.png

##
killall Dock


Monday, November 05, 2007

Leopard Hacking : Front Row

Thanks to my coffee, i can't seem to sleep. So to pass the time i decided to do some more work on a new brain wave i just had this evening.

It centers around front row. Well actually it had nothing to do with front row, however building on top of front row makes more sense, than starting out from scratch.

Now as you may or may not know, like most of the cool gui stuff on osx front row is a closed environment. Which means it's hacking time. Something i always wanted to play with is a decompiler. Now i'm no Dmitry Grinberg, so assembly doesn't wash with me. Instead i found this little gem.

After a a brief compile it gave me this wonderful output



struct _NSZone;

/*
* File: Movies
* Arch: Intel 80x86 (i386)
*/

@protocol BRMenuListItemProvider
- (long)itemCount;
- (float)heightForRow:(long)fp8;
- (BOOL)rowSelectable:(long)fp8;
- (id)titleForRow:(long)fp8;
- (id)itemForRow:(long)fp8;
@end

@protocol NSObject
- (BOOL)isEqual:(id)fp8;
- (unsigned int)hash;
- (Class)superclass;
- (Class)class;
- (id)self;
- (struct _NSZone *)zone;
- (id)performSelector:(SEL)fp8;
- (id)performSelector:(SEL)fp8 withObject:(id)fp12;
- (id)performSelector:(SEL)fp8 withObject:(id)fp12 withObject:(id)fp16;
- (BOOL)isProxy;
- (BOOL)isKindOfClass:(Class)fp8;
- (BOOL)isMemberOfClass:(Class)fp8;
- (BOOL)conformsToProtocol:(id)fp8;
- (BOOL)respondsToSelector:(SEL)fp8;
- (id)retain;
- (oneway void)release;
- (id)autorelease;
- (unsigned int)retainCount;
- (id)description;
@end

@interface RUIMoviesAppliance : BRAppliance
{
}

+ (id)moduleKey;
- (id)init;
- (void)dealloc;
- (id)moduleIconName;
- (float)moduleIconReflectionOffset;
- (id)moduleName;
- (id)moduleKey;
- (id)applianceController;

@end

@interface RUIMoviesApplianceController : BRMediaMenuController
{
NSArray *_headerRows;
NSMutableArray *_titlesWithUnplayedContent;
RUIMovieFolderCollection *_movieFolderCollection;
BRMovieTrailersProvider *_trailersProvider;
unsigned int _hasLocalMovies:1;
unsigned int _movieTrailersPreviewRequested:1;
unsigned int _movieTrailersSelected:1;
BRDataStore *_dataStore;
Class _msClass;
}

- (id)init;
- (void)dealloc;
- (id)musicStoreBaseType;
- (BOOL)menuDisplaysLeftIcon;
- (void)networkStatusChanged:(id)fp8;
- (BOOL)isVolatile;
- (id)loadModelData;
- (void)refreshControllerForModelUpdate;
- (BOOL)shouldRefreshForUpdateToObject:(id)fp8;
- (long)defaultIndex;
- (void)itemSelected:(long)fp8;
- (void)wasExhumedByPoppingController:(id)fp8;
- (void)wasPushed;
- (void)willBePopped;
- (void)wasPopped;
- (id)previewControlForItem:(long)fp8;
- (BOOL)brEventAction:(id)fp8;

@end

@interface RUIMoviesApplianceController (AsyncNotifications)
- (void)_movieTrailersLoaded:(id)fp8;
- (void)_swapNewController:(id)fp8;
@end

@interface RUIMoviesApplianceController (DataSourceAccess)
- (id)_movieTrailers:(id *)fp8;
@end

@interface RUIMoviesApplianceController (MediaParadeBuilders)
- (id)_moviesFolderParade;
- (id)_movieTrailersParade;
- (id)_stingrayMediaPreview;
@end

@interface RUIMoviesApplianceController (MovieLoading)
- (void)_cacheUnplayedTitles;
- (BOOL)_hasUnplayedMovies;
@end

@interface RUIMoviesApplianceController (MovieSelection)
- (id)_movieSelectedAtIndex:(long)fp8;
@end

@interface RUIMoviesApplianceController (MenuBuilding)
- (id)_buildMovieTrailersMenu;
- (id)_movieTrailersController:(id)fp8;
- (id)_buildMyMoviesMenu;
- (id)_stingrayFrontPageController;
- (id)_headerRows;
@end

@interface RUIMoviesApplianceController (DataProviders)
- (id)itemForRow:(long)fp8;
- (long)itemCount;
- (id)titleForRow:(long)fp8;
- (float)heightForRow:(long)fp8;
- (BOOL)rowSelectable:(long)fp8;
@end

@interface RUISDMovieTrailersController : RUIMovieTrailersController
{
}

- (id)initWithTrailers:(id)fp8;
- (id)previewControlForItem:(long)fp8;
- (id)titleForRow:(long)fp8;
- (long)defaultIndex;
- (id)itemForRow:(long)fp8;
- (long)itemCount;
- (void)itemSelected:(long)fp8;

@end

@interface RUIMovieTrailersController : BRMediaMenuController
{
NSArray *_trailers;
}

- (id)initWithTrailers:(id)fp8;
- (void)dealloc;
- (BOOL)isNetworkDependent;
- (void)itemSelected:(long)fp8;
- (long)itemCount;
- (id)itemForRow:(long)fp8;
- (id)titleForRow:(long)fp8;
- (float)heightForRow:(long)fp8;
- (BOOL)rowSelectable:(long)fp8;
- (id)previewControlForItem:(long)fp8;

@end

@interface RUISDMovieTrailersController (Private)
- (id)_HDMovieTrailers:(id *)fp8;
@end

@interface RUIMovieTrailersController (Private)
- (id)_movieTrailersTitle;
@end

@interface RUIMovieDirectoryController : BRMediaMenuController
{
RUIMovieFolderCollection *_collection;
NSString *_path;
}

- (id)initWithMovieFolderCollection:(id)fp8;
- (void)dealloc;
- (id)moviesForParade;
- (void)itemSelected:(long)fp8;
- (id)previewControlForItem:(long)fp8;
- (id)mediaPreviewMissingMediaType;
- (BOOL)mediaPreviewShouldShowMetadata;
- (BOOL)mediaPreviewShouldShowMetadataImmediately;
- (long)itemCount;
- (id)itemForRow:(long)fp8;
- (id)titleForRow:(long)fp8;
- (float)heightForRow:(long)fp8;
- (BOOL)rowSelectable:(long)fp8;

@end

@interface RUIMovieFolderAsset : BRBaseMediaAsset
{
NSString *_displayName;
NSURL *_mediaURL;
NSString *_folderPath;
BRImage *_posterImage;
BOOL _requestedImage;
}

+ (id)assetForName:(id)fp8 folderPath:(id)fp12 andMediaURL:(id)fp16;
- (void)dealloc;
- (void)setDisplayName:(id)fp8;
- (void)setMediaURL:(id)fp8;
- (void)setMovieFolderPath:(id)fp8;
- (id)assetID;
- (id)title;
- (id)mediaURL;
- (BOOL)hasCoverArt;
- (id)coverArt;
- (id)dateAcquired;
- (id)mediaType;

@end

@interface RUIMovieFolderAsset (ArtLoading)
- (void)_loadImage:(id)fp8;
- (void)_imageLoaded:(id)fp8;
@end

@interface RUIMovieFolderCollection : BRBaseMediaCollection
{
RUIMovieFolderCollection *_parent;
NSString *_displayName;
NSString *_folderPath;
NSArray *_childCollections;
NSArray *_childAssets;
}

+ (id)collectionForName:(id)fp8 folderPath:(id)fp12 andParent:(id)fp16;
- (void)dealloc;
- (void)setParent:(id)fp8;
- (void)setDisplayName:(id)fp8;
- (void)setMovieFolderPath:(id)fp8;
- (id)childCollections;
- (id)parentCollection;
- (id)collectionType;
- (id)collectionID;
- (int)count;
- (id)mediaAssets;
- (id)title;
- (id)titleForSorting;
- (BOOL)hasCoverArt;
- (id)coverArt;
- (BOOL)isLocal;

@end

@interface RUIMovieFolderCollection (Private)
- (void)_generateCollectionChildren;
@end

@interface BRMediaCollectionType (FolderCollectionExtension)
+ (id)folderCollection;
@end

What you see here is the headers/interface & protocol files for all the different classes located within Front rows movies appliance.

If you want to see your own front row app, it's located @ /system/library/coreservices/front row.app

Now i had heard that some good folks over at Awkward TV forums have hacked appliances for the Apple TV which is basically what the new front row on leopard is, however these don't seem to work 'out of the box', and apparently Apple updated this version before the roll out.

Coupled with all the above, i have reason to believe that the new appliances are digitally signed by [chinese] ni cai, Apple.

By reasoning for this, is a did a hex dump (using 0xED) of the appliance executables, and found the following string(s) @ 135535

"Apple Certification Authority1301U*Apple Code Signing Certification Authority"

Now just after typing the above sentence, it dawned on me that this might be for the transactions with the ITMS, for movie trailers, however i checked the settings appliance and found the same thing.

Also i tried deleting the various applications from a running front row, and it handles them gracefully, and also doesn't mind having new ones dropped in. I tried droping in the rss apple tv plugin, however it didn't like it very much.

I'm a programmer, not a hacker so this is about the limit of my skill, especially if it envolves digitally signed apps. I can barely deal with the symbian signed apps, never mind about these ones. If got some ideas or feel like getting dirty and dodging some DMCA takedown notices let me know.

UPDATE

i found this URL above the previous string, http://www.apple.com/appleca/

turns out that the certificate may be freely available, which might make life a tad bit easier.

PS. to any one wanting to warn me for breaking the law, i'm not a US resident ^_^

Wednesday, October 31, 2007

Mobile Web development

In recent months I've seriously considered getting into mobile application development. My platform of choice has been symbian thus far. However yesterday something dawned on me. Most people don't understand that modern phones are miniature computers hiding in pink cases. As such the idea of additional applications is moot. However what everyone is now seeing is that the internet on mobile devices is possible. In this crazy online world of ours that means one thing web 2.0!

So from today, i'm gonna put some fuel into creating mobile web 2.0 applications. I have a vague idea of where i'm going, but only time will tell.

In other news, this is my 250th post, meh.

I'm slowly becoming myself again, best reflected by the fact that i have time to write this monologue!

Plus i got the 24" in the end, Benq fp241. ....

Well until another time




Quote of the Day

Caption

Tuesday, August 07, 2007

Database Table Size Calculations

As a professional Developer, every once in a while you'll need to create a Database, for one reason or another. It's always nice to apply structured thought to your design process and work out your proposed database size before who release it upon the unsuspecting database server.

It's kinda obvious to do, but just in case heres how i do it.

First create your data dictionary. In my case it was for a questionnaire management system, (QMS, might release it as OSS when i'm done).

i wanted to dynamically generate a new table for each questionnaire, so i need to work out the system limits before hand.

first we would have our "user id's"

id - UInt
hostName - 128 byte (unicode 64 character string)
ip addr = 15 bytes (it's ip v6)
assocQuestionnaire = 4 bytes aka 32bit unsigned integer

then depending on the questionnaire you could have upto 32 questions/ comment, (32 columns). These could then store upto 1024 characters so thats basically double in UTF-8, so 2048 bytes, bringing in each row at almost 65Kb, now the company i work for has 40 000 members of staff, so lets assume they all anwser the same questionnaire (Great advertising for me), the database would swell to 2.5 Gb!

Well i think thats sight over kill, so by tweaking the the system to only implement the larger fields when requested by a user, and assuming that they only want one comment field per questionnaire, we get a much more wholesome figure of 100 Mb.

So to summerize the formula is

sum( column types ) * num of rows.

Remember this is only an estimate, and doesn't account for the master tables or relationships or any of that other RDMS goodness. So it's a guide not, E=MC2

Jonathan

Saturday, August 04, 2007

Display Madness

For once i have a little time, which makes a huge change. In the last hour or so i've been exploring my options around getting a new display to help support my Mac lovin life style. However what should be a joy filled ride through the online e-commerce world, is turning out to be a little less simple then i had imagined.

I have a budget of around £600.
My current setup is two 19" @ 2560 * 1024

However there is a major problem with my current setup, My Blackbook only supports one display. However with a little box from matrox it can support two, but at a maximum resolution of 1024 * 768 each or 2048 * 768.

Current i share the setup with my nix box, but that is getting axed (Yes blu-ray is dead/dying) in favor of consolidating all my development onto one physical machine, and running nix, solaris, windows via parallels.

Now normally i would the following choices given the price.

2 x 22" displays (3360 * 1050)
1 x 24" display ( 1920 * 1200)
1 x 27"
1 x 26"
Now two 22's would be nice, not only cause because it's big but it's also a Jay-z song(well in reverse)!

Now based on current machine specs i've actually got three choices
1 x 24" display ( 1920 * 1200)
1 x 27"
1 x 26"

These are all below my current resolution, so maybe it's the machine that needs changing ...

Ok, lets do the math

Macbook pro (legit) £1149 with student discount
2 22" displays £ 500
matrox dual head to go £140

total £1700!

sweet price point, not. What makes it worse, is that i love the macbook's form factor and would hate anything bigger. ie MB pro.

Plus for that price i could get a mac pro which i have often considered and drooled over with phil. (the computer not phil).

The other solution is to build a osx86 machine, however as developer, and with Leopard coming doing all my work on a unsupported, illegal, in-frequently updated, hacked platform strikes me as dumb.

So that leaves the single units

All of which mean i lose about 1/2 million pixels, and a couple of inches.

Heres the price breakdown
24" £430
26" £ 500
27" £ 680

So on price the 24" is a winner models in that range, that have 8bit color panels, good response times, and adjustable stands, and multiple inputs are ...
Dell's 2407wfp
Benq's 241 wp ( HDMI included!)

On the 26"'s there is one that i know of
Acer 2604
It's got a crapy stand, and no Digital inputs, infact it's only got a VGA input

And then there is 27's

Dell 2707wfp

Which is basically the 24" dell with a phat-er panel and no rotation. And a pixel pitch closer to a 19" lcd (0.294 vs 0.3)

Now we consider the pros and cons of the 24 vs 27

1. I have personal issues with spending seven bills on a lcd display, that i don't really need while people starve to death, and go to war over food.
2. The pixel pitch of the 27 is ideal, the high pixel pitch of my 19's is why i sprang for them over the 17"'s.
3. No rotation, how do i show off those cool XGL effects without being able to rotate the display as well!
4. Both give me less working resolution then i have currently.

Conclusion...

I'll wait to see if apple brings out a super notebook next week, that razor thin macbook pro that all mac geeks dream about, and if it's what i want i'll upgrade.

BTW

i recently bought my name (www.jonathandalrymple.com) as well as a couple of domain names for some projects that are in the pipeline.

Thursday, July 19, 2007

CSS research

I'm completely knackered, but research is my life. One of my many clients wanted a semi transparent div. Now i say div, but they just want it to look shiny.

Basically then want an element with appox 20% opacity. Easy right, use a PNG. But that cancels out all ie versions apart from 7. How about a gif instead, you dont get alpha transparency! Well genius how about css, great, there are ways to do it on webkit, gecko, and ie, however they apply the same amount of transparency to their children.

the trick here is to think outside the box, literary...



Thanks to relative positioning, i made a solid div below my transparent div, and moved it over the transparent div, creating a the above effect. The cool things is that by modifing the z-index you can create a ghosting effect!

Best of all, there are no images used to create the above, (well apart form the obvious background pattern on the body), more testing is needed, but i think i might be on to something here.

The CSS
*{
text-align:center;
margin:0;
padding:0;
}
body{
background: url("pattern.gif");
}
div#wrapper{
margin:0 auto;
width:70%;
text-align:center;


padding:1em;
}
div#panel{
opacity: .50;
height:200px;
background: #ddd;
width:100%;
margin:0 auto;
}
div#wrapper p{
padding:1em;
background: #000;
color:#fff;
width:90%;
position:relative;
margin:0 auto;
top:-180px;
z-index:1;
}

The html


Transparent div

content goes here






Now if you excuse me, i'm off to bed

Introducing Absolution

Yes i'm alive, it may have been months since the grand plans of facebook widgets and such, but i'm back. Today i'm unleashing on the world something new(ish), A PHP framework. Now don't get me wrong it's no piece of cake, but it's not meant to be. Absolution place in the world is on shared hosts, and B grade websites, where speed of development is more important than MVC patterns and OO principles.

Well OO is always good but you know what i mean.

Currently it consists of 4 classes, that contain helper functions, that enable you to do things like print an un ordered list from a sql query in one line of code!, get a pre-sanitized variable from the query string with one line, even filter out bad characters with one line.

I plan to add more classes, and more functionality, as the framework grows up, however it's 0.01 alpha at the minute! Eventually i want this to grow into something like prototype for PHP, a lean, mean framework machine.

Also i think this place could do with a redesign, ajaxian styleee, now if only i had time.


Till another time

Quote of the Day
"We knew that when we gave it to him, that it was never gonna end up as just a simple webpage!"

My love of Jquery is starting to give me a reputation

Sunday, June 03, 2007

Reverse Engineering: Facebook poking

Since i declared Poking war on all my facebook friends, i've been thinking of doing some R & D. So i'm developing a Greasemonkey Script that would enable me to reply to all the pokes simultaneously.

Well thus far, heres what i've discovered.

A poking request is made by sending the user id of the person you wish to poke to a php page.

http://(networkName).facebook.com/ajax/poke.php?id=(userID)

with this request, goes a cookie with your login credentials.


Host: solent.facebook.com

User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.1) Gecko/20061223 Firefox/2.0.0.1

Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5

Accept-Language: en-us,en;q=0.5

Accept-Encoding: gzip,deflate

Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7

Keep-Alive: 300

Proxy-Connection: keep-alive

Content-Type: application/x-www-form-urlencoded

Referer: http://solent.facebook.com/profile.php?id=511999790

Content-Length: 70

Cookie: login=[Login credentials etc. Need to workout the encoding on these]

Pragma: no-cache

Cache-Control: no-cache

As you can see i did this on my mac, using Firefox to take advantage of firebug. If you drop in the refer url it will take you that persons profile page, i imagine that this is also checked to stop spam bots, however i plan to fake the refers in the application, so that shouldn't be a problem.

Therefore in essence to automate the process, all you need to do is create an array of the users that you wish to poke, and loop though them sending your credentials each time to ensure that it is accepted by the server.

While i was poking around i also discovered that FB uses a modified version of Apache 1.3.37 (they suffix it with "fb1"). Whether this is an edit to the string, or actual modification, who knows?

Anyways, when i stop working 7 days a week, or going to bed at 2:15 am, i'll but together a small java app to take advantage of this.

Now if you think this is a lot of work, it isn't really, i got a http request class already built and fully functioning thanks to my work on isolation. So just gotta reverse engineer some more, and apply this concept.

Let the poking war continue!


Quote of the Day

Caption

Monday, May 28, 2007

Because i have time

Remember that facebook widget i spoke of?

Well it's actually in the oven, now and should be ready soon-ish, just have to work out how to communicate with the REST API that facebook uses, and i'm quids in.

Heres a screenshot of it running live in safari, and i built it based on a dashcode generate file, rather than actually using dashcode. Always more fun getting your hands dirty.

Saturday, May 26, 2007

2006/ 2007; A year in review.

Alas the academic year is at an end, so i thought i would look over my highlights for the year. Fortunately, for once there weren't too many down-ers, which makes a change. In the last year, i've "grown" as a person, changed a lot socially. One thing i've developed is an extremely are head, the sheer number of compliments i've started getting, is messing with my head, resulting in a chemical reaction, often known as "Big head syndrome".

So what did i like about this year?
  • Facebook!!!!
  • Jaimini
  • Cooking
  • Chasing Women * (Not as bad as it sounds, honest)
  • Strictly Exclusive
  • Ocean & Collins
  • Nokia E61
  • OS X
  • Java
  • Black Macbook
  • My Poster (you know the one ;) )
  • Chocolate Bourbons
  • Group Dinners
  • Tunde (Even if he's a waster)
  • Jai & Nick's Co*K Blocking
  • Eating Popcorn for dinner
  • Plagiarism ( I'm innocent )
  • Easter ;)
  • Luke, OG
  • Stupid Flat Games
  • PHP
  • Linux
  • Comic Life
  • Steph B.
  • That Monday at OC, well both actually.
  • A night in Portsmouth
  • Working with Schuster
  • Getting my Old Job, back on both counts
  • Stupid sleeping habits
  • Erykah Badu
  • Robin Thicke
  • Mos Def
  • Dave Chappelle ;)
  • My nickname, Lawman
What do i want to improve on for next year & beyond?
  • Chasing Women (what, they're first years, they need help...)
  • My Personal Cleanliness, mainly my room
  • Number of publicly available software projects (One is a joke for a software developer)
  • My relationship with God (not the best at the moment)
  • Income (could be better considering my skills)
  • Grades (Too much coasting!)
  • Language skills, 10 isn't enough, i need more
  • Language, ones that other people know, like spanish etc
  • general knowledge, i'm getting dumb
  • Electronics , don't get it twisted with software
  • act my age, yeah i'm 20 not 30 during the day and 14 at night.
  • Stop speaking like a LDN kid
  • Remove in'it from my vocabulary
  • Improve the jokes, (long time coming)
  • Start sleeping at normal times
Favourite moment of the year
  • Coming back to uni after dropping out, or geting my macbook
Biggest Waste of time
  • Pro Evo Tournaments at the SU
  • A Certain individual(s)
Most Rewarding use of time
  • Cooking Dinner for 6 of my friends and watching them devour it with gee
Most constructive use of time
  • Building Downtime in my first week back
Biggest waste of cash/p
  • That Remote control plane
Most shocking news
  • One of my best friends coming out
Favourite Quotes (aka Tunde's section)
  • "It's all, real stainless steel" Tunde
  • "TASTE!!" Tunde
  • "Fail" Anwar/ UMZ!!
  • "Mrs. Lawman" Jai, Nick, Lester and whoever else was there
  • "Lebanon is in africa" Tunde
  • "I sleep on my stomach, with both arms under me, with my hands between my legs" Jaimini
  • "I'm in the same place(diva) every week" Steph
  • "Wasteman"
Well i'm pretty tired now, so i'm gonna call it a day. But i must say, sitting here writing this list had be cracking up, and smiling the whole way. It's been a great year and to all my people, thanks for the good times, and God Willing we will have so many more next year.

Jonathan "Lawman" Dalrymple