Saturday, August 15, 2015

Pwd Rules

This happens to me all the time: I have to create a password for a site that I dont use everyday, but its an important site, like a bank or insurance site. The site usually has some wierd set of rules that I obeyed when I created the account, but have forgotten now.

So when I go in after a while and have to get in, I have some inkling of my password, but cannot get past the auth page because of some arcane rule that is not obvious to me then. Of course, I go through the reset password procedure and THEN they list out all the requirements for the new password.

If I could see the rules one page ahead, though, I'd probably be able to remember my original one!

So here's the idea: A website called PasswordRules that stores the password rules by site. You can query by site to get the rules for that site and use it to login. Simple!

Better yet: Browser plugin that pops the rules up when you visit the site.
More: API for contributors and website owners to publish the rules programatically.

Design:
  • Create a website that has:
    • add new site and its rules
    • edit site rules
    • search for rules by site
  • Create an API that allows:
    • Search for rules by site
    • [optional] add/edit site rules
  • Create a plugin for Firefox, Chrome, etc that:
    • Uses the API to search for the current site and load up its rules in a popup

Sunday, December 14, 2014

Lingaa->Rajni->Balleilakka->Choirs : How mass movies lead to high music

So I watched Lingaa yesterday.

Because of which I was googling and youtubing for rajni's impact outside india; and was largely expecting to find videos from japan - which I did.

But what was really interesting is that I found at least 5 to 6 videos of one song from Rajni's last movie - Sivaji - being sung by school choirs across US.

The song's called Balleilakka, and here's the original:
https://www.youtube.com/watch?v=Tma8zoLEPJU

Here's a sampler of schools choirs singing it:

Best that I found: https://www.youtube.com/watch?v=XQWLqcNr9B8
Really fast: https://www.youtube.com/watch?v=Rvo1_vLGAGo
Pretty good, but smattering of indians :) : https://www.youtube.com/watch?v=dUhMQYW-xmk
Pretty good: https://www.youtube.com/watch?v=09C8s1QhgqE
Shitty accoustics, but points for the effort: https://www.youtube.com/watch?v=jSJYVAB8XQU


.. and I began to wonder: why this song alone? None of them actually mentioned the source of the song; they usually called it an indian song in tamil. I think one mentioned that its AR Rehman's song.

So they were actually using it because it was a complex song musically - it was a tongue twister even for natural speakers of the language and what was really obvious from listening to it when sung by a chorus is that it had many layers and voices to it. I dont obviously know the right musical terms here, but in programming terms, it was a mutlithreaded song - multiple concurrent voices had to be active to make it happen, and each voice was sure to get knotted up in the tongue twister lyrics; not to mention that the beat was really fast! No wonder the choruses are taking it up as a challenge.

Its amazing that I live in a time when composers like Rehman have enough commercial clout to put complex music into a movie meant for the masses. Even better: not only do the intended audiences love the song, so do people who are serious about music!

Thursday, August 14, 2014

Idea: A screenreader that's a market place, not a queue

Had this idea while in a meeting at work today where ADA was being talked about; and how making a page ADA compliant required reordering the markup - sometimes entirely.

What if the screen reader didn't read sequentially - like a queue of people who talk to a teller - and instead read everything that's on a page at the same time - almost like a marketplace where everyone's talking at the same time?

I'm not blind, but I have to imagine that this is how blind people perceive the real world anyway - as a cacophony of sounds that they have to filter out noise from. This is not that different from fully able people sensing the world and filtering what's important.

If we had such a screen reader, the document markup could be the cue for how "loud" each element would be, child elements could be "muted" in favor of the parent and so forth.

Todo: check if screen readers already do this.

Tuesday, June 17, 2014

Fixed order graphs with Graphviz

Graphviz continues to amaze me. I did not know until recently that they had an awk-like language for graphs within the graphviz package, but even closer home - there's a tool to control the order of nodes!

This is the one thing I've battled with out-of-the-box Graphviz for a long time - any new edge is likely to throw your neat-looking graph off-kilter *just because* that's the most optimal graph layout.

Well, not if you use osage, packmode and sortv.

I dont exactly know why its called osage, but this layouting engine actually obeys the order of nodes that you can specify with the sortv attribute.

You have to set the appropriate packmode setting, of course, and the correct incantation is:

packmode=array_uX

where X=1 if you want one column of nodes, 2 if two and so forth.

Here's a sample graph for a taste of what it looks like in practice (from the man page for osage, see example section):

digraph test123 {
    pack=8
    subgraph cluster0 {
        packmode=array_u1
        x[sortv=5]
        y[sortv=4]
        x0[sortv=3]
        y0[sortv=2]
        x1[sortv=1]
       
        subgraph cluster1 {
            mn
        }
    }
    b[shape=box];
    c[label="hello\nworld",color=blue,fontsize=24,fontname="Palatino−Italic",fontcolor=red,style=filled];

    a->z
    x->z
    a->b->c;
    a->{x y};

    edge [style=dashed,color=red];
    b->x;
}



Once you do that, you issue something like this:

osage testosage.dot -Tpng -o testosage.png

... and you should see a column of components with x at the bottom and x1 at the top.

Also, use

pack=16

to space the nodes out a bit. Default is 8


Sunday, March 09, 2014

I fixed some hardware!

