Posted by hank,
Sat Jan 05 16:49:00 UTC 2008
So, I found this today, and it is awesome. I wanted it in Bluecloth so I could use it in Mephisto. Here’s how.
First, I needed to make it so I could still do normal images, but turn on coolness if I want. Here’s the goal I came up with for the grammar:
[](imageurl.jpg "Scrolly Text at top" "photoslice")
Here’s the first test, with a single image:

And now a set with a namespace:

I did it by simply modifying the regex and image url parsing function in BlueCloth like so:
InlineLinkRegex = %r{
\( # Literal paren
[ ]* # Zero or more spaces
<?(.+?)>? # URI = $1
[ ]* # Zero or more spaces
(?: # title
([\"\']) # Opening quote char = $2
(.*?) # Title = $3
\2 # Matching quote char
)? # Title is optional
[ ]* # Zero or more spaces
(?: # rel
([\"\']) # Opening quote char = $2
(.*?) # rel = $5
\4 # Matching quote char
)? # rel is optional
\)
}x
# and later...
# ...or for an inline style second part
elsif @scanner.scan( InlineLinkRegex )
url = @scanner[1]
title = @scanner[3]
rel = @scanner[5]
@log.debug " Found an inline link to %p" % url
text += %{<a href="%s"} % escape_md( url )
if title
title.gsub!( /"/, """ )
text += %{ title="%s"} % escape_md( title )
end
if rel
rel.gsub!( /"/, """ )
text += %{ rel="%s"} % escape_md( rel )
end
I also added the following to my Mephisto theme layout, in the head section:
<!-- Photoslice -->
<link rel="stylesheet" type="text/css" href="/javascripts/photoslice/style.css" />
{{ "photoslice/functions.js" | javascript }}
Once again, Ruby is awesome. And so is Markdown.
Tags: javascript
Posted by hank,
Thu Oct 25 20:30:00 UTC 2007
So, I though it would be interesting to mimic browser behavior with error pages. I decided I needed to make a page that looked exactly like the Firefox Server-not-found page. I managed to copy the source using Firebug, and I extracted the css out of the jar files on my system. Anyway, I ended up with some source for IE and some source for Firefox.
I left little invisible links in each one (search for ‘Supplies’ on the page). I also removed all the default javascript from the Firefox version and replaced the Try Again action with a simple reload one-liner.
Then, I just wrote some awesome PHP to take care of which one to load, and called it index.php:
<?php
if (preg_match('/MSIE/i', $_SERVER['HTTP_USER_AGENT'])) {
readfile("errortest-ie.html");
} else {
readfile("errortest-ff.html");
}
?>
And we’re done. Not bad, eh?
Tags: javascript
Posted by hank,
Sun Aug 19 13:42:00 UTC 2007
Of course I know that a simple Greasemonkey script can very easily thwart this, but I don’t expect most people to go out and find it to defeat this. If you don’t like my google ads, you can read this wonderful entry.
function sendJerksAway() {
// Bye
eval(unescape("%69%66%28%24" +
"%24%28%75%6e%65%73%63%61%70%65" +
"%28%27%25%35%62%25%36" +
"%65%25%36%31%25%36" +
"%64%25%36%35%25%33" +
"%64%25%36%37%25%36%66%25%36%66%25" +
"%36%37%25%36%63%25%36%35%25" +
"%35%66%25%36%31%25%36%34%25%37%33%25%35%66" +
"%25%36%36%25%37%32%25" +
"%36%31%25%36%64%25%36%35%25%35%64%27%29%29%2e%6c" +
"%65%6e%67%74%68%20%3d%3d" +
"%20%30%29%20%64%6f%63%75%6d%65%6e%74" +
"%2e%6c%6f%63%61%74%69%6f" +
"%6e%20%3d%20%22%68%74%74%70%3a" +
"%2f%2f%67%6f%6f%67%6c%65%2e%62%6c%6f" +
"%67%6e%65%77%73%63%68" +
"%61%6e%6e%65%6c%2e%63%6f%6d" +
"%2f%61%72%63%68%69%76%65%73" +
"%2f%32%30%30%37%2f%30%37" +
"%2f%32%34%2f%67%6f%6f%67%6c%65%2d%72%65%63%6f%6d" +
"%6d%65%6e%64" +
"%73%2d%74%75%72%6e%69%6e%67" +
"%2d%6f%66%66%2d%61" +
"%64%62%6c%6f%63%6b%2f%22"));
}
Then it’s just this:
<body onLoad="sendJerksAway();">
Tags: javascript
Posted by hank,
Mon Apr 16 22:53:00 UTC 2007
Today, Will told me about some awesome image caching. I used it.
//Do some image caching
cached_image = Array(new Image(), new Image(), new Image(), new Image());
cached_image[0].src="image1.jpg";
cached_image[1].src="image2.jpg";
It’s amazing.
Tags: javascript
Posted by hank,
Wed Apr 04 15:49:00 UTC 2007
Today, I had a problem doing this:
<input type='text' readonly onFocus="alert('manatee');this.blur();" />
The problem was it would go into an infinite alert loop. That’s not cool. The fix was to reverse the calls:
<input type='text' readonly onFocus="this.blur();alert('manatee');" />
Tags: javascript