Avengers

I have been waiting for this movie since 2009. Actually, scratch that – since 2007 and it was worth it. I don’t have to tell you that Marvel’s grand experiment in bringing the comic book shared continuity concept to the silver screen was an astounding success. The box office figures speak for themselves: it was the biggest opening weekend since forever. Not only that, the movie continues earning barrels of cash nearly two weeks after release. I went to see it last Saturday and luckily got ticked long in advance, because by the time we got to the theater all Avengers time slots were already sold out. This movie was a tremendous risk – if it bombed it could prematurely end the great superhero boom we are currently experiencing. Fortunately, the exact opposite happened: Avengers is a living proof that shared continuity superhero team-ups can, and do work. Not only that – they are the golden meal ticket that studios have been waiting for: a long running franchises that can be milked indefinitely, and which can amortize weaker movies by incorporating them into a grander over-arcing plots. It’s a magical formula for printing money – and good news for comic book nerds all over.

When Joss Whedon was announced as the mastermind behind this project, many people wondered if he can handle something of this magnitude. Can a guy mostly known for creating beloved, but unfortunately short lived TV shows carry the biggest and most important summer blockbuster in recent years? The answer is yes. Weedon was the best choice. The only choice. Having watched the movie, I do not think anyone else could have directed this film. Not only because he understands the genre – because he really does. When I was watching Avengers, I felt as if Whedon took that itemized list I made in 2007 and nailed every single point on it. Hell, he did things I did not even think about back then. He clearly studied all the Marvel movie ventures to this date, and drew conclusions from their mistakes, electing not to repeat any of them. But that’s not the only reason why he was the best person to make this film.

Unlike most screen writers and directors that work on summer-time popcorn flicks, Joss understands characters. Avengers had to be about characters – the heroes had to have chemistry and work well together for this entire venture to work. You can’t just say they are a team – the audience has to see them become a team, and believe it. This is something Whedon does very well – all his creations to date had really great ensemble casts of characters, and most of them were telling character driven stories.

Most of the movies that led up to the Avengers were plot driven. Thor, Captain America and Hulk were all concerned with telling compelling stories. The heroes were there, mostly just tagging along for a ride – tugged along here or there as the plot demanded. Iron Man movies were a notable exception, mostly because they were Robert Downey Junior driven productions – half improvised, half adlibbed mess that was carried by the undeniable charm and personality of the leading man. The Avengers movie was different. Joss Whedon did not start with a plot – he started with characters.

The Avengers

The Avengers

All the members of the team are introduced, fleshed out, given motivation and the plot is more or less the function of the sum of their goals, motivations and personal agendas which collide and intersect with each other. Even though this is a movie about super-hero team-up, for most of the movie there is no team – just bunch of guys with bigger-than-life egos bickering about nonsense. But when they finally work out their differences and start working together, it does not feel forced or rushed.

Whedon understands the source material, and he seems to have a great feel for what the characters should be, and how they fit into the story. He carefully cherry picked what worked from each characters respective movie and dropped what did not. For example, Iron Man and Captain America are mostly intact – their characterization is consistent with what we had seen before. Thor and Hulk however have been revamped.

The former is no longer the brash, foolish, naive spoiled brat – he is more mature, wiser and more balanced and more responsible as you would expect from a god of thunder. This is a very welcome change – the child-like, infantile Thor was rather annoying, albeit necessary to tell the morality tale / coming of age story of his own movie. Now he is sent back to Earth as an adult, and a powerful agent and ambassador of his people. He is still proud and short tempered but no longer a fish out of water. Whedon gives him a new niche, as he chose to have the time-displaced Steve Rogers to play the “stranger in strange land” fiddle this time around.

Going into Avengers I was really expecting to see Thor and Tony Stark get in a pissing match, because the movie seemed to be only big enough for one dude with grossly overblown ego. But such a petty squabble turns out the be beneath Whedon’s much improved Thor. Instead Stark’s rampant individualism and egoism crashes with Steve Roger’s patriotic ideals and military discipline – a much more interesting conflict to watch.

The Hulk was rebuilt from ground up – it had to be, since Ed Norton did not come back to reprise his role as Bruce Banner. This actually turns out the be a good thing, as Mark Ruffalo’s interpretation is much more interesting. His Banner is much geekier and much more nuanced character. Norton’s character had a deer-in-headlights quality to him – he mostly reacted to plot cues, and came off a bit whiny. Ruffalo’s character is sharper and more confident. He is passive aggressive, manipulative, resentful – a polar opposite of Tony Stark, but at the same time his intellectual equal. What I liked the most about this character is that Ruffalo is able to play a laid back, goofy Banner while at the same time giving him this quiet undercurrent of soft boiling rage. He is a man balancing on the knife edge and fighting real hard to maintain his mellow demeanor against all odds.