This is a personal first. I took my wife's laptop apart and repaired it!

My wife has a Lenovo 670 that we bought in India. Its a low-end laptop that I chose for her because we were in the market due to my son spilling water over the good Toshiba that she originally had. "You use it mostly for browsing", I had reasoned, adding: "Besides, its a Lenovo, which used to be a Thinkpad, so these things are rugged; and more importantly it has the chicklet keyboard so we're covered on the water spillage scenario from now on".

While it indeed was rugged, it didnt endear itself to my wife because it was slow as hell. Still, she was not a fan of the Mac and was happy that it was the one Windows machine in the household.

Fast forward 2.5 years later and across the globe where we are now, the poor laptop had fallen for the umpteenth time from the side table (I think it was the son again - this time a well-placed kick in sleep) and the wife found that she could no longer charge the laptop. The connector could still be seen inside, but it was not in its slot and couldn't be paired with the charger.

"Husband, can you see if you can fix this?" she asked. I quickly googled the nearest Lenovo service center and left it open in a tab for her to see.

A few weeks later, she got around to calling the service center only to be told that they didn't service any models sold outside the US of A, thank you very much.

We considered shipping it off true desi style with some hapless acquaintance to be delivered to a service center in India that DID service such models, but thought it might be not worth all that hassle.

So my wife repeated her original question and went one step further and found a web page with instructions on how to do it.

Two or three weeks later, I got around to looking at it. The initial steps were all pretty standard - unscrew 13 screws, turn over, unscrew 8 other screws and so forth. The rest were decidedly not unless you've been assembling and disassembling laptops (or other electronics) all your life.

Here's the thing about electronics these days: They're giant 3-D puzzles that have been put together in a space the size of a football field and then squished into the final size that you get it in. There is apparently one and only one way to take the thing apart and almost everything requires you to take the whole thing apart. Must be nice to be in a market where your product has no serviceable parts or the act of servicing it will render it non-serviceable.

So I got around to removing the battery (of course), back cover, the hard disk, the connection to the wireless lan and the optic drive. I had skipped the memory hoping it would not be germane to my fixing the power supply connection. Going through the next steps. however, it looked like the only way I could get to the power supply was by removing the fan, the cpu heat sink and the cpu itself.

Now this is not new territory to me - I HAVE disassembled a laptop before - solely because of my cheapness. Back in the early 2000s, they sold an abomination of a laptop called eMachines - they had great specs and were cheap; except they killed themselves whenever you ran more than 3 applications because the cpu heated up past its allowed range due to the cheap heat sink they put in. One way to solve this was to open it up and clean out the sink yourself.

Anyhoo, because of that experience, I knew that taking the CPU out implies putting in new compound - something that I didnt have then nor had now (side note: I had taken a chance with the eMachines and put the hardened compound back as-is and it did work for a while :) ). So I did what everyone would do - tried taking either the bottom half of the laptop or the bevel surrounding the keyboard without touching the CPU or its sink.

After about 5 hours, I gave up. All natural light had gone by then and I really couldnt work with the incandescent lights and the Walmart tools that I had. So I gave up for the next few weeks.

Finally, I picked it back up today. Started at about 11 am and by 6 I had the bevel around the keyboard removed. Here's the kicker: Remember I told you that these things are 3D puzzles? Well, not only are they puzzles, they're also traps: manufacturers put in blue paint on screws and stickers on specific components that will tell them if we've actually looked inside. The thing that held me up for a good 4 hours? One screw that was hidden under a Lenovo sticker. After I found it at 3 hours and 57 mins counting, I realized that special gum those kindly folks at Lenovo used would not allow me to peel the sticker off. It had to be scratched out - leaving no doubt that whatever warranty this laptop could have been under has now been voided.

Once the bevel was removed, I could look at the connector. Sure enough everything was fine and all it needed was to be put back in place. To their credit, this Lenovo had taken all kinds of weird angles of the charger and worked well until recently. I dont know if there was a bit that did hold it in place, but it looked like all they had going to keep it there was a snug fit. So I made that a lil bit snugger with some quickfix glue and closed the whole thing up.

And by "closed the whole thing up" I mean "Spent the next 2 hours painstakingly following the instructions in reverse order, of which half an hour was spent looking - unsucessfully - for the one washer that got away and was now hidden in the beige savannah called my carpet, then reaching the last step only to realize that step 8 was reinstalling the keyboard (a link off to another page) that I'd missed so going back a few steps to take gajillion screws out again and popping the keyboard out and finally getting it all together with 2 screws outside"

As if on cue, the wife showed up and asked nonchalantly: "How's it going?". This must be how CEOs and VPs feel.

We fired it up and it hasn't exploded - yet.

My wife, of course, noted dryly that it seems somewhat slower - like my hardware machinations could have magically slowed down the electronic pathways inside Windows 7.

I was just happy that it worked :). We hi-fived. She said she's proud she married someone who knows how to fix things.

Tuesday, January 07, 2014

A better portable environment

For a long time I've tried to create a portable environment for myself, without much success.

A portable environment is a collection of all software that I need and use for development available as a set of files on a USB stick. I should be able to put it into any machine (Win, OSX or Linux) and do everything that I want to do.
PortableApps comes pretty close. Portable msysgit gives a uniform bash shell everywhere and as long as i'm miserly with the languages I want to work with, I should be OK. Maybe cheat a bit with an install of Sublime Text (zip install used via Wine on Linux) and I'm golden.

