Web Design, 3d & More - Aaron Newton 

How To Make a Bookmarklet For Your Web Application | BetterExplained

How To Make a Bookmarklet For Your Web Application

Browser buttons (bookmarklets) are shortcuts that act like a simple browser plugin. Their advantages include:

  • Fast installation: Just add a link to your bookmarks
  • Convenient: Use features while on your current page
  • Easy to write: Bookmarklets are just like making a webpage; there’s no need to write a whole browser plugin
  • Cross-browser: The same bookmarklet can work in IE, Firefox, Opera and Safari.

Here’s a few bookmarklets I use regularly:

Anyone got any cool ideas for a bookmarklet they want me to build?

Posted by Aaron Newton 

Comments [0]

Fixing Missing Folders in my Subversion (SVN) Repository

Sounds almost dirty, doesn't it?

I've been working some more with the Wordpress PODs CMS plugin this week, and I'm really begining to appreciate just how good it is. I am now at the point where I'm having more difficulty customizing the Wordpress pages then theming my own PODs CCK.

Something unusual did happen to me though - folders went missing from my subversion project! 

I was transferring SVN dump files between machines, and the whole site collapsed. My Zend CE log told me this was becuase the PODs plugin was missing - what the hell?

Here's what went wrong.

I copied my PODs plugin from another Wordpress plugin that was part of a checked-out repository. This included the .svn files from the other project. The result? Subversion got confused and didn't include these files in the project. I have also noticed that if you move folders inside the same project that are under versioning (contain the .svn folder) you get the same problem.

It is a simple problem to address.

First of all, try using a GUI like Tortoise SVN. This tool provides a 'move here' function which understands and adjusts versioning (thank you Daniel for this pointer). If the folder is outside the project but under versioning, you can also use 'export' (again using Tortoise SVN) to move an unversioned copy of the folder to the desired location.

If you have already made this mistake, try deleting the .svn folder inside your versioned folder. This may give you errors about unversioned files. In this case, rename the folder, clear out any .svn folders inside, then commit. This will delete the old folder reference, and then create the new one. You would then rename the folder and commit again. If this doesn't work, you may have to run the cleanup script.

This last solution is pretty messy, but it will let you fix the problem quickly and get on with your work.

Posted by Aaron Newton 

Comments [0]

Debugging PHP $_POST arrays using var_dump for "PHP Notice: Undefined index:"

I forgot to set my name attributes in a form today (deeeeer!), and was scratching my head a bit when this error started coming up for all my form elements:

"PHP Notice:  Undefined index:"

This is an easy enough problem to fix. Depending on your DTD, adding name attibutes in addition to id attributes will make the form post the data correctly. Here is a bit of a test you can try for yourself.

<form action="send.php" method="POST" id="contactForm" enctype="multipart/form-data">

<fieldset>                           

<label for="Name">Your Name </label>

<input id="Name" type="text" />

 <input id="sendMail" type="submit" name="submit" />

</fieldset>

</form>

Here is your basic form. In the page 'post.php' we add the following:

<?php var_dump($_POST); ?>

If we then posted our form, we would get the "PHP Notice:  Undefined index:" error in our debugger, and you would get the following array from var_dump

array(1) { ["submit"]=> string(12) "Submit Query" }

Notice that the array has one key "submit". Some forums suggest using if(isset($_POST['submit'])) {} to solve this error, but obviously since this key exists this is not necessarily the best solution. Another solution would be to experiment with the form to see which attributes cause the input values to show up in the $_POST array. Modify your "Name" input element to include:

name="Name"

Post the form again and we get...

array(2) { ["Name"]=> string(5) "Aaron" ["submit"]=> string(12) "Submit Query" }

Ah! That's better. This time I can see my "Name" input value has been set to Aaron and successfully posted, which is what I want to happen.

This may seem like an overkill solution to this problem, but consider that var_dump may be useful to debug forms with a lot of post values; as an alternative to writing a whole heap of if statements to test which values are set in form post. Once we see that $_POST is an array/array like object (?) we can use the regular array syntax to get the post value, e.g. $_POST['Name']

I hope that made someone's day a little less frustrating ;)

 

P.S. Jayne said she'd bring me a cookie if I posted this duck -enjoy!

        ,----,
