elfs: (Default)

I work with EXT and Prototype at the office, and Dojo at home. I have a lot more time with EXT than either of the other two, so when I’m working on a personal project my first thought is “If this were EXT, I’d do it this way, but how do I do it in Dojo?”

It’s useful to write that knowledge down.

Last night, I ginned up a quick wiki, dropped in a theme I liked, and put the whole thing up. It only has a few entries right now but they should be enough to show what I’m trying to accomplish. If you find this a useful idea, please contribute to it and publicize it:

The Javascript Framework Phrasebook

This entry was automatically cross-posted from Elf's technical journal, ElfSternberg.com
elfs: (Default)

I started using this recently. If you do a lot of Python, you’ll sometimes find yourself desperate for breadcrumbs, little print statements scattered throughout your code as you try to figure what you told it to do, since it’s obviously not doing what you want it to do. I’d used inspect previously to unravel exception handlers; there’s a customized one inside the Isilon UI, so if the product fails in the field the exception will be logged to a file for later analysis, but this is a nice little routine. It’s basically a pythonic version of the C __LINE__ macro. Wherever you think you might need a debugging statement, put if DEBUG: print _line(), foo, bar, baz and you’ll not only get the fields you want to see, but also the name of the function/method, and the line number of the print statement.

import inspect
def _line():
    info = inspect.getframeinfo(inspect.currentframe().f_back)[0:3]
    return '[%s:%d]' % (info[2], info[1])

Use as needed.

