Friday, June 20th, 2008

Crap I’ve had to re-google

At some point you get tired of re-Googling crap…

Delete the directory before handling it in SVN?

svn commit -m <missing directory>

Pin the dock to the start|middle|end of the monitor.

defaults write com.apple.dock pinning -string start|middle|en

Remove the .Mac sync icon.

command-click and drag it off the bar. works for any icon up there.

Posted by shane | Filed in Code Stuff | Comment now »

Friday, June 20th, 2008

Refresh a django database

I just ran across this post on Chris Platt’s blog and don’t want to lose the code. There are a few ways to refresh your django database (that is, export the data, empty the database, update the schema, and re-import the exported data):

 

Method Number One

#!/bin/sh
./manage.py dumpdata >> blabla.json
./manage.py flush
./manage.py loadata blabla.json

 

Method Number Two

Add a setting to settings.py:

 

FIXTURE_DIRS = (‘/home/keats/fixtures’,)

 

Then dump your data:

 

./manage.py dumpdata >> /home/keats/fixtures/initial_data.json

 

Now each time you call:

 

./manage.py flush

 

The data in fixtures/initial_data.json will be reloaded into the database. The filename is important.

 

Method Number Three

Add a sql/ directory to your application. Create a file in sql/ named model_name.json (or model_name.sql) and it will be loaded each time you flush your database. There’s more about this particular method somewhere but I’m too lazy to google it.

 

Posted by shane | Filed in Code Stuff | Comment now »

Sunday, June 8th, 2008

WYSIWYG? Hardly.

WYSIWYG editors have a long way to go.

 

I’m using the editor in WordPress to write this article. Like every other WYSIWYG editor I’ve used or tried to integrate into a site, it has flaws that make it frustrating to use.

 

For 30 minutes I struggled to copy and paste plain-text from email I received into a quoted section. Sometimes the entire section is quoted properly, but the text I write beneath the quoted section is chopped off or not colored correctly. Sometimes the quoted text is split into sections, sometimes it’s not. What I see is not what I’m getting. I got so frustrated, I abandoned that post to bitch about it in this one.

 

FCKEdit suffers from similar problems. So does the editor from Telerik. I tried to integrate each into a .NET CMS application but soon found out that they stripped, replaced, and added tags to the editor’s content behind the scenes. It’s impossible to create a file in either editor without it being modified.

 

I tried most of the Googlable WYSIWYG editors on the market. Of those that fell into the “not enough features” set, most saved the content as I intended it to be. The problem, though, is that they aren’t advanced enough to consider for a solution anyway. You might as well be using a TEXTAREA. On the other hand, those editors that were feature-rich played all sorts of games to achieve that end. What you put in isn’t what you get out and that’s a problem in certain situations (like SEO or trying to maintain a consistent look across a site while allowing marketing folks to edit their own content).

 

Clever Kills

 

The more these editors do, the more they mangle the HTML. There are reasons I don’t want BODY tags around the content when I don’t put them in there, or multiple FONT or SPAN tags when one will do, or empty P tags strewn about. And, although they all seem to allow some sort of CSS-customization, even if you can get the editor configured to use the fonts and colors and styles that the rest of your site does, the HTML it spits out can be horrendous.

 

I recently wrote a small wiki app for the stfupls.com site. It uses a TEXTAREA for the content, largely because I chose to support markdown syntax instead of HTML. I had a hankering to use an image in one of my wiki pages the other day but gave up because FTPing the image to a public place and referencing it was just too much effort.

 

The sensible solution is to integrate an editor that allows me to upload images and automagically takes care of storing them wherever they need to be. But I can’t get over my general distaste for WYSIWYGs and I still think I should write my own solution; one that isn’t bloated with everything and the “kitchen sink”.

 

... and the kitchen sink.

(my screencap almost wasn’t quick enough, but you can still see the tooltip)

 

However, in the interest of time and the good out-weighing the bad, I’ll likely end up with one of these abominations in the solution; stripped down as much as possible. I’ll give the WordPress editor credit here — it’s as sparse as it can be while remaining useful (it hides the less-oft-used stuff in the “kitchen sink”) and it doesn’t have the dumb-ass floppy-disk save icon. Praise Jebus.

Posted by shane | Filed in Rants | Comment now »