At least that's what I've settled for now.

But sometimes its not enough. You want a full environment. You want to not have to copy files or git rebase. So I tried VirtualBox. The idea was that the only install I'd need was Virtual Box on each machine that I want to use the environment on, and the VDI file would be on the stick. That way everything remains in one place.

Except the VDI files dont work right with OSX. Or at least didnt on Snow Leopard. I've not tried on Mavericks.

But in the meantime, I had an idea: How about a node-webkit based environment? As long as the stick has executables for all OSs, the app itself can be run. There are enough and more terminal emulators, editors and so forth in JS these days. What is still not in JS (versioning, file system, etc) could probably be filled in using emscripten.js maybe?

Its a thought for 2015 :)

Saturday, January 04, 2014

Idea: Stable visualization of a codebase

I have been thinking lately about visualizations of a codebase - spurred on because of recently rediscovering Software Catography and its successor - Codemap. Coincidentally, I also wanted to create my personal website as a "visual representation of the web of connections that it is", which essentially boiled down to a stable visualization.

When I looked at the tools that are currently available to do this, it seems like they are overly complex. The closest was Gource, but it focuses on the people who worked on the code and doesnt generate a stable visualization.

So here's my idea:

  • The visualization will be created from the commit history of the codebase.
  • Once created, the visualization is not a snapshot, but can be enhanced over time to show changes. So the output format should contain the history of changes.
  • The visualization is essentially a Treemap-ish diagram with time along the X-axis and size along the Y.
  • Each object(file or directory) is drawn as it comes to life in the commit log and is represented as a rectangle.
    • Position: The first object  that is created gets the position x=0 within its parent, the second gets x=1 and so forth. Once assigned, these positions are permanent even after the object is moved or removed.
    • Dimensions: The width remains the same for all: files have a width of 1 unit and directories have a width equal to the sum of the widths of its contents. The height is equal to the size of the file.
  • When an object is changed, its old size shows up as a faded outline within the newly sized rectangle - somewhat akin to the age rings of trees. Size reductions may show age rings outside the current rectangle.
  • When an object is moved, its old position shows a faded outline and objects after it do not move to take up the position.
  • Similarly when an object is deleted, its old position shows a faded outline.
  • Keeping the visualization contained: This is where the Treemap concepts are helpful. The complete visualization's size will be calculated inside-out: the size of the deepest directory will control the % contribution of its parent and therefore transitively its grandparent, and so forth. This way, the visualization can be contained in a finite space. At its smallest size, each "rectangle" will be reduced to a line: the position still remains as described above, the width is reduced to 1 pixel and the length is still the size of the file. No rings are possible at this level of compaction.
  • Controls: The visualization will have:
    • Play: A way to see the evolution of the codebase a la Gource
    • Zoom in and out
    • Time Filter: A way to filter out older rectangles. This will essentially show the current state of the codebase, but since all positions are fixed, it will give an idea of how far the current state is from the original.
    • Object Highlight: this will highlight a particular file or directory to "show where it is in the map"
    • Object Trace: This will high light the path of the object throughout its evolution in the codebase.
    • Commit Highlight: Highlight all files in a commit
The advantages I see with such a visualization is that it combines a stable spatial representation of the code along with its evolution over time. Using a treemap representation essentially keeps it bounded so that the view could be injected into current developer environments without taking up too much screen space.

Implementation notes:
  • A quick way to implement this might be using html divs.

Wednesday, December 25, 2013

Last post of the year

Its been almost 9 months since I've blogged!

I realized it only yesterday.

A lot has happened in that gap  - I moved halfway across the globe, was in "transit housing" before and after, getting adjusted to the new place and so forth.

However, there's another reason for the dry up in blog content: I started building more and - more importantly - started journaling my work within each project.

The "building more" piece came from an an increased focus on finishing. Not that I'm good at it, but I'm moving in that direction.

The "journaliing" piece came from switching projects too much and having to spend a lot of time catching up with where I was when I left off last. However, it quickly became a "pensieve" of sorts - a place where I store my thoughts and half-baked ideas on how to move forward with that project. Since most (all?) my projects are single-person ones, its easy for me to plop in a journal.md and just start writing.

So, in some sense, the ideas that I come up with used to be put up here as blog posts now are likely ending up as another project folder on my laptop. It also is probable that the bandwidth that I had for ideas in general is now being channelled into specific ideas for projects that I'm already working on.

Anyhoo, that's by way of apology to the teeming millions visiting this blog :)

Since this is the end of the year, I usually end up thinking about what I've achieved and do some half hearted attempt at a resolution list. Not that I actually execute on that list, but its good to at least think about it once a year :)

So here's what I'd like to focus on in 2014: Actually finish up (even a v1.0) of these projects:

  1. my website
  2. GUTS
  3. plnext
  4. ed
This should be quite enough considering I'm staring a part-time masters soon. Hopefully I wont get derailed with weekend projects that take 2 months to reach v1.0, but hey - that's the fun of personal projects, right?

On the bright side, that project was something that I always wanted to do, so there's always a bright side :)

Wednesday, March 13, 2013

Eternal digressions of the engineer mind

