Visual Code Editor 1.2.2: support for code in comments
Visual Code Editor 1.2.2 now supports code and syntax highlighting in comments.
Testing iframe code…
<iframe src='/test.html'></iframe>
Visual Code Editor 1.2.2 now supports code and syntax highlighting in comments.
Testing iframe code…
<iframe src='/test.html'></iframe>
I will be moving my blog from blogCFC to WordPress. So I have it installed and played with skins and syntax highlighting… which is quite lacking.
The problem comes in when you edit your post twice. When you load that post again, WP converts ampersands into “&”. Which is nice. But if you edit that post again, WP re encodes ampersands again. Giving you “&&”. Want to guess what happens if you save and load it again?
Now lets compound that with the visual editor, which automatically encodes for you as you type or paste. That only accelerates the process. And the fault here is with WP when it loads the post. Not with TinyMCE, at all.
Lets make matters even worse. WP’s init for TinyMCE is really screwy. Looking at the code you’d think they were rocket scientists. But… dang it… the defaults are horrible for programmers who want to blog!
That may sound really picky. But most syntax highlight plugins require either <pre> or <code> and to use special attributes in them to display properly. Some require the syntax to have all entities escaped, some require the opposite. What a freaking nightmare. So I set out to end this nonsense.
Enter Visual Code Editor. It’s a plugin I wrote for WordPress. Visual Code Editor makes it possible (and trouble free) to post and edit code snippets in wordpress’s visual editor.
And the nicest thing is… it’s a plugin! You don’t have to go around editing WP’s base installation. Download, extract, upload, activate, done.Coupled with the SyntaxHighlighter Plus plugin, you get results like this:
All you have to do is create a [/sourcecode] block, select the sourcecode block, select Preformatted from Tiny’s format menu, then paste in your code.
It should look like this:
I also left the door open for other syntax highlighters, which instead of using , use <pre lang=”xxx” [line="5"]> or even <code>, etc.
Feel free to download the plugin, which is now in the WordPress PlugIn Directory! Yippee I learnt how ta use SVN today! http://wordpress.org/extend/plugins/visual-code-editor/
I did my homework before writing this plugin. I tried all of the following. All of which failed in one way or another.
Here are the plugins that I am currently running:
WHEW! That’s enough blogging for today. I gotta get some work done!
I learned a great way to randomize SQL results.
In the past, I would have followed this routine:
Run a query pulling all of the results (tens? hundreds? thousands?).
Create an array.
Loop until 5 good random results are made:
Get 1 random query result.
If it’s not in the array, put it in.
If it is in the array, ignore it and try again.
Then I’d output the data from the array, rather than the query.
I suppose I could simply fill an array then randomize it. But that’s not really the point.
As you see, with this version we have to pull back so many more results than we’re actually going to use. That’s wasteful – especially if you want to pull back lots of data in each row.
So what’s this great super duper new way I’ve discovered to simplify code, only pull back the 5 results from SQL Server, and run fast? It’s really simple: tell SQL Server to do the work for you, with one word. No post parsing needed!
Just order the results by NewID(). Yeah, that’s it.
SELECT TOP 5 id, name, description FROM companies WHERE active=1 ORDER BY NewId()
This query will only return 5 random results – even if there are 1000 companies that are active – and in random order. So you can simply output your query like normal with your server language. Sweet.
Recent Comments