This entry was automatically cross-posted from Elf's technical journal, ElfSternberg.com
elfs: (Default)
Baling out of politics for a moment (it's gonna be a long few months) but still entertaining myself thinking about how sick and sad this world can be, I'll relate a depressing conversation I had yesterday at Borders Books.

I'd gone to find myself a copy of the Ruby Pocket Reference. I've long liked having paper books for some things; I don't need the tactility of paper for fiction, but for reference it's absolutely critical, especially when I've reached the point of having so many tabs open on the browser that I've lost track of where I put the reference page for CGI and the one for IOStreams.

While I was looking through the shelves to see if there was anything I could learn that I wanted to learn (not generally), I saw a man browsing through the web development section. He was looking at a book on Dreamweaver. Since I'm not a fan of Dreamweaver, I asked him what he was looking for.

"I don't know," he said. "I don't own a copy of Dreamweaver."

We got into a conversation about what he was looking for. He wanted to learn how to put pages up on the web, he said. He didn't know a think about it. I explained my prejudices, and then we discussed the different layers of web development: HTML describes what goes on a page, and CSS describes how it'll look. The limitations of the web server can constrain your site's page-to-page architecture, and an application server like PHP, Rails, or Django (there were Django books everywhere) will allow you to provide pages that react, with things like logins, preferences, per-user views.

He seemed a little overwhelmed with the depth of knowledge needed. And then I pointed out that I wasn't a graphic designer; the visuals I usually just adapted from OSWD or a similar site, or bought outright from one of the many template stores available online.

And then I finally got around to asking him why he wanted to know.

"I thought I would put up a site for different cities that had deals on cars and other things, and would let members know right then that if they went down to some dealer somewhere they might find the right salesguy having a good day, or the right store with a very low price. You know, same day kind of stuff. I heard that there were these sites that had, what's it called, Adwords, down the side and I heard about these guys who put up a site and it made two or three dollars a day, which doesn't seem like much but if I put up a hundred sites like that it would make a lot of money, wouldn't it?"

I sighed and explained that it doesn't work like that. Only a fraction of sites make even a dollar a day. I said that there's a limit to automating the kind of site he was describing, along with policing it for griefers, spammers, and porn hackers (I had to explain griefer to him). What he really needed was a compelling difference from the rest of the market, how to stand out from the noise, and make your site different from everyone else's, something that would generate a lot of interest. "You've got three options: create content, which makes people want to read what you've got to say, create a community where lots of people want to read what each other has to say, or create an application that makes each and every user's lives better or easier in some way."

He seemed very disheartened by the responsibility of running a business. But then he brightened. "Some sites are just collections of links to other stuff. And they make money."

"Yeah, they cheat. And Google's figuring out how to kill them, because they don't actually add to the sum knowledge of the world. They just steal. Someday, Google will cut them out of the search field."

He kinda shrugged and said, "Well, there's still room for people like me, I guess." He pulled out the Dreamweaver book and walked away. "Thanks for the talk."

Sigh.
elfs: (Default)
I have a great mystery about Javascript: What does the new operator do, exactly? According to the documentation, "The new operator creates instances of ECMA standard objects and custom objects derived from Object." Since all other objects in the standard are derived from Object this would seem to me to be a useless addition, but that's not my point.

I have not yet found a use for the new operator in my normal programming responsibilities, and believe me I'm doing some heavy-duty Javascript these days. My traditional constructor looks like this:

MyClass = function(arg1, arg2) { 
    function privateFunction(argX) {...}; 
    function privateFunction(argX) {...}; 
    return { 
        a: 0, 
        b: '', 
        f: function(argX) { // Does something with this.a, this.b and arg1 } 
    }; 
}; 
myObj1 = MyClass(1, 4); 
myObj2 = MyClass(5, 9);


Calling the function MyClass returns an object (all the { ... } stuff after the return statement) and Javascript knows that unless you create a deeper internal scope, the this operator refers to that { ... } thing all the time, so a, b, f, and anything else described in there is available as a member of myObj1 from the outside, and this from the inside. Since every time MyClass is invoked, it creates a new scope and then pushes the closure out onto the heap before collapsing the stack, there's no need to call new.

So, when would someone need to use new?

Progress!

Nov. 14th, 2006 01:23 pm
elfs: (Default)
Well, I finally decided to knuckle down and work on my Rails project a little more. Total development time so far: about two hours. Progress: You can now add genres to the database. You can create stories, and stories have plots, and plots have scenes. You can't create plots or scenes yet, but you can add new stories and assign them genres. The genres drop-down is still just a label; the entire genre annotation subsystem hasn't quite gelled in my head and I think I'm going to have to hack it straight out of reality the hard way, by discovery rather than invention. I haven't even begun to consider the relationship between scenes, plots, and the timeline, but I have some intriguing ideas.

The generic story collective is called "world," but it has no model yet. Eventually you'll be able to add characters and locations to the world instead of to a story so you can keep using those characters and locations over and over again.

Once world is solidified, it'll belong to its own collective, "author." I hope someday to put this thing up on Pendorwright and let people beta-test it, joining as authors. Paying customers will be able to have more than one world, more than five stories, more than 25 scenes and more than 200K characters per story, and will be allowed to add private genres to the genre annotation subsystem. I'll make sure to run diction&style on all new text objects uploaded to the database to make sure that nobody's using it as a generic repository of garbage. Users will always be allowed to download their efforts.

I tried a downloadable "writer's tool," Writer, and I found it bewildering. It's not obvious to me how one "starts a story." I'm hoping that the "New Story" button in my thing will immediately lead you through to the Rails text editor tool intuitively.

I'll also be putting a stripped-down version of the source code up on the site for free, so anyone who wants to can run a local instance. The stripped-down version will support a single author (i.e. it will have no authentication or payment systems) and will lack many of the planned text-rendering features (mostly because they'll be subsystems that rails will call, rather than being part of the rails application itself).

Ruby is...

Nov. 10th, 2006 10:51 pm
elfs: (Default)
So, I've been wrapping my head around Ruby and Rails this week in my copious spare time (by the way, I hit by wordcount deadline for today, passing the halfway mark at 25860, yes! And the month's only a third over!) and listening to some simply incredible classical music (see the music tag) when I came to some annoying realizations about Ruby.

Ruby is Lisp. There's no other way to describe it. Ruby is Lisp the way Javascript is Lisp: both are descendents of the Lisp Way, but both have worked very hard to obscure that fact and look as if they had much in common with Algol's descendents, such as C and Pascal.

Ruby is Perl and Python. It's a scripting language as powerful as either of these, with a little of each's philosophy thrown in: from Python, ruby stole a sense of clarity with which it has not yet made peace, and from Perl, it stole the idea that there was any number of ways to do something and, oh yeah, Perl had some great ideas about what should be available by default.

Most frightening of all, Ruby is C++. Every major Ruby project creates a domain language unique to that project. Invoking the keywords of that domain language may result in great cascades of code that have little to no resemblence to "the core Ruby way of doing things," and whole chunks of your system may invoke excessively clever environmentally dependent templatizing routines that, without sufficient documentation, may deliver whole metaclass subsystems with execution trees that were never meant to be held inside the human head. Ruby's philosophy is that the domain language should be appropriate to the domain. Rails does an excellent job of living up to this expectation, but other projects I've seen do not.

