Replacing 8kb of javascript for 36kb

Tuesday, December 18, 2007

A long time ago I came up with a solution to use inline editing with EE using some ajax magic. The problem with that solution though was that the page would refresh once you submit something to edit. I figured that there must be a more elegant solution, one that updated the edited information without a page refresh.

I decided to revisit this problem and rewrite the code using the jQuery javascript library and the jQuery form plugin. However, there is a lot more javascript involved. The jQuery file itself is 26kb (the packed version), the jQuery form plugin file is 6kb, and the custom code is 4kb, so the total amount of javascript I have to include on every page is 36kb. The original solution used only 8kb of javascript (although it did require me to edit the HTML to add the javascript call, whereas with jQuery I don’t have to).

Oh well. At least I got to learn how to use the jQuery library. And, since I am the only person who’s authorized to do any editing, I made it so the javascript files are only loaded when I’m logged in, so it doesn’t make any difference whatsoever to you the reader.

I love Version Control!

Saturday, April 08, 2006

This version control stuff is so so useful! I can’t believe that I’ve only realized this now. If only I had learned this in university – it would have saved so much time on group projects!

Come to think of it, there was one time in second year where one of my profs talked about CVS. But no one really listened because a) it was during the last week of term b) it wasn’t going to be on the final exam. smile

Playing with Subversion

Tuesday, March 28, 2006

After reading a whole bunch of instructions and fiddling with settings I don’t completely understand, I have finally gotten a Subversion repository working. I also set up public browsing interface using WebSVN.

It’s awesome. I set it up to track the changes I made to my LiveJournal style. Since several people use it I wanted to save the old revisions in case I make a change that breaks someone else’s code. Right now I know how to update and commit changes, still struggling on the branching and merging concepts. TortoiseSVN makes it super easy to do all of it.

WordPress Hack: Clickable Titles in Admin

Tuesday, January 10, 2006

I have been playing with WordPress for the past while. I’m helping a friend use it to manage a site. I’d use ExpressionEngine of course, but she needs it for commercial purposes and can’t afford it yet. smile Now WordPress is great, but I did find one minor annoyance with regards to the admin control panel. The posts (and pages) made to this WP blog are going to be edited a lot. If you look at the Manage Post page, the link to edit the post is all the way to the right side of the screen:

It got tiring having to move the mouse to the right of the screen to edit a post (hey, I have a highish resolution, I work with a maximized window and I have a big monitor screen). To fix this, I hacked the WordPress installation so that when you click on the post title, it’ll take you to the edit page for that post. I will share this hack here.

Open up the wp-admin\edit.php file, and around line 171 look for this:


	case 'title':
		?>
		<td>&lt;?php the_title() ?&gt;

Replace those lines with this:


	case 'title':
		?&gt;
		<td>&lt;?php if ( current_user_can('edit_post',$post->ID) ) { echo "<a href='post.php?action=edit&amp;post=$id'>"; the_title(); echo "</a>"; } else { the_title(); } ?&gt;

Then you can do the same thing to the Manage Pages page. Open up wp-admin\edit-pages.php around line 47 AND wp-admin\admin-functions.php around line 626, and look for this:


<td>
&lt;?php echo $pad; ?&gt;&lt;?php the_title() ?&gt; 

Replace the lines from both files with this:


<td>
&lt;?php echo $pad; ?&gt;&lt;?php if ( current_user_can('edit_pages') ) { echo "<a href='post.php?action=edit&amp;post=$id'>"; the_title(); echo "</a>"; } else { the_title(); } ?&gt;

Note: this is a hack and not a plugin, so the next time you upgrade your WP installation the changes will be lost.

Extension/Module Preview

Thursday, December 29, 2005

See this?

image

This is a screenshot of my EE control panel. I’ve written this extension and module combo that crossposts entries from EE into LiveJournal. The module part deals with the setup, and the extension part does the cross posting. I can pick a userpic option from the dropdown box, and the picture on the left immediately updates! It’s pretty darn cool if I do say so myself.

It’s finished but I have to fix up some of the language files and also the documentation.

Fotobuzz 0.2

Sunday, April 17, 2005

Fotobuzz 0.2 is out. It’s really kewl. I like the fact that you can now add multiple comments per region, and you can get an RSS feed for new comments added to an image. You can check out my desktop gallery for a demo (note: only I can add new comments). I really need to think of something to better utilize the EE gallery and fotobuzz. Maybe a childhood map? cool

Code Humour

Tuesday, June 01, 2004

Yesterday my brother told me about this Firefox plugin called Mouse Gestures that allows you to navigate faster using your mouse. So last night I installed it, and it already has TOTALLY changed the way I surf. Surfing is so much faster now! I use mouse gestures to go backwards, forwards, open a new tab, and open a new window. There are a lot more supported gestures to learn too.  cool

Now, on to what I actually wanted to post. There’s this article on code humour over at kuro5hin. There are several examples of funny code, and the author asked for others to post more examples. I have some of my own.

Here’s one my friend did on a Java assignment back in First Year (University):
do
{ /* some stuff I forget */
} while ( fat_lady != singing );

He changed it later, but I did think it was hilarious.

As for me, I’ve done this kind of thing lots of times with error checking:
int user;
scanf( “%d”, &user );
if ( user == stupid ) {
print("Error");
}

I’ve left this unchanged and submitted it as an assignment several times. smile

Searching Forums

Tuesday, May 18, 2004

I really wish there was some way that you can search forums faster.

How To Write Unmaintainable Code

Friday, March 05, 2004

Here’s an entire book outlining how to write unmaintainable code. It includes general principles, naming conventions, documentation, design, etc. It’s really funny to read and after looking through it I’m certain lots of programmers I know must have read the book too!! (link from del.icio.us)

Online computer manuals

Thursday, March 04, 2004

Muahaha this is great. I got this email today, informing me that my university library has gotten trial access to Safari Tech Books online. There you can find hundreds of handbooks and manuals on computer related things. I can only access it from a computer on campus, but there are so many neat books available! I don’t actually own a lot of technical handbooks; I tend to think that they’re expensive and the content becomes obsolete quickly. So it’s great that I can browse through some of them online. And even though a paper book may be easier to read, I like the fact that this way I can do an electronic search on a certain word / topic. The school library only has access for one month, but I’m definitely going to recommend that they permanently subscribe. smile

The Absolut Browser Caption

Wednesday, February 18, 2004

I’m loving this extension for Firefox. You get to change the name of the browser, and it can load a random word from a list. For the last few days, my browser’s name has been “Mozilla Wateremu”, “Mozilla Superimpala”, “Mozilla Spacemanatee” etc. Just today I realized you can change the “Mozilla” part of the name too, so I changed it to “Absolut”. Which is very cool, because absolut is my most used username. smile Now it’s fun opening up my browser and seeing what I get.

There was one interesting word I noticed in the default list of words that was installed, and I didn’t recognize - kitsune. I looked it up and it’s the word for the Japanese Red Fox. Is that what Firefox is named after? Because I remember reading somewhere that Firefox was meant to be the Red Panda. What I found even more interesting is that in the Wikipedia entry for kitsune it says they are “are capable of shape-shifting and creating illusions to trick people”. Shape-shifting, as in changing names several times? tongue

Hello, World, indeed!

Wednesday, February 11, 2004

Learn how to say “Hello, World”, in hundreds of languages! Programming languages, that is.

Here’s how I’d do it in C++, which I’m learning right now:

#include <iostream.h>
int main() {
cout << "Hello, World! << endl;
return 0;
}

Page 1 of 1 pages