David Thomas Baker » Web

jquery load stylesheet into frame

For when I forget next time:

<iframe name="framename" id="framename" src="something.html"></iframe>
$('body',framename.document).append('<link rel="stylesheet" href="http://mysite.com/stylesheet.css" />');

or use this awesome jquery plugin:

http://ideamill.synaptrixgroup.com/?p=6

it allows you to easily run code and load css/javascript into iframes

 

Posted by David Baker in: Web | Tags:
Some ads...

Australia Post API for Shopping Carts

Australia post provides an API here:

http://drc.edeliver.com.au/

You need to post the following values to http://drc.edeliver.com.au/ratecalc.asp

  • pickup & destination post code
  • country (AU)
  • weight
  • service type (standard, express, etc..)
  • length
  • width
  • height
  • quantity
More details on their website

Aus post calculates the weight of a package by either the cubic weight or actual weight, whichever is greater.

For example: if you have a 2kg package with these dimensions: 80cm(length)  x  20cm(height)  x  30cm(width) then the actual weight you will be charged for is:

Step 1: work out cubic meters: 0.80 x 0.20 x 0.30 = 0.048
Step 2: work out cubic weight: 0.048  x  250  =  12kg

That means, your 3kg package that is 80x20x30 you will actually be charged for a parcel that weighs 12kg!

Currently working on a prestashop australia post calculator module, I will post it here and on prestashop forums when it is complete.

Posted by David Baker in: Web | Tags:

Free Remote Desktop Support

Here's a free way to get basic single click remote desktop support for your customers.... Continue Reading »
Posted by David Baker in: Web | Tags:

Installing SVN & Trac on a Plesk host

Process I followed to install subversion and make it available via mod dav svn on a plesk host. Continue Reading »
Posted by David Baker in: Web | Tags:

How to setup simple Google Maps on your website

Here's a quick howto on setting up Google Maps on your website.

Ideal for "Contact Us" pages.

Continue Reading »
Posted by David Baker in: Web | Tags: google |

Oracle and Toad - tnsnames.ora example

Getting Toad to work with Oracle doesn't seem to be explained very well anywhere.

Here's a quick list:

  1. Download and Install TOAD from http://www.toadsoft.com/toad_oracle.htm
  2. Download and Install the Oracle XE Client from http://www.oracle.com/technology/software/products/database/xe/htdocs/102xewinsoft.html
  3. If you launch toad now, you should see XE as an option for connecting to Oracle
  4. Create a tnsnames.ora file in C:/Program Files/Quest Software/Toad for Oracle FREEWARE/

Here is an example of a tnsnames.ora file for Toad

 IDENTIFIER =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.0.123)(PORT = 1521))
)
(CONNECT_DATA = (SID = orcl))
)

Once this file is there you can re-open Toad and use "IDENTIFIER" as the connection identifier (drop down list). Toad will then know that it has to connect to the oracle server at 192.168.0.123 on port 1521

Posted by David Baker in: Web | Tags:

Multiple tinyMCE editors with a single menu - tinyMCE iframe example

Here's an example showing multiple tinyMCE editable regions been controlled from (what appears to be) a single tinyMCE menu.

This is also a good example of how to use tinyMCE with an iframe

http://examples.dtbaker.com.au/code/tinymce/

see the forum post here:

http://tinymce.moxiecode.com/punbb/viewtopic.php?pid=32411

Posted by David Baker in: Web | Tags: jquery | tinymce |

search.live.com/results.aspx referral spamming

im getting lots of these across a whole bunch of apache log files:

Referrer: http://search.live.com/results.aspx?q=keyword&mrt=en-us&FORM=LIVSOP
IP Address: 65.55.165.88
User Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2; .NET CLR 1.1.4322)

After some googling it seems this is part of some live.com's search engine quality checking blah blah

I have heard the bot downloads javascript and css files as well... who knows what this could be doing to things like adwords or google analytics.

So I just blocked them:

if(preg_match('/^65.55.165/',$_SERVER['REMOTE_ADDR'])){
header("Location: http://microsoft.com");
exit;
}
Posted by David Baker in: Web | Tags: microsoftsucks |

Drupal - "Access Denied" user accounts orders

After a host did a PHP upgrade drupal decided not to remember sessions very well any more. I'm still not sure what the exact problem was but this is what fixed it... Continue Reading »
Posted by David Baker in: Web | Tags: drupal |

