Week 8: More Morse
After a few weeks break, I'm back, with the stuff I had nearly finished last month. Here's a nifty tool I'll be expanding over time to hopefully include nearly every morse code standard imaginable.
Week 7: Morse Code
I spent last week feeling miserable from a cold, which is why I didn't post anything, so I'm planning on having two things finished this week to make up for it.
For now, I wrote a little class that generates wav files when fed morse code. I've set up a page that will simply return the result based on the url parameters. Change 'morse' and 'speed' (wpm) to whatever you want them to be. It accepts . for dit, - for dah, and spaces for a dit-length delay.
I'll post the source code later this week once I clean it up a bit and release some other morse code related stuff.
Week 6: More Perfect <pre> and <code> Tags
I recently read an old blog post called "How to Create Perfect Pre Tags" and thought it was pretty awesome, and then a day or two later I saw it (or something very similar) was in use on Flattr.com as well. However, I found "perfect" to be an inaccurate moniker.
Some of the problems:
- long lines are cut off when javascript is disabled
- unpredictable behavior (depending on css) using <pre> without <code>
- no syntax highlighting
- no line numbers
- pixel font sizes should be ems
- widths shouldn't be hard-coded javascript
- should be an optional max width property
- able to set tab size somewhere
- no source code available (other than the tutorial itself)
So, I took a bit of the original code and then rewrote most of it to do all of the above. jQuery is required (though with javascript disabled, #1 and #2 have still been fixed). #3 requires Google Code Prettify, but that's totally optional.
Here are some examples with the different options:
// really long block with just <pre><code></pre></code>
wp_register_style(self::$plugin_stylesheet_id, WP_PLUGIN_URL . '/' . dirname(plugin_basename(__FILE__)) . '/admin-styles.css' );
wp_enqueue_style(self::$plugin_stylesheet_id);
wp_register_script(self::$plugin_script_id, WP_PLUGIN_URL . '/' . dirname(plugin_basename(__FILE__)) . '/admin-scripts.js' );
wp_enqueue_script(self::$plugin_script_id);
// uses max-width
wp_register_style(self::$plugin_stylesheet_id, WP_PLUGIN_URL . '/' . dirname(plugin_basename(__FILE__)) . '/admin-styles.css' );
wp_enqueue_style(self::$plugin_stylesheet_id);
wp_register_script(self::$plugin_script_id, WP_PLUGIN_URL . '/' . dirname(plugin_basename(__FILE__)) . '/admin-scripts.js' );
wp_enqueue_script(self::$plugin_script_id);
// with class noprettyprint
wp_register_style(self::$plugin_stylesheet_id, WP_PLUGIN_URL . '/' . dirname(plugin_basename(__FILE__)) . '/admin-styles.css' );
wp_enqueue_style(self::$plugin_stylesheet_id);
wp_register_script(self::$plugin_script_id, WP_PLUGIN_URL . '/' . dirname(plugin_basename(__FILE__)) . '/admin-scripts.js' );
wp_enqueue_script(self::$plugin_script_id);
// with class nolinenums
wp_register_style(self::$plugin_stylesheet_id, WP_PLUGIN_URL . '/' . dirname(plugin_basename(__FILE__)) . '/admin-styles.css' );
wp_enqueue_style(self::$plugin_stylesheet_id);
wp_register_script(self::$plugin_script_id, WP_PLUGIN_URL . '/' . dirname(plugin_basename(__FILE__)) . '/admin-scripts.js' );
wp_enqueue_script(self::$plugin_script_id);
// just <pre> and no <code> ____ ____ ____ ___ ____ ___ __ __ ____ ______ ____ ___ ____ _____ __ ___ ___ ___ l j| \ | \ / _]| \ | \ | T | / T| Tl j/ \ | \ / ___/ / ] / \ | T T | T | _ Y| _ Y / [_ | D )| \ | | |Y o || | | TY Y| _ Y( \_ / / Y Y| _ _ | | | | | || | |Y _]| / | D Y| | || |l_j l_j | || O || | | \__ T / / | O || \_/ | | | | | || | || [_ | \ | |l : !| _ | | | | || || | | / \ | __ / \_ | || | | j l | | || | || T| . Y| | \ / | | | | | j ll !| | | \ || T\ |l !| | | |____jl__j__jl__j__jl_____jl__j\_jl_____j \_/ l__j__j l__j |____j\___/ l__j__j \___jl__j \____j \___/ l___j___j
// just <pre> with class 'expandable' and no <code> ____ ____ ____ ___ ____ ___ __ __ ____ ______ ____ ___ ____ _____ __ ___ ___ ___ l j| \ | \ / _]| \ | \ | T | / T| Tl j/ \ | \ / ___/ / ] / \ | T T | T | _ Y| _ Y / [_ | D )| \ | | |Y o || | | TY Y| _ Y( \_ / / Y Y| _ _ | | | | | || | |Y _]| / | D Y| | || |l_j l_j | || O || | | \__ T / / | O || \_/ | | | | | || | || [_ | \ | |l : !| _ | | | | || || | | / \ | __ / \_ | || | | j l | | || | || T| . Y| | \ / | | | | | j ll !| | | \ || T\ |l !| | | |____jl__j__jl__j__jl_____jl__j\_jl_____j \_/ l__j__j l__j |____j\___/ l__j__j \___jl__j \____j \___/ l___j___j
Since what you're seeing on this site at the moment is an old hacked together version,
here's a demo page I've set up where you can see all the different options and download the source.
Week 5: Support
Major update to the Dashboard Site Notes plugin, more work into it than it took to write the original version. I also did a major update on the Custom Post Type Archive plugin last week.
Week 4: QR Code Out
I was pretty busy with "real" work this week, so I'm posting a bit late. Next week will come early.
I had an idea for a dumb game so I made it.
Week 3: NSFW!
I'm planning to make a potentially not-safe-for-work post in the future, so I figured I'd put together a plugin to handle it without offending anyone. Here is the Make Safe For Work WordPress plugin.
Week 2: Dashboard Site Notes
This week I finished my hopefully bug-free plugin Dashboard Site Notes. You can also enjoy this timelapse video that I actually made a few weeks ago of the basil plant in my kitchen.
Week 1: One Week, Two Things
Over the last week I've been working on releasing some WordPress plugins, both to have some CV-fodder in my upcoming quest to find a developer job in Stockholm and to unify some bits of code that I've been using on various client sites while allowing them to stay updated via the plugin manager. I guess a bonus is that some other people might find them useful as well.
The first one is Admin Search by ID which took about 15 minutes to put together, and just allows admin users to search for posts by id instead of having to manipulate the url (not very client-friendly).
The other one, Post Type Taxonomy Archives, already existed in about a dozen forms by other plugin authors, but I wanted a bit of WordPress plugin writing practice so went ahead with it anyway.
Custom Post Types in Taxonomy Archives
- Configuration page
About a dozen versions of this already exist by other authors on WordPress.org, but I decided to throw in the version I cooked up just for some experience working with WordPress plugin development and because I'd already written most of it before I bothered to search.
This one is as exciting as it sounds. It allows you to choose which content types you want to include in your /tag and /category pages. One thing that (I think) makes this version unique is that it also allows you to add 'media' in addition to all of your custom post types.


Make Safe For Work
I wasn't satisfied with the Not-Safe-For-Work WordPress plugin I found, so I wrote one that has far more features than you'd ever imagine a silly plugin like this to have.
The default method, reload, doesn't send any of the offending content to the user's browser until they click on the reveal link, so if someone is behind a filter that prevents them from loading pages with certain words, they'll still be able to view your page.
Here are some demos of the different types available. The spoiler type handles images and advanced styling about as well as you'd expect (exceedingly poorly) but it uses visibility:hidden instead of just trying to turn everything black, so at least it always works.
original text:
really seriously unbelievably long swear word that exceeds all expectations
Standard method (first tag):
[Not Safe for Work. Click to View.]
Standard method (after first tag):
[NSFW]
Spoiler method:
really seriously unbelievably long swear word that exceeds all expectations
Deleted (never show anything, no idea why you'd want this):
[redacted]
Comment (view source):