Sunday, March 18, 2007

How Prototype extends the DOM. I find Prototype essential to using Javascript, I have come to really rely on things like the $() selector, and now with the enhanced performance of $$() in Prototype 1.5.1, I'll be using it even more.
SQL injection cheatsheet - Good things to know to help you secure your server.

I'm really lucky, I use Ruby on Rails, and if you use it right, it'll protect you from most SQL injection attacks. It's still really good to be aware of these attacks, though.
Easy Clearing - How to clear floats in an enclosing container, the easy way.

It's basically saying that they don't like the current way of doing the following to clear a float in a container:


<div> <!-- float container -->
<div style="float:left; width:30%;"><p>Some content</p></div>
<p>Text not inside the float</p>
<div style="clear:both;"></div>
</div>


and instead they recommend you put a ".clearfix" class in each float you want to clear, and put the following in your CSS file.


.clearfix:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}


Well, I think this is pretty ugly, and as well, you still have to put a ".clearfix" attribute in the container you want to fix, so I will still be doing it the old way, myself.
How to use S3InfiniDisk from Amazon Developer Connection
S3InfiDisk for EC2 - A distributed caching system for EC2 with backend storage on S3.

This is a really interesting concept, and is going to be really useful for deploying applications on EC2. Right now, it's a little tricky, because each EC2 node isn't persistant, so you have to store all your permanent data on S3.

Now, we need something like this to be GPLed, and perhaps something more like Gluster, so that we could use those huge 160GB disks on each EC2 instance for fast access and caching, and then use S3 for permanent storage.


From the really wonderful online comic The Devil's Panties.

Wednesday, March 14, 2007

It was finally getting to me how I would have to press the "o" key four
times just to see where I was in the program. So, I hacked the
source. This is why free software is so important, sometimes, your
freedom includes not having to type the "o" key four times. Your
freedom is also how you interact with the world, and having to do that
over and over was getting to me. Ok, rant over, code begins:

I looked through the code until I found the code that deals with the
keypresses and found the relvant section, and just hacked it brutally
to do what I want. osd_level can be 0..3, and I wanted it to cycle
between level 1, which is the osd enabled, and level 3, which is full
osd display. So I changed the code to say:


if(v < 0)
if (osd_level == 1) {
osd_level = 3;
} else {
osd_level = 1;
}


Then, I didn't want the "OSD:enabled" message to display when I went
back to OSD mode, so I just commented out the offending code:


/* if (v == -1 && osd_level <= 1)
set_osd_msg(OSD_MSG_OSD_STATUS,0,osd_duration,
MSGTR_OSDosd, osd_level ? MSGTR_OSDenabled :
MSGTR_OSDdisabled);
else
rm_osd_msg(OSD_MSG_OSD_STATUS); */


Simple. No fuss, no muss. I was in and out in 10 minutes. It could have
been prettier, but part of the beauty was that it does exactly what I want
and it took almost no time to code.
:counter_cache - A way to do counting in Rails without having to query the database. Instead, a counter is kept updated when new items are added and removed from the database. Sweet.
I love this plugin: annotated models - It puts your schema definition at the top of your app/model/*.rb files. This is really sweet since you then don't have to have your schema.rb and your model.rb file open at the same time.


wow, so sweet, a big picture showing the http response codes.

Saturday, March 10, 2007

25 Code Snippets for Web Designers - Really sweet tips and tricks for CSS.

Friday, March 09, 2007

For yarn.sness.org, I need to slurp a bunch of data into a database,
and I remembered doing this for lovemygarden as well. The trick is to
put the data in a yaml file and use load_from_file to load the data.

First, install the plugin:


./script/plugin install http://topfunky.net/svn/plugins/ar_fixtures


Then, for example, if you have the following data in a file:


---
- !ruby/object:Amendment
attributes:
updated_at: 2006-07-07 11:56:10.086189
id: "1"
entry: Added 1 big bag of peat moss
user_id: "1"
created_at: 2006-04-16 12:40:00
- !ruby/object:Amendment
attributes:
updated_at: 2006-07-07 11:56:10.295888
id: "2"
entry: Added 3 shovel fulls of compost
user_id: "1"
created_at: 2006-04-18 12:40:00


You could put the following into a file in the db/migrate directory, like db/migrate/insert_data_001.rb


Amendment.load_from_file


And then run it with:


script/runner db/migrate/insert_data_001.rb



I learned this from:

nubyonrails - dump-or-slurp-yaml-reference-data

mmm tasty... edible turing machines...

Thursday, March 08, 2007

The Page Paradigm:

- - - - - - - - - - The Page Paradigm - - - - - - - - - -

On any given Web page, users will either...

- click something that appears to take them closer
to the fulfillment of their goal,

- or click the Back button on their Web browser.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Google spreadsheets go Camping - Some code to show how to integrate Google Spreadsheets with Why's great little Microplatform, Camping.

Wednesday, March 07, 2007

Monday, March 05, 2007

Wow, this would really rock, if I could get it running: An Emacs client for Google services

With it you can post directly to your blog from Emacs. Now that just rocks.

Another similar blog post about it

Also, a really nice mode for editting HTML/XML in Emacs is nxml-mode. I'm personally doing all my HTML with Ruby on Rails, even for static sites, I use RoR and generate static content, and for all my Rails interaction I use rinari.

Some info on the Google Data API

Also, this is just sweet: AWS::S3 - This is a Ruby library to interact with Amazons S3 (Simple Storage Service). If you're not into S3, EC2 and SQS yet, you need to be, it's so the future.
I think I used to know this, but I just learned this again:

How to open a tab in an existing Firefox window:


firefox -remote "openurl(http://www.mozilla.org)"

Friday, March 02, 2007

Performance tuning Apache:

Tuning Apache - Some links and general information
Perl tuning with ApacheBench - contains other good information as well
tuning Apache