Catching and Preventing echo md5("just_a_test"); exploit attempts

Have been noticing LOTS of automated explot attempts recently... Continue Reading »
Posted by David Baker in: Web | Tags:

Submit a form into a popup

Sometimes it is useful to subimt a form into a popup window, here's a few ways to do it:

Continue Reading »
Posted by David Baker in: Web | Tags:

Facebook Footer - Non-Trimmed ?

The Facebooks footer:

is made up of the following parts:

<div class="copyright">
<span title="Non-Trimmed">Facebook </span>
<span title="75">&copy;</span>
<span title="10.16.93.101">20</span>
<span title="19269744">08</span>
</div>

Hover your mouse over the Facebook footer in a browser to see the title text appear.

What do these numbers mean I wonder...

the IP Address - the backend server handling the request?
the last number - the time it took to generate the page?

Posted by David Baker in: Web | Tags: facebook |

TinyMCE customise Styles/Classes dropdown

Pretty easy, just do:

tinyMCE.init({
theme: "advanced",
//etc....
theme_advanced_styles: "className=Class Name;imgclass=Images",
//etc....
});

and your custom styles will be available in all popups etc..

Posted by David Baker in: Web | Tags: tinymce |

Website Screenshot Thumbnail Creator Script

One day I needed to create thumbnails of about 300 websites, this would usually take a very long time, so I wacked together a simple shell script which makes use of Firefox, Xvfb, and Imagemagick

The script creates a virtual X desktop, starts a Firefox instance, and then, using the openUrl command, proceeds to load each website and capture a screenshot one at a time.

If you cannot get Xvfb working, you should be able to run this with little modification on a spare linux desktop. I suggest you play with image magicks cropping tools to remove the firefox decal.

here is the original bash script: Continue Reading »
Posted by David Baker in: Linux | Web | Tags:

TrackMouse - Using Javascript to track mouse movem

Here's a little script I wrote ages ago that could collect users mouse movements and clicks on a site, save to a database, and generate an image showing a "click stream" of the users activity.

:

Posted by David Baker in: JavaScript | Web | Tags:

Creating a Firefox extension

coming soon
Posted by David Baker in: Web | Tags: firefox |

How does Flock access Facebook/Flickr friend list

When you sign into Facebook or Flickr whilst using Flock you will have access to a list of your friends via the People Bar.

Flock does this by calling the Facebook / Flicr API's

Here is an example request as seen in a wireshark dump:

GET /restserver.php?query=SELECT uid,name,pic_square,status,profile_update_time 
FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = 123456789)&
api_key=123456&session_key=12345&call_id=12345&method=facebook.fql.query&
format=JSON&v=1.0&sig=12345
HTTP/1.1
Host: api.facebook.com

(flock facebook code: http://svn-mirror.flock.com/trac/flock/browser/trunk/mozilla/flock/base/services/ )

Flickr is accessed a similar way, via their rest interface - eg:

GET /services/rest/?method=blah.blah 
Host: www.flickr.com
Posted by David Baker in: Web | Tags: flock |

RealEstate.com.au Scraper

Wrote this when hunting for a house.

Pretty much a scraper for realestate.com.au, displaying search results in a much more user friendly and advertisement free way. Also includes a couple more options than what is available in the usual realestate search form.

And also the ability to quickly categorise and remove results from appearing again.

http://examples.dtbaker.com.au/code/realestate/s.php

Will publish the code after a little clean up.

Posted by David Baker in: Web | Tags: scraper |

Commonwealth NetBank Login + Scraper

Ran this on my home PC while overseas to transfer money between accounts / credit cards.

Could hit it up with an email like: Transfer $100 to Account B and away it goes.

Much more secure and faster than typing in my netbank login details in some foreign internet cafe (especially when the keyboard is in another language)

Will open source the code once I clean it up a little.

Posted by David Baker in: Ideas | Web | Tags: scraper |

Virgin Credit Card Login Class

Virgin doesn't email statements out, you have to log in to check balances etc..

Logging in via their interface sucks balls, so I wrote this to do it automatically.

Will publish after a little clean up.

Posted by David Baker in: Ideas | Web | Tags: scraper |

CommSec Share Watch Exporter + Scraper

Some friends of mine recently became a little bit obsessed with the share market, recording share prices in a little book through out the day.

This will automatically log in an export your CommSec watch list and save it to a database. Much easier than scribbling down share prices in a book 20 times a day.

Could also set it up to automatically buy/sell when stock reaches a certain price. A feature that doesn't exist in CommSec at the moment.

(Will publish after a clean up)

Posted by David Baker in: Ideas | Web | Tags: scraper |

How to access Experts Exchange posts for free

Whenever trying to Google for help on error messages I usually get an experts-exchange.com result or 3 on the first page.

Problem is you need to become a "Premium Service Members" in order to view the responses.

bah!

Lucky for us, experts exchange does a little bit of dodgey search engine stuff =)

