Live data from Hacker News

Learning to code kept me sane when I was a diplomat

vikparuchuri.com

21–30 of 51 posts

Re: Learning to code kept me sane when I was a diplomat

#21

Before you knock on "writing code that clicks things" remember that on Windows clicking things is the primary if not solitary interface to most of the system. Even the administrative interfaces are secondary to the visual interface. A lot of programs don't offer an API available to outside processes. The most important thing about any program is correctness: does it work and do what it is supposed to do. The only thi…

For the server versions, Windows finally leaves this path, making PowerShell (that admittedly also takes some getting used to) a first class configuration system. You even can do something in the GUI and then check in a log what PowerShell commands were executed under the hood.

Re: Learning to code kept me sane when I was a diplomat

#22
Oof. Had a hilariously similar experience doing data entry at my first internship, which was at a financial services firm.

I knew nothing about programming, but I had taken an intro stats class that had a few assignments in R. A super simple R script did half of my day's work in seconds (plus some debugging because of course I did next to no error handling).

In retrospect, I've realized that if I knew a thing of two about regular expressions at the time, I would have been able to automate my whole summer internship.

So it goes.

Re: Learning to code kept me sane when I was a diplomat

#23

This is a fantastic article and illustrates a HUGE problem in government systems, where data gets aggregated, but not associated.

A few years ago I had a brain-numbingly monotonous "navigate here" then "click here" then "record output here" type job. Unfortunately, mine was on a military base and the "record output here" was an Access database. I tried to automate the whole process in Access, but military restrictions prevented me from automating most of the process.

Re: Learning to code kept me sane when I was a diplomat

#24
I haven't seen much discussion of a more ideal way to solve this problem (to say: as a one-off like the author was doing, not reusable software), so I thought I'd just think about how I'd do something similar.

Luckily there are libraries that are great at interacting with a web page or multiple pages at the same time without needing to actually have a browser instance open. There's selenium and its various scripting environments, which are meant for browser testing but work just fine for many automation tasks: http://www.seleniumhq.org/

And, newer, are headless technologies like phantom.js: http://phantomjs.org/ and Dalek.js: http://dalekjs.com/

This is SO much easier than using Javascript to find purple links on a page, and so much more reliable.

He could have looked up each link on DB1, then used the data to look up the DB2 information.

In any case, what he did saved him hours and hours of time and started him on a lifelong interest in programming.

Also, obligatory relevant XKCD's: http://xkcd.com/1319/ & http://xkcd.com/1205/

Re: Learning to code kept me sane when I was a diplomat

#25
post #16

Earlier quoted context omitted.

Just to clarify, we weren't accessing any Guyanese databases. And as far as I know, nothing illegal was going on.

How else could you then search for the criminal history of Guyanese citizens? Did the Guyanese government push all their data to the US?

I presume they were looking through criminal records in the US, not Guyana.

Re: Learning to code kept me sane when I was a diplomat

#26
This is a really great post. For me, the recurring theme is knowing what's possible.

From a class he took in high school, Vik knew that some sort of automation was possible. That spurred some reading and exploration, which led to some success.

Success led to thinking about other opportunities for automation and more exploration of what's possible, which in turn led to more success.

To me, it absolutely doesn't matter that things could have been done in other ways. Nothing to cringe about here. A developer can only use approaches that he/she knows or suspects are possible.

In the day-to-day work of a developer, knowing what's possible is perhaps the most important thing. Anything else can be googled.

Re: Learning to code kept me sane when I was a diplomat

#27
post #21

Before you knock on "writing code that clicks things" remember that on Windows clicking things is the primary if not solitary interface to most of the system. Even the administrative interfaces are secondary to the visual interface. A lot of programs don't offer an API available to outside processes. The most important thing about any program is correctness: does it work and do what it is supposed to do. The only thi…

For the server versions, Windows finally leaves this path, making PowerShell (that admittedly also takes some getting used to) a first class configuration system. You even can do something in the GUI and then check in a log what PowerShell commands were executed under the hood.

From which version of Server? Where does the log go? I have a use for this.

Re: Learning to code kept me sane when I was a diplomat

#28
post #7

> I decided to write a program that clicked on things. I cringed a little. I'm glad he's learned enough to know now that this is not the right approach.

I cringed too, but then I realized this is probably the best way to start out. It's only a 'problem' because it's a bit more glue code (but less 'figuring things out' time). The only truly cringey part is not knowing about CSV!

that said, CSV is not without its own problems - i mean, it's not well defined. if you're down to automate a bunch of windows programs by moving around the cursor programatically and faking keyboard events, using excel over ODBC is far from cringey.

Re: Learning to code kept me sane when I was a diplomat

#29
this reminds me of when i started to code - find the first solution to the problem that comes to mind and hack it until it works, even if was something as abstruse as manipulating the UI. of course the outcomes were incredibly fragile and broke at the first possible moment, but in the end they still did the job they were supposed to do most of the time.

today i couldn't do that anymore; i've grown too uptight to try any of those inefficient "solutions". i guess i'd rather give up and admit defeat if there were no APIs or passable hacks (i'd say using phantom.js would be a passable hack) i could work with than solve the problems this way.

i'm usually unable to follow the advice given by the xkcd automatisation timetable described here: http://xkcd.com/1205/ "is it worth the time?" - if a dirty hack is destined to run more often than once, i just have to make it passably elegant, readable and efficient. i'm sure nine out of ten times the effort is pretty much wasted.

i guess i've just grown old.

Re: Learning to code kept me sane when I was a diplomat

#30
post #3

The article shows an interesting illustration of the disconnect between programmers and normal computer users. Like the author says at the beginning, any experienced developer knows that automating interaction with a GUI is a crazy idea. It's a painful, fragile way to move data around. But to the author and anyone who's done data entry, it's an improvement to their workday that demonstrates the power of programming.…

I'd be interested in seeing an accompanying article by the author or another developer laying out how you would solve the same problem if you were an "experienced" developer; I have done a little of the same type of programming at my job, and a side-by-side comparison of the 'novice' and 'pro' approach would be extremely helpful.
Post reply on HN