1 July 2014 | Programming |
If you’ve ever programmed something in JavaScript, you most likely ran into a situation where you needed a delay.
Normally, we do this with setTimeout().
For repeatedly calling some function every X milliseconds, one would normally use setInterval().
Well, that’s fine. But what if you want to so something 10 times, and delay 3 seconds between iterations?
The solution is not as obvious as it appears…
But it is simple!
(more…)
6 June 2010 | Programming |
Some of you may recall my earlier post Adding JavaScript to WordPress Posts without a Plugin. In that post, I talked about how to add JavaScript for, say, embedding a video without having WordPress “sanitize” your code… and without any plugins!
WordPress MU, the version of WordPress that allows multiple blogs to be run under one WP installation, uses a different content sanitizer. In fact, it’s so seriously anal that it blows away not only JavaScript, but all kinds of other HTML tags in your posts that the regular WP leaves untouched! Bad juju.
In the case of WP MU, the best solution that I could find does include a plugin – but you can write it yourself in about 10 seconds. In writing the plugin yourself, you will also know how to maintain it yourself. Even if you don’t know much about PHP, this one’s a piece of cake!
So, here’s how to convince WordPress MU to play nice with the HTML in your posts…
(more…)
14 December 2009 | Programming |
So you’ve decided to be supercool and use jQuery. That was a wise decision you made, because jQuery totally rocks. Especially in Rails apps, jQuery makes life a LOT simpler. Yes, you have to learn some JavaScript and some quasi-new syntax, but it’s still seriously powerful and convenient.
There’s only one problem: if you’re like me (i.e. JavaScript-impaired), you just couldn’t get your forms to submit via an AJAX call.
You’ve probably heard of something called the jQuery Form Plugin. It’s a bit overwhelming looking at all the options and trying to extract just the functionality you need if you aren’t a JS Jedi, though. And so, without further ado, I present to you jQuery Form Submission for Dummies!
(more…)
22 November 2009 | Programming |
If you have installed your own WordPress blog on your server, you may want to include some JavaScript goodness from time to time.
The bad news is that WordPress likes to screw around with tags when using the WYSIWYG post editor. That makes it kind of hard to, say, embed a video in one of your posts.
The good news is that there is a very easy way to embed any kind of JavaScript in your posts without the need to install any plugins, or change any configuration settings. And it works beautifully with the WYSIWYG editor…
(more…)
27 June 2009 | Programming |
WordPress is a seriously popular blogging platform, primarily because it simply rocks. In fact, this here blog uses WordPress.
Since I generally write posts about programming issues, I needed a good plugin for automagically highlighting code segments. I ended up choosing SyntaxHighlighter by Viper007Bond.
While it generally kicks butt, there is one little bug that is particularly annoying for those of us who post snippets of Ruby code: including a variable in a string like 'this is a #{color} string'
causes SyntaxHighlighter to make everything after the “#” into a comment, which it wraps down to the following line.
That simply won’t do…
(more…)
Recent Comments