Instead of clicking the link taking you directly to experts exchange, simply click the "Cached" link. You will notice the cached version of experts exchange is very different. Scroll down past the huge block of links and presto, there's the posts.

No need to become a premium member.

 

Posted by David Baker in: Web | Tags:

NetRegistry Hosting - Only Zeus or IIS!

It looks like NetRegistry only has Zeus and IIS hosting accounts.

So any apache thingeys like mod_rewrite wont work.

Also you will need to set you own custom PHP temporary session directory to get PHP sessions working correctly.

Posted by David Baker in: Web | Tags:

Update page while PHP script executes

If you have a script that runs for a long time and you would like to update the browser with some progress reports here is a very simple way of doing it:

script.php:

<html>
<body>
<div id="messages"></div>
</body>
<?php
function w($message){
?> <script language="javascript">
document.getElementById('messages').innerHTML =
document.getElementById('messages').innerHTML + "<?=$message;?>";
</script> <?php
@ob_flush(); @flush();
}
//example:
w("Here is a message");
sleep(5);
w("And another message");
sleep(5);
w("And yet another message");
?>
</html>

 

View an example here: click

Posted by David Baker in: PHP | Web | Tags:

Apache mod_rewrite - Melbourne IT - PHP-CGI

Ran into a problem trying to use mod_rewrite in .htaccess on a Melbourne IT hosting account.

They seem to run PHP as CGI instead of an Apache module. Read the differences here: http://blog.dreamhosters.com/kbase/index.cgi?area=2933

Here's the rewrite script that worked in the end:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php [L,QSA]

The problem was a missing / before the index.php

Posted by David Baker in: PHP | Linux | Web | Tags: apache | mod_rewrite |

Apache2 Sub Domains

Sub domains in Apache... Continue Reading »
Posted by David Baker in: Linux | Web | Tags: apache2 |

jQuery - Duplicate Select Boxes

jQuery - Duplicate Select Boxes

Ever wanted a allow the user to add or remove select boxes (or any other form elements for that matter) .. here's how...

Continue Reading »
Posted by David Baker in: Web | Tags: javascript | jquery | ui |

Introduction to JSON

coming soon
Posted by David Baker in: JavaScript | Web | Tags:

PHP5 and JSON

coming soon
Posted by David Baker in: PHP | JavaScript | Web | Tags:

Multilingual PHP5 with UTF8

coming soon
Posted by David Baker in: PHP | Web | Tags:

Search My Site

Featured Projects

Collector Comics is THE place to buy, sell, and research comics online. Launching soon.
Launch » Screenshot »
Webitor is a kick-ass easy to use, easy to extend, non-database driven Content Management System. Version 2 with reseller plan coming soon.
Launch » Version 1 »
GC Lounge is my own pet social network and test bed for social related code. Made by locals for locals.
Launch »
GG has indexed over half a million recent Trade Mark applications. This revolutionary tool is extremely valuable for industry experts.
Launch »
GCWiFi is the hub for techies interested in joining a ad-hoc wireless mesh spread across the Gold Coast
Launch »
Web based financial client management system
Launch »
OS Commerce modules and template modification
Launch »
View More Projects »

Daves Friends

BlueTeddy
WebSpark
GC Designer Forum
IPWealth Trademarks
Cheap Websites
Bonsai Shop
Webitor CMS Resellers
Hayley Crook
David Novakovic
Ben Novakovic
Richard Morwood
Gold Coast Linux
Aussie Click
CMS Website Design
Inspire Tuition
Gold Coast Music Network and Gold Coast Gig Guide

Chat with Dave

Powered by...

In the works

Webitor - Easy to use Content Management System with Shop, Newsletter, and Reseller plan