I like Ruby, but that last is a major pitfall. Ruby experts love to show off their inner knowledge, often confusing the heck out of those of us new to the language, and the last aspect of the language makes it easy for said experts to mangle the brains of beginners. The Ruby community is currently going through an infatuation phase with itself, and helping new folks (like me) is going to take a while.
elfs: (Default)
Ruby is officially cool. Even without Rails, I can totally see how this language could become addictive fast. I barely speak the language and am desperately thumbing through the nutshell book at warp speed and I manage to write a better, faster, and more secure version of Narrator, this one obeying the principle of "configuration, not integration!", in less than half an hour.

That's totally cool. The only question remaining is simple: does the lack of an interim on-disk format cause a performance hit compared to the python version?
elfs: (Default)

Workrave screenshot.
For a long time, I've used Dr Wright, a program that reminds me to take breaks every now and then to rest my wrists and shoulders and generally to relax. Dr. Wright is a very simple program that does little more than lock up your screen after an interval with the warning "Take a break!"

I've switched recently to Workrave, which I like a whole lot more. It has a micro-break feature (about every five minutes, but configurable) which I should use but don't, and its hourly (or so, again configurable) breaks have a nifty "exercises you can do" guide (complete with anime girl with fluffy sheep logo... how cool is that?) that leads you through three of about ten different stretches and relaxation exercises meant to minimize damage both to your bones and to your eyes. It also tracks your total computer usage throughout the day, so you can eventually get the message that it's time to turn off your computer and go outside.

Workrave advertises that they have a distributed model, where a server keeps track of your time and the clients all intercommunicate so no matter how many machines you work on throughout the day, they're all keeping track of your total keyboardage so you can't cheat. It's not a true client/server model in that one client is basically allocated as "master" and all the others record their interactions to it. It would be better if there were a true server with no UI; I could run it on my laptop and have all the other boxes I use talk to it. It's also poorly documented; I can't figure out how to make it go.

But that's a quibble. The core functionality, designed to prevent RSI like my tendonitis, is better than any other product I've used in the past, such as Dr. Wright or the obnoxious XWrits, and it's cute mascots definitely make it a keeper.
elfs: (Default)
... will I remember what I'm doing when I'm sober?
elfs: (Default)
Four free software projects that are publicly available merged in my brain to become something bigger than their original parts. The projects are: qcomicbook (A Qt program allows you to read digitized comics and manga), gjiten (A GTK program that accepts keyboard input for kana/kanji), kanjipad (An X-11 program that accepts input from an artpad and spits out the possible kanji), and moji (A XUL program that accepts one, two, or three kanji and produces the translated word or phrase in English.)

A popular (and effective, for me at least) way of learning Japanese is to read manga in the original. But the dictionary lookup process is marred by a lack of speed: it takes a while to go from SKIP code to SKIP code, and that's not useful learning time.

So why not make that part of the process automatic? I envision a two-pane system. On the left, the page you're reading, with some zoom, forward/backward, and panning features. On the right, a stroke box on top hooked up to an art pad. A strip on the right or the bottom contains the "likely kanji" for the strokes you've just entered. Below that, an "accumulator" box that's picking up the kanji you've chosen and systematically providing you with individual and aggregate translations of those characaters.

Over time, this process (known as scanlation) will become more and more automatic as the characters and sequences become familiar.

This is one of those "in my copious spare time" projects. All the tools are available. As I am an Elf of very little brain or time, I'm not gonna get to it anytime soon. Someone else should take a crack at it.
elfs: (Default)

The following is a diff entry against the emacs client lj-update 3.3 that supports tagging. Note that the client makes no effort to check the tags, ensure they're consistent with anything else you've ever done, or enforce comma-correctness. Brad's entry makes it clear that tags can be "short phrases," therefore it's up to you to put commas between your "short phrase" and single-word tags.

Diff follows )

Profile

elfs: (Default)
Elf Sternberg

August 2025

S M T W T F S
     12
3456789
10111213141516
17181920212223
24252627282930
31      

Syndicate

RSS Atom

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Aug. 25th, 2025 10:55 pm
Powered by Dreamwidth Studios