I had an idea for a stream-of-consciousness editor. So I started creating a prototype using node-webkit, codemirror and my non-existent ui skills.

Since I did all this on the PC and wanted to sync up with the mac, I started to setup node-webkit on it, only to realize that there are no binaries for osx 10.6.x.

So I downloaded node-webkit (using up 35gigs of bandwidth by the 10th of the month - kids and wife will not see their videos) and got it running.

Then I realized that the code for the editor itself could do with some modularization - modularization of the kind that my betterscript language promises. That project, which was last worked on last year on one day - a hacknight - now got revived.

Of course, betterscript uses ometa-js, which I'd copied directly onto the betterscript project (along with its dependency - rhino) and duct-taped together a script that worked only for that version of betterscript.

Today's me, however, was not happy with this state of affairs. First off, ometa-js should be an external dependency. Also, even if it were an external dep, the original author had not really organized the code much. He'd just done the important bits - ie the really interesting peg parser in JS that parsed both text and objects alike - and left the rest of the "productionization" to us vogons. This wouldnt do, of course. I'd like some organization in that code, for cryin' out loud.

This required looking up the original github project and its 400 some-odd forks to see which one met my needs. There were a few that did re-org the code, but not in the "just right" way: they'd either stop short of what I wanted, or go way beyond the call and rewrite the code.

So of course, I forked the original, reorg-ed the code my way and tried to use it as a dependency on betterscript. Which, of course, meant that now I had to rewrite the original ometa-rhino.js with whatever changes I'd made in the file with the same name within betterscript. This lead to the realization after one sleepless night (doh) that outputing an object to stdout will reduce it to a string that cannot be read back as an object. Off to Crockford's for a bit of json2.js.

As of today:

  • my fork of ometa-js works when run using my lanucher with rhino. Other modes not working yet.
  • betterscript works using my fork of ometa-js on simple samples. Still a long way to go before I send that post out to jashkenas :)
  • soced is encouraging concept-wise, still to reach its usability nirvana!

Final note: I thought it might a good idea to represent all these dependencies as a Graphviz graph. That turned into a journey down the "how do I get graphviz to show the nodes in the order I want " rabbit hole.

Sigh.

The phrase "Eternal Digressions" is somewhat inspired by the phrase "Infinite Digressions", which is copyrighted by Praveen. Alluded to here with no permission whatsoever :) 

Sunday, March 10, 2013

Built node-webkit...finally

So I'm still on Snow Leopard, which means node-webkit's pre-built binaries are of no help - they start at 10.7. The pithy response to the very pertinent question of "How the hell do I run this awesome piece of software on my apple-fanboy-version-of-win2k?" has been "Oh, just build it on 10.6.x yourself. I hear it works fine then".

In a rush induced by the success of my "Code as you think" prototype working really nicely on the PC, I decided that I must have it running on the Mac too. I did consider upgrading to Mountain Lion, but decided that building node-webkit like they'd blithely suggested might be smaller a peak to scale than having to deal with a whole new version of OSX.

Downloading the code took about a day and a half. Of course, I was not surprised, considering this was  the Chromium codebase, plus node-webkit's own. Actually, the final download took about 3-4 hours, but it failed (ie 'gclient sync' got stuck and had to be ctrl-c'd) about 4-5 times. Here're the things that I learnt/thought up during these failures:

  • How to setup the mac so it doesnt sleep - using screensavers and energy settings. Ended up using neither: was going away for the night, didnt want to leave machine unmanned.
  • How to piss spouse off with blank stares and disconnected answers while download process failed yet again.
  • How it would be nice if code sync processes had pause and resume options. wget has it, why not gclient/git?
Anyhow, all the code finally came down at around 1:40 am. Of course, I had to build it right then, so after some more consulting of multiple documents, I fired off the build commands. A full 1.5 hours later, I was the proud owner of a self-built version of node-webkit. The process completely maxed out all 4 cpus on my mac for the majority of the time, which I spent browsing the ninja build tool manual. Of course, it was almost finished by the time I'd reached the part on how to control the number of cpu's to allow for ninja's use :). The mac, however, performed admirably under stress, I must say. The rest of the running processes were still very usable and the terminal itself was still responsive. Not the same experience on a Windows or linux box, in my experience.

In all, time well spent; and catharsis for disappointments from the past. I might just run the build commands for Chromium next.

And once I've patched up with the spouse, I might even try getting it to run on Windows with VS Express!

Code as you think