When he turns into Hulk, he becomes an unstoppable force of nature. The big green guy has starred in several movies and TV shows up until now, but Whedon is the first director who has absolutely nailed the essence of this beast. The way he moves, the effortless way in which he smashes and dominates even the strongest opponents – this is the Hulk we have been waiting to see for years.

The difference between Joss Whedon and other directors who handled Marvel Properties is that he can take such non-characters as Scarlett Johanson’s Black Widow, and Jeremy Renner’s Hawkeye and turn them into fully fleshed out members of the team. Despite considerable amount of screen time in Iron Man 2, Johanson’s character was nothing more than eye candy. Whedon needs exactly 5 minutes to establish and build her up as a devious, manipulating super-spy with strong work ethic and personal goals and motivations. Her subplot non-pairing with fellow agent hawk-eye is refreshing, but at the same time very Whedonesque – they owe each other their lives, and they obviously have some history and some pent-up sexual tension but they do not immediately fall into each others arms, but instead opt for professional camaraderie.

Finally, Whedon has a knack for writing and directing villains that are goofy and bad-ass at the same time. Loki was a complete wuss, and a push-over on Thor. I just did not believe he could make a compelling villain in Avengers, but Joss pulled it off. He builds upon his characterization from the previous movie, but not without giving him a moment to shine. When Loki first appears, he instantly wipes out an entire room full of armed Shield agents without breaking a sweat, just to establish him as a credible threat. Next we see him take few pages from the Joker’s notebook, establishing himself as a complete and utter bastard who likes to play mind games with his victims. By the time the heroes get to fight him, the audiences already managed to forget how much of a pussy he was in Thor.

Whedon did an absolutely amazing job on this movie, and his cast delivered great performances each. Does this mean Avengers is a perfect movie? No, it’s not. At the end of the day, it is a silly summer popcorn flick. It is not high brow entertainment, but it is damn entertaining. In my honest opinion this is the best installment in the entire series. Better than The Incredible Hulk, better than Thor, better than Captain America and better than both Iron Man movies. This is how summer blockbusters ought to be done.

Posted in movies | Tagged | 4 Comments

Scripting Windows the Unix Way

Sometimes you gots to script windows. If it’s my personal rig I usually just use Cygwin because that’s where all the tools I need reside on Windows boxen. Either that or I just hack in Python which became my replacement for Perl after I went back and tried to read a 3 year old Perl script that broke. I know that code clarity depends on a programmer – and I’m very good at being sloppy in every language I know, but my shitty Python code is marginally more readable than my shitty Perl from that period in my life when I decided I’m really good at regular expressions.

But this is not about scripting for myself. This is about writing scripts that could possibly work on some limited range of machines that won’t have Perl, Python or Cygwin installed because they are operated by functional halfwits. More or less, the typical use case works like this – and end user walks in with a computer in tow and goes:

“Yo, my shit is all retarded.”

At that point your job is to un-retard his shit, whatever that might mean. Actually, what it usually means is that they changed, deleted or misplaced something. The usual procedure is to make them download and run bunch of installers, reset their home pages and re-jiggle their thingymabobs. This could be done by hand, but it is usually tedious. I have already created a tool that does a lot of such tedious work for me. While said tool became an indispensable asset for me, I try to keep it a generalized, all purpose tool – a Swiss Army Knife of sorts. I needed a set of specialized scripts that would parse, change, delete, download and run files to do some very specific tasks. Tasks that may periodically change – where periodically is defined as “more often than I would want to compile the damn code”.

Most of the time, you would probably do this sort of shit in VBScript. Before Powershell was a thing, VBScript was the go-to scripting language on Windows. It still is, seeing how it is not installed by default on Windows XP which is still on roughly half of the machines I have to deal with. The problem with VBScript is that it is a shitty language – and a verbose one too.

Let me give you an example – when I’m on Linux, Unix, Cygwin or a Mac, and I need to download a file from the interwebs, all I need to do is:

wget http://example.com/somefile.zip

In VBScript this is slightly more complicated:

URL="http://example.com/somefile.zip"
saveTo = "c:\some\folder\somefile.zip"
 
Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
objXMLHTTP.open "GET", URL, false
objXMLHTTP.send()
 
If objXMLHTTP.Status = 200 Then
   Set objADOStream = CreateObject("ADODB.Stream")
   objADOStream.Open
   objADOStream.Type = 1 'adTypeBinary

   objADOStream.Write objXMLHTTP.ResponseBody
   objADOStream.Position = 0 'Set the stream position to the start

   Set objFSO = Createobject("Scripting.FileSystemObject")
   If objFSO.Fileexists(saveTo) Then objFSO.DeleteFile saveTo
   Set objFSO = Nothing
 
   objADOStream.SaveToFile saveTo
   objADOStream.Close
   Set objADOStream = Nothing