___.` `,
`=== D :
`'. .'
) ( ,
/ \_____________/|
/ |
| ;
| _____ /
| \ ______7 ,'
| \ ______7 /
\ `-,____7 ,' jgs
^~^~^~^`\ /~^~^~^~^
~^~^~^ `----------------' ~^~^~^
~^~^~^~^~^^~^~^~^~^~^~^~^~^~^~^~

Posted by Aaron Newton 

Comments [0]

Using body_class() in PODS CMS for Wordpress

 

I have been playing around with a CMS plugin for Wordpress called PODS. Here is a function for functions.php which might come in useful if you want to add POD page URL variables and page pod types to your body class:

 

 

function pods_body_class($classes)

{

    global $pods;

    if ( is_pod_page() )

    {

        $classes[] = "pod";

        if( is_object($pods) )

        {

            $classes[] = "pod-".$pods->datatype;

        }

 

        $classes[] = ' '.pods_url_variable(-2).' '.pods_url_variable('last');

    }

    return $classes;

}

 

add_filter('body_class','pods_body_class');

 

 

The body_class function is a useful built in Wordpress function that prints the page_id, blog post category etc. to the class names for the body element. It can be implemented like so:

<body <?php body_class(); ?>>

When implemented with the above code, this will return the last two URL variables, i.e. for the rewritten URL example/parent/child/. If the POD was 'cars' this would return body class names like this:

pod  parent child

If you assign corresponding class names to your sub-navigation elements (e.g. <ul class="parent">) you can then use CSS to highlight active menus like so:

.parent .parent { font-weight:bold };

Enjoy!

 

Posted by Aaron Newton 

Comments [0]

Vector Rabbit

I've been playing around with vectors a lot in Photoshop lately. Here is the before:

and after:

Posted by Aaron Newton 

Comments [0]

Prevent Client-Side iframe Hotlinking with Javascript

I thought frames went out of style a decade ago but apparently everyone feels the need to duplicate the Digg Bar. I don’t trust these framed services so I choose to use a javascript snippet that prevents my site from being in someone else’s frame.

The Javascript

if (top.location != self.location) {
	top.location = self.location;
}

This comes in very handy if you want to prevent people from hotlinking your content with iframes.

Posted by Aaron Newton 

Comments [0]

Adding a newline (i.e. 'carriage-return' or 'line-break') in MySQL statements

There was suprisingly little information on how to insert a newline character into a MySQL script. Here is what I found:

 

SET @newline=CHAR(10);

 

Set a user variable for the (unix) newline character. You can then use it like so:

 

select @newline;

 

(returns a newline)

 

select concat('something,', @newline, 'something', @newline, 'darkside...') as emperor_dialogue;

 

something,

something,

darkside...

 

Enjoy!

Posted by Aaron Newton 

Comments [0]

Making seamless texture tiles in Illustrator for use in Maya or Photoshop

There have been a couple of situations in the last few weeks where I have needed to generate a seamless texture for use on a 3d model or Photoshop composition. While this sounds like a simple task, it can actually be extremely frustrating to get it right unless you know the correct technique to begin with.

Here is a decent tutorial for generating resolution independent, seamless texture tiles in Illustrator for use in Maya or Photoshop:

http://www.bittbox.com/illustrator/how-to-make-a-perfect-seamless-vector-pattern

To get this into Maya, you will need to export the pattern out to a jpg file, which can be created directly from illustrator using the 'file' > 'save for web and devices' dialogue (N.B. I saw this under the assumption that you will be using Mental Ray for Maya, which seems to struggle with formats like PSD). Once you have created your Maya file texture node, you can tweak the 'UV Texture settings' under the attribute editor to change the scale of the texture tessellation.

Posted by Aaron Newton 

Comments [0]

Spring IDE plugin for Eclipse - correct download location

I have been having a lot of trouble today trying to find the Eclipse plugin for Spring. I eventually found it here:

http://springide.org/updatesite/

This URL should work with the Eclipse install/update GUI. Enjoy!

P.S. according to some forums you will need to uncheck the 'Spring IDE Dependencies' options for versions earlier than Eclipse 3.2.x.

Update:

You may get errors like the following:

 

Cannot complete the install because one or more required items could not be found.

  Software being installed: Spring IDE AJDT Integration (optional) 2.3.0.200912170948-RELEASE (org.springframework.ide.eclipse.ajdt.feature.feature.group 2.3.0.200912170948-RELEASE)

  Missing requirement: Spring IDE AOP Visualiser UI 2.3.0.200912170948-RELEASE (org.springframework.ide.eclipse.ajdt.ui.visualiser 2.3.0.200912170948-RELEASE) requires 'package org.eclipse.contribution.visualiser.core 0.0.0' but it could not be found

  Cannot satisfy dependency:

    From: Spring IDE AJDT Integration (optional) 2.3.0.200912170948-RELEASE (org.springframework.ide.eclipse.ajdt.feature.feature.group 2.3.0.200912170948-RELEASE)

 

 

To fix this, you need to add the Apache AspectJ tools for Eclipse. AspectJ is an Aspect Oriented Programming framework which is very popular, and can be used within Spring. If you check all of the options for the Spring download, you may want to download all of the AspectJ dependencies first. 

Under 'Help' > 'Install New Plugins' go to 'Add' and use http://download.eclipse.org/tools/ajdt/35/update as the download site (you may need to adjust for your version of Eclipse, see: http://eclipse.org/ajdt/downloads/).

Once you have installed all the plugins/dependencies that you want, try installing Spring again using http://springide.org/updatesite/ inside Eclipse.

Posted by Aaron Newton 

Comments [0]

nickelwound.com - MySQL: Join Tables from Different Databases

If you should need to access tables from multiple databases, or even JOIN tables from multiple databases, you can (provided the user you're connecting with has sufficient privileges):

SELECT
    c.customer_name,
    o.order_date
FROM
    db1.tbl_customers c LEFT JOIN
    db2.tbl_orders o ON o.customer_id = c.id

I needed to inner joing two geo-data tables across a MySQL database using only a single connection.

I should add that both users need the same permissions for this to work.

Posted by Aaron Newton 

Comments [0]



Contact Us   |