I was in the middle of deciding how to proceed with my current side project when I realized that I'd not yet created an architectural description for it. Since I already have an architecture description tool that I wrote, I have no excuse for not writing one out. So I stopped to think why I didn't create an architecture definition first. Ans: Because it would stop me from doing what I was doing right then, which was to decide:

  • how to separate out the current spike of the language from its sample code and actions.
  • how this will be deployed in and of itself, ie how to dogfood it?
  • how to move from the spike folder to the actual folder
  • how to move from bitbucket(where I'm keeping all this stuff till its public-worthy) to github or a public bitbucket repo (where I expect this to be shared with the world)
  • ...all in the middle of adding commit messages for changes
  • while juggling code between the PC and the mac
  • ... and so on.

As I'm writing this, more thoughts are streaming through, and they're all jumbled together: code ideas, architecture ideas, documentation, behind-the-scenes reasons, journal entries - all in one single stream of consciousness. Stopping now to create an architecture definition would not just slow me down, it would take me down a totally different path. And I don't want to go down that path because the IDEAS ARE JUST FLOWING!

Another reason I didn't want to context switch into "architecture definition mode" was the high cost of that switch : create a new document, decide where to save it, type in the actual content, optionally see how it looks once the markdown becomes html and so forth. IMO, this is also why documentation is out-of-date with code, especially expository documentation like architecture and design docs. The comment-above-code kind of documentation may still be in touch with the reality of the code, but higher level documentation like READMEs and user guides quickly become disconnected from the code they're talking about.

That's when it hit me: What we need are tools and languages that understand the stream-of-consiousness way of building software: code snippets flying into the system from the human mind along with documentation and random thoughts and todos and reorganizations of such thoughts - all of which the system will record in sequence and generate meaningful views out of. 

Imagine an editor that:
  • Allows creation of content without the need to pick a name or a location for it.
  • Knows enough about the content to provide appropriate editing affordances - syntax highlighting, preview, whatever.
  • ... and autosaves it for you - no separate save step required
  • ... then allows tagging it as being "of a particular type"... whatever that means to you
  • ... then allows you to seamlessly retag it differently
  • ... including being able to arrange it in hierarchies (if that made sense) or graphs (ie nodes and links - if that made better sense)
  • Presents all existing content and its associated "tag graph"
  • Allows linking content with each other
  • ... or even parts of content with each other.
  • Shows the links visibly
  • Allows tagging parts of a document as being of a different tag, but still housed in the source document. Content tagged thus will be displayed in both tagged content, but the second display will be a reference to the original.
  • Tracks all changes to the content graph in a stream-of-consciousness journal that's visible and accessible at all times so that you can see what you did before in the order that you did it.
  • Allows you to add your own manual entries to the journal to track your thoughts at that point in time.
Such an editor could be used to make the context switches mentioned above as seamless as possible. The only bit of automation it promises is the decidedly "big brother"-like journal, but in my opinion that's something the computer should do for us - track what we're doing automatically so we can look back and "see the trace of our thoughts from before in our actions". Features like seamless switching allows easy creation of design, code, comments  and code in back-n-forth style, for example; while the ability to link content allows for todos to be linked to the point in code where change is required, but still can be maintained as a separate list of todos for easy review.

To allow easy adoption, such an editor should add the following:
  • Treat an existing directory structure as the basis for its tags: folders become tags, folder structures become hierarchical tags, files become fully described hierarchical tags. If starting from a blank folder, however, allow for the initial tagged content to remain as files until the user discovers the "natural order of things" for himself.
  • Seamlessly convert files to folders when the user renames them.
  • Save the changes to the underlying folder as soon as possible so that there's no "last minute unsaved content change"
  • Allow for some scripting/automation triggered by content changes.
UI Design Notes:
  • Start the editor from a particular dir, which we'll call <dir> in these notes. The startup sequence allows choosing the default language to use optionally, else the default is text.
  • The editor starts with two windows: a default one titled "<dir>" and the journal titled "stream". The former is editable, the latter is read-only. 
  • The default window is "in" the default language (if chosen), ie is syntax highlighted for that language. Typing text into it and hitting enter causes text to show up like any editor, but it also causes the same text to show up in the stream window with a date/time stamp. Internally, the text in the stream window is a reference to the line in the original window, not a copy of its contents. In the background, all the text changes are saved back to <dir>.
  • Typing F2 allows you to rename the window's title, which is also its tag. The editor allows creation of hierarchical tags like "tag1/tag2/tag3". It also allows setting the language of the content by naming the tag with the format "tag.type" - similar to how files are named today.
  • Typing an esc puts you into "enter a tag" mode. a small edit area (or vim/emacs-style command area) shows up which allows you to type in the name of a tag such as "todo" or "comment" or whatever. hit enter when done and two things happen: the edit area disappears and a new window titled with the tag just entered shows up and focus moves to that window. Type text and hit enter to enter content in this mode, while it also appears the stream window like before. if the tag is already present, focus shifts to the existing window for that tag and text input proceeds from there.
  • Selecting text and then pressing esc to select a tag will leave the text in the original window, but add that text to the window corresponding to the chosen tag (via reference again), as well as denote that the tagging event occured in the stream window. Presssing ctrl-esc instead of esc will cause the text to be moved to the tag chosen.
  • Ctrl-tab will cycle through all open windows and allow you to make any window the main one. The same esc and enter behavior holds for all windows.
  • Everything is save-as-you-type. No ctrl-s required. The tag is the name of the content.
More features:
  • Windows are tiled, not free. this allows pinning of windows to specific locations so as to create familiar screen layouts.
  • A third kind of window is a modal window, which can be in input or output mode. this will allow creation of repls. issue a command when its in input mode and view results when its in output mode, which is read-only. The "stream" window can also be recast as a modal window, allowing journal entries in input mode.

Ok, that was the easy part. What about a s-o-c language?

Such a language would:

  • Allow for programs to be expressed one chunk at a time. The language runtime could be invoked at any time during the expression, at which event the runtime would evaluate the current set of chunks and determine if it can do anything with it. If the runtime is a compiler, it would decide if object code can be generated or not; and if its an interpreter, it would interpret the chunks available.
  • Not have comments. Instead it would allow a more generic interpretation of commented content as "chunks from another language embedded within itself, which could be "understood" or "translated to itself" given an appropriate cross-interpreter/compiler.
  • Allow chunks to be linked to each other and handle link lifecycle events. Eg: chunk A is related to chunk B could imply that if A changes, B should also change; thus flag such changes on A as requiring changes in B as well. Or, if chunk A is deleted, chunk B should be deleted as well because it doesnt make sense to keep it around anymore. Or, if chunk A is created, a corresponding chunk B MUST be created.
More thoughts on the language TBD.

Implementation Notes
Editor:
  • Use node-webkit, codemirror and sharejs to allow evented entry of text
  • Make a repl using a bot that's sitting at the other end of a sharejs connection.
WIP notes

Started work on a prototype using node-webkit. A basic version of the UI Design has been implemented, and the updated version of this post reflects some experiences from this implementation.

Saturday, March 09, 2013

bash tip: setting terminal tab title programatically

This one has been annoying me for quite a while - looking at the string of tabs in the mac's Terminal App, all of them titled "bash" except for the one trying to download webkit which is usefully titled "git".

So I finally decided to do something about it, namely google the solution. Here're the results:

As a bonus, the cd() function adds the ability to change the title to whatever directory you currently are on - which works just fine when you're in your projects directory :)

I think this should work on Linux as well; confirmation TBD.


Sunday, March 03, 2013

The Ultimate Personal Task Manager

I've been prototyping a GDoc-based 43 folders for a few weeks now. The biggest two problems I have to date are:

  • the ease with which I miss my daily review of things to do
  • "Too much trees, too less forest". I need a dashboard that's higher than the daily, ground level view
In a fit of frustration about the second point (cos there's no point fretting about the first:) ), I set about designing the ideal personal task management system - once again. Here's the result:

The Ultimate Personal Task Manager needs:
  1. The open task list: which contains all tasks that are to be started or WIP. Routine/repetitive tasks are represented as new open tasks for the next instance when the current one is completed.
  2. The review/decide process: which reviews current status and decides what to do next.
  3. The todo list: which contains tasks that have been decided upon, and will be acted on in a particular time period - day/week/month/whatever. <==> 43 folders. no sequencing, just "these tasks mush happen within this period or before this milestone"
  4. The plan: sequenced list of tasks. <==> day planner. contains time slots when things will be done
  5. The dashboard: "dont break the chain" style display of only top level projects. ideally this should be the top 5 things you care about in life shown as a red/yellow/green style view
  6. The nagger: Most important piece for procrastinators. the physical reminder to actually use this system. could be a phone reminder system or a spouse/friend. should know what your frequency to run the decision process is and nag you to do it.
Key point about this system: It could be all in your head or on paper/pencil or software

Yes, this is pretty close to GTD. The additions are the dashboard and the nagger. 

If implemented as software it also needs to:
  1. Work offline
  2. Works across OSs and systems
  3. Allow versioning
Software implementation notes:
- Something that works offline and universally is required. simplest i've seen to date is gina trapani's todo.txt. Using it, the functional requirements:
- #1 & 3 are built in.  Use 'repeat' addon for sub point under 1
- #2 and 6 are human tasks anyway.
- #4 and #5 will need additional dev. In particular #5 will require (at least for me) enhancing the project field to a tree of projects. Some simple testing with bash showed that a format like "proj1/sub1/sub11" will work, as will "proj1:sub1:sub11"

  The non functionals have direct answers:
  - it works offline and across OSs - being text and a shell script
  - putting it in a git repo will handle versioning

- Idea: Create an Outlook plugin to auto convert mail into tasks
- how to run cygwin bash from windows? ans: Cygwin's run command
- how to create an outlook plugin? TBD

Friday, March 01, 2013

Groovy DSL Voodoo... or why I think imperative programming makes more evolutionary sense

I recently had to consider the Groovy space for a project proposal as the client had decided on Groovy/Grails as the platform of choice. While evaluating the platform for the proposal, I naturally gravitated towards Groovy's DSL capabilities and started thinking about using it for my personal projects, obviously. Abu seems like a natural fit (why didnt I think of Groovy before, I wonder? I'd hit a wall with JRuby due to generics anyway); as did Jack.

Anyhoo, with all this background, I hit slideshare and found tons of decks from the language leads on the specific topic of DSLs. One example piqued my interest in particular: slide 106 of Paul King's deck, which I've replicated here as a gist:


I wanted to both understand how this worked and to replicate it by myself. Here's all the flailing I went about in trying to achieve those two goals:

As you can see, I failed miserably. My last trial had a near-working version, but left me completely disillusioned about Groovy's DSL capabilities - especially considering I came out of the process feeling that all the work was done by the single 'of' closure with the rest playing dummies to the Groovy language's optional syntax rules - especially because in my Englishy version, you could switch the order of the closures passed into 'of' and still have it work fine.

However, all of this didn't explain the "extra code" in the original, which left me with the nagging feeling that no language author would be trying to pull this much wool over people's eyes. So I went back and expanded the original expressions like so:

Now it made much better sense.

Mind you, I still haven't figured out how you go from a problem statement like "I want to express the ability to compute square roots in an English-y fashion" to the solution presented above. This is as far as I can get:
  1. I'll obviously need a way to call Math.sqrt and then print it. This needs to be a function name that's english-y
  2. An englishy description could be something like "Show the square root of 100". Using Groovy's existing rules, that makes "of" the candidate for the function name.
  3. How now do we make the rest of the words work? Well, "show" and "square root" are exactly the two actions to be taken. So as long as I can define those as functions and compose them, I'm good.
  4. How do I pass in the functions without naming them?
Obviously, its all the baggage of years of imperative programming knowledge holding me back. Somebody with more skill in functional programming might find this the intuitive enough to roll out.

But I have to wonder: There's too much magic going on here. The imperative approach to the stated requirement would be to define a grammar, write a parser and allow actual interpretation of such a language. Painstaking and error prone, sure; but explicit and clearly out of the programmer's head and into a language that is so dumb that there's no doubt as to what's happening.

This sounds like I'm propounding Worse Is Better in other words,  but there's something more: I realized that the cognitive overload required to understand the Groovy version is higher. More importantly, the cognitive overload to retain that understanding over time is even more so - for "normal" developers who have not walked the functional way for very long. That's the majority in today's world, at least.

More insidious, however, is the implied promise that this is real; that the Groovy DSL is actually English. Could I, for example, expect the slightly less polite "show the square_root of 100" to work? Or the even curt "square_root of 100"?  As an English speaker, why would I not?

As a programmer, I see why 'please' and 'the' are the required glue to make the english-y sentence work within Groovy's pretend-English world. Its extensible in that you could replace square_root with cube_root, for example; but not so that you could change the grammar of the sentence itself. That would require a different set of closures, like the ones you'd find in slide 105 of the same deck, for example. Note that in this version its 'the()' that is the active closure. But I fail to see why this should prevent me from expressing myself naturally as an English speaker.

This then, IMO, is the larger problem with DSLs. When you make something like its real-world counterpart, the human mind immediately taps into the huge body of latent real-world knowledge and tries to use it with that thing: although this DSL doesnt promise it, I immediately wanted to use English structure on it. It's all fine that your programming language has risen to talk your user's language, but has it captured enough of the user's world to go beyond "training wheel use"? To paraphrase Carl Sagan,: To make an apple pie DSL, you must make a universe that's up to scratch

How will the DSL author handle this? In general, not very well, I think. I realize I'm picking on a toy example here, but on extrapolation I cannot imagine a domain where all possible concepts and all of their possible combinations are easily enumerated; and then retain their meaning over time and across minds.

I begin to wonder then, at attempts like the VPRI's FONC, where one of the overarching ideas seems to be to create a multitude of DSLs to produce an OS in under ~20 KLOC; and at feeble attempts like my vaporware designs of Jack and Fluent: would they build a better world or is the imperative code bloat of Windows and Linux the more sustainable way?

Thursday, February 14, 2013

JMeter as a webapp

I've long felt that it might be a good idea to create a web-based controller for JMeter. JMeter has been and still is a good tool for performance testing. Its Swing-based UI, however, has always been a bit of an eyesore and IIRC a memory hog. The one interesting behavior it has, however, is "save on tab", ie any data you type is automatically saved when you tab out of the control. Of course, the save happens to memory, so you still have to Ctrl-s to actually save. And then there's the "feature" of saving any chosen node as a new file. Why, I'll never know.

Anyhoo, my idea is to create a webapp version of the JMeter UI. The possibilities are interesting:

  • Even a straight copy of the existing design should right away make a JMeter instance accessible via the intra/internet. Add features to actually kick off performance runs and you have a saucelabs equivalent for performance.
  • If instead we tweaked the UX a bit and actually model the Performance testing workflow (which, btw, the JMeter XML supports inherently), the result could be vastly better. Create the test run workbench separate from actual runs, show reports as a separate view instead of as attached nodes, and so forth.

Sunday, February 10, 2013

Explicit Language constructs for architectural concepts

You know how we have modules, layers and environments for code but none of these concepts are actually IN the language?

Modules are typically self contained chunks of code that expose an interface to some useful logic. It is not important how it does what it does; but it IS important that we be able to find the module and call it. In most OO languages, we use functions or object/class methods to hold such logic, but then have to actually build the concept of module using user-visible mechanisms.

Layers are another conceptual tool for organizing code. This typically reduces to packages or namespaces, but neither of these concepts actually enforce a hierarchy or "can/cant call" rules. Similarly, it would make great sense for dependencies themselves to be layered this way, but no language that supports imports also supports defining the layer for those dependencies.

Environments - which I mean the container or context in which code runs - are similarly underspecified.   Most languages define a main entry point and are call it done. Why not have a generic way of stating an entry point that includes a declaration of the environment (or even environments - plural)? The declaration of environment allows for the actual standup of said environment and trigger of the main code to be separated from the code itself; while the ability to declare that "this code runs in both gui and cli environments", for example, allows explicit declaration of such purity in the code and allows determining if this is true statically.

Well, this idea is to explicitly add those concepts to the language syntax itself.

The idea is that the implementation explicitly states the architecture assumed. Two advantages:

  • The intended architecture is explicitly available to future developers
  • Tools can be brought to bear on code directly, maybe even in the language
Of course, this does mean that the language knows only about specific types of organizing code. Within that limitation, however, things are much more clear, IMO.

Monday, January 14, 2013

Excel as a UI Mockup tool

I just finished using Excel as a UI Mockup tool and am amazed at just how usable it was.

More (with pictures, tips and techniques) when my left index finger is out of the bandage.

"Whose Turn?" App

This idea is from a recent outing of 3 couples with kids under six:

A Phone app that tells whose turn it is to change diaper/ deal with the lil monsters / feed them / whatever.

You choose the activity, it keeps score and tells you whose turn it is.
Once you're done you say you did it, and it updates the score.

Bonus points for doing things out of turn is a configurable setting :)