End if

Or something along these lines. I actually did not test this – I shamelessly lifted the code from here. I just don’t care enough to actually make sure it’s correct – if it’s wrong, then it’s wrong. Don’t use that code. I guess what I’m saying here is that VBS is a shitty general purpose programming language that can be used for scripting, but it ain’t pretty. It was designed by people and for people who thought that Visual Basic was a good idea and it shows. Unix shell on the other hand is an elegant command line environment with a smorgasbord of nifty tools that work beautifully out of the box. Tools that are self contained, mature, tested and follow the unix philosophy of doing just one thing, but doing it well.

While the script above may poorly imitate a fraction of functionality of wget, but is flimsy, ugly and pain in the ass to maintain. It may solve one problem (downloading files from the internet) but wget is not the only tool I would like to use on a daily basis. There is abut a dozen of other GNU utilities that I wold like to have on Windows: sed, grep, diff, patch, head, tail, touch – just to name a few. All extremely useful, all nontrivial to re-create functionality-wise in VBScript.

For example – why spend an hour fiddling with VBS string processing functions and end up with about a 100 lines of unspeakably ugly code (90% of which is boilerplate and padding) if you could write 4 regular expressions and feed them to sed to accomplish the same thing. Granted, regexps are unspeakably ugly in themselves most of the time, but it’s still 90% less ugly per volume if you think about it.

The standard windows scripting environment (cmd.exe) is less verbose and more like unix shell in some aspects. It’s unfortunate that it is hampered by it’s syntax, and a very limited set of utilites. Powershell is much better in this aspect, but it is both more verbose and vb like and not as ubiquitous.

If you could only somehow “borrow” bunch of GNU shell utilities and bundle them with your standard Windows batch scripts, you could actually have quite a powerful tool at your heads. And I’m not talking about Cygwin. Yes, it is nice but often you don’t want the whole kit and caboodle – a separate shell with it’s own set of environmental variables, it’s own filesystem hierarchy is an overkill for a lot of task. Ideally you’d just want cherry pick select utilities – for example, if your script only needs sed and wget, then you would only include these.

Some time ago, I have discovered an old, but still somewhat relevant project called Unix Utils. It’s aim is basically to create dependency free Windows ports of all the core Unix utilities. The package ships with a rudimentary shell (sh.exe) but the tools in the usr/local/wbin are actually completely portable. You can extract the entire package, take out wget.exe, drop it in the same directory as your batch script and it will work.

The downside of this method is that it creates dependencies for your script. If you distribute it via email, you need to include all the external GNU executables with it. This is a problem, since your average office drone can’t be trusted to properly extract a zip file. I tried – on average my users failed to unpack such a bundle 13 times out of 10. No it’s not a typo – that’s just how hard they failed.

Alas, there is a tool that can help with that. It’s called WinRar and everyone loves it. I know, because I once made a poll and WinRar kinda won. WinRar is a neat compression tool, but it also has the ability to build so called SFX archives – self extracting bundles that can be instructed to run a program when they unravel themselves. You can do that directly from a GUI but it is tedious – a lot of clicking is involved. If you will be building and re-building your batch scripts a lot (and you will) you want something you can automate. Fortunately everything you need is in the WinRar program directory:

  • rar.exe – is a stand alone command line version of WinRar
  • Default.SFX – is a binary header that gets appended to the self extracting archives

You can grab those two files from the WinRar program directory and put them wherever. As long as both are in the same directory you don’t even need WinRar installed on the machine where you will be building the SFX bundle.

Next step is to create a config file sfx.conf where you specify where and how the bundle is to self extract. Here is an example:

Path=%TEMP%
Setup=%TEMP%\somedir\batchscript.cmd
Silent=1
Overwrite=1

Quick explanations:

  • Path – is the directory where you want to extract your shit. I’m using the temp directory.
  • Setup – is the program to be run after successful extraction. Note that I’m assuming that the bundle will extract to a sub-directory called somedir.
  • Silent – setting this to 1 suppresses the GUI extraction dialog
  • Overwrite – ensures that old files get overwritten as they are extracted

Now, you put you batch script and all the things you want to bundle with it in somedir\. Outside you put rar.exe, Default.sfx and sfx.conf. Once everything is in place, you run this command (or, you know – make it a script):

rar a -r -sfx -z"sfx.conf" setup.exe somedir\

Boom, now you have an executable called setup.exe which will quietly self-extract to temp dir, and run your batch script allowing it to call any and all binaries you included with it.

You want a practical example where this might be useful? Here is a script that changes the home page in Chrome. Changing IE homepage is somewhat trivial – it requires a simple registry hack. Changing it in Chrome, after it was already installed and configured is a tiny bit more complex. Essentially you need to parse the users’ Preferences file and change two values in it. This can be done in a number of ways, but being a unix geek I opted for something like this:

@echo off
set ppath=%USERPROFILE%\Local Settings\Application Data\Google\Chrome\User Data\Default
sed -n -f chrome_homepage.sed "ppath%\Preferences" > "%ppath%\Preferences.txt"
del "%ppath%\Preferences"
move "%ppath%\Preferences.txt" "%ffile%\Preferences"

Here is the Sed script that does the actual work:

s#homepage\": \"[^\"]*#homepage\": \"http://example.com#
s#homepage_is_newtabpage\": true#homepage_is_newtabpage\": false#

If you are having trouble reading it it’s because I’m using hash-marks (#) instead of forward slashers as regexp delimiters to avoid the zigzagging pattern of escaped slashes that usually accompanies regexps that deal with URL’s.

My SFX archive then includes 3 files – the batch script, the sed script, and the sed.exe executable from UnixUtils project. The user gets a bundled executable that will briefly flash a command line window for a split second, and his home page will be auto-magically reset to the proper value.

Is this the best possible way of doing this? No, probably not. It’s rather unorthodox, and old time Windows admins will probably yell at me for doing this. But it works, and it does let me accomplish a lot of complex tasks using good old Unix functionality without having to bang my head against the wall debugging VBS code, or forcefully install Powershell on WinXP machines.

Posted in sysadmin notes | Tagged | 4 Comments

Chronicle

Over the last few years the phrase “found footage” became synonymous with “not very good at all” – especially in Hollywood. While there are some amateur projects framed around this paradigm that are surprisingly decent, big budget productions using it tend to be miserable failures. Limiting yourself to a single camera and POV perspective is very limiting, too much shaky cam makes the audience sick, and directors too often rely on it as a crutch rather than an interesting storytelling device.

Chronicle does something unique with the medium. It steps away from the “single camera” approach and incorporates multiple points of view into their narrative. While they still maintain the “found footage” format, they sort of imply the footage was edited and spliced from many sources. So there are two camera toting characters, multiple shots taken from various security cameras, footage taken by by-standers and random passers by on their phones and iPads. Thus the title – the film you end up watching is essentially a chronicle of events that led to the rise of the downfall of the protagonists. This is a move in the right direction, and an I hope other people making find footage type features will take cue and incorporate this methodology into their work.

But Chronicle does more than that. Since it is a movie about bunch of kids who inexplicably gain awesome telekinetic powers, the camera does not need to be hand-held all the time. One of the three protagonists quickly learns to control his camera with his mind, giving it a very wide range of movement. Sometimes it floats over his shoulder, sometimes it moves away for wide panning shots, sometimes he floats it into the sky and shoots from above. In the incredible, action-packed finale he actually “force pulls” phones of bunch of bystanders in order to replace his lost camera. It is on of the first movies in quite a while that uses the find footage methodology in a clever and innovative way.

Chronicle Movie Poster

Chronicle Movie Poster

The story itself is quite decent. I have heard it described as a western take on Akira, minus the creepy progeria babies and the infamous human amoeba scene. And you know what? I would agree. It is a coming of age story about three high school kids that are suddenly transformed in some unknown, unexplained way into superheroes of sorts. At first they use their powers mostly for fun and mischief, but their strength and potential grows every day until it becomes too much to bear. Eventually one of the kids cracks under the pressure, and you get a finale very similar to that in Akira, prior to the transformation into the bloated, city consuming monstrosity.

The characters are likable, though a bit stereotypical. You got a star football player, an aloof cool kid and a nerd with an abusive father and a dying mother bonding together over a shared secret. You can figure out which one of them is going to do a face-heel-turn quite early on, but the journey there is still pretty well handled. The transformation of the subdued, shy introvert into an “apex predator”, force of nature grade super-villain is pretty fluid, and doesn’t seem forced or hammed in. It just works.

The film has some very good action scenes. The finale is possibly the most awesome super-powered battle I have seen on the silver screen yet, and Avengers will have to bend over backwards to top it. The found footage angle gives the movie a very intimate feel, which works very well considering the subject matter. When watching it, you feel that you are “in on the secret” and that you are really given a window into their private lives. It is one of the few features where this method of filming seems justified. It is a storytelling device rather than a gimmick or a crutch. Granted, it probably could have been shot in a more traditional way without sacrificing much of the story, the mood or the tone, but whatever. They used the medium well.

Is is worth watching? Yes it is. It is by no means a masterpiece, but it is a really cool take on the popular superhero genre. The premise is very close to the core concepts in Akira, and therefore the movie has a very solid backbone on which it builds an interesting story about three young men who gained powers they don’t know how to handle. Definitely check it out when you get a chance.

Posted in movies | Tagged | 4 Comments