Tuesday, December 04, 2012

An agent-based parser for a structural IDE

I had been thinking about the difference between text editing and structured editing and it dawned upon me that the latter will never win simply because it is not "natural" to edit structurally and that such editing is not forgiving of "mistakes". Sadly, text editing is good by default; and structured editing is not so by design.

We have a grammar, so we use it. But do grammars have to be policemen all the time? After all, we humans created grammar; and I have to think that we created it by convention to make sense of the otherwise chaotic barrage of communicative sounds we invented. So if natural language grammar is intended to be "guidelines and lighthouses to the islands of information in the oceans of noise", why shouldn't computer language grammar be the same?

The problem, of course, is that such a grammar would be non-deterministic. How would you specify a terminal symbol with any kind of certainty when any possible other symbol could intervene and has to be considered noise in a very context-sensitive way?

I wonder if there's an other way; and the rest of this post will record my thoughts to date on this other way.

Imagine each symbol of the language's alphabet as a cell waiting for user input. Imagine each non-terminal in the language's grammar also as a similar cell, only it waits for symbols to activate.The moment a symbol appears in the input (this could be the read of the next symbol from a file or the next key pressed by the user) the symbol grabs it and announces that its now "active". This triggers "interested" non-terminals to claim that symbol as part of themselves, although the ownership is shared - until all symbols of a particular non-terminal are satisfied and it claims all symbols to itself; and announces that it is active. This triggers the next level of non-terminals to wake up, and so forth.

This sounds pretty close to how Agent-based systems work, hence the term in the title. If I were Microsoft, I'd probably call it ActiveParsingTM.

The key advantage with such parsing would be that ambiguous input could be handled by the system. Also, input that doesn't match any production rule in the grammar would still be allowed into the system; which means that erroneous user input is tolerated, not berated.

In addition, such a system would be incremental from the ground up: although it is backed by a grammar, input is not constrained to "start at the top and end at the bottom of the grammar". It is also inherently event-driven (see design notes below) and therefore should be able to react to editing actions better. This ties in well with "natural" structural editing.

Finally, such a system would allow for hybrid languages that embed other languages within themselves, eg HTML+CSS+JS.

I cannot imagine that this hasn't been thought of before, as always. My Goog-fu not being upto snuff, however, I was not able to ferret up anything concrete. Of course, I did find a lot of references in the NLP literature to agent based systems and automata based parsers and such like, but they usually devolved into stats or deep math to prove the value which I couldn't comprehend.

Design Notes

  • The system works on heartbeats called ticks. Everything happens once every one tick.
  • There are cells. Cells wait for external input. All cells are guaranteed to get a new datum input into the system within the same tick. Cells activate (or not) during that same tick for a particular datum. Cell activate recognizes a single symbol or character.
  • There are cells that wait on other cells for input. These cells  activate when all the cells they need are activated. Their activation recognizes a token or non-terminal.
  • The input could be control input (such as the delete key) as well. This would result in previously activated cells becoming deactivated, changing the state of the system. The impact would be felt in the system over the next few ticks, but also means that it would be local to only those parts of the grammar that are indeed affected by the change, not universal as is typical in standard parsing systems.
  • At all levels, activation triggers an event that can be handled outside the system. In particular, recognition of a non-terminal could be handled as highlighting it as a known keyword or identifier, etc. This is how syntax highlighting would happen
  • At a sufficiently high level, activation of a non-terminal means something larger than syntax highlighting, eg, validation, interpretation/compilation or execution can happen.
  • Finally, all cells can be supplied with a prerequisite activation signal which would HAVE to be "on" for them to become on. This would allow controlling the "viewport" of visible cells easily enough to constrain the calculation to that part of the text that is visible.
Update
Found it! An undated paper about Object Oriented Parallel Parsing for Context-free Grammars. Although I couldnt find a date on it, references to Symbolic Lisp machines dates it to at least the 90s if not the 80s. Google search terms "parallel parsing computer language" 

Thursday, November 29, 2012

Idea: Email + Document Server in a box

I dont yet have a good name for this concept, but here's the idea anyway:

You know a lot of good ideas are better put in an email instead of a separate document because people will not open that attachment?

What if you could actually then easily extract out such content and make it available as a document? Further, what if the original recipients of your email continue to see it as an email, but it has a separate life as a document?

This is what I mean by the Email server being a document server as well. Each email could contain multiple such documents; or each email could itself be a document. The inline vs attachment line is blurred, but at the same time, individual bits within emails become addressable entities outside of the email thread.

Right now, we save such emails, re-format them as documents and stick them in a wiki or sharepoint. What if the Email server did all this for us?