Wednesday, October 29, 2014

angular changes

I'm not anti-frameworks any more, but a buddy twittered me Have the Angular Team lost their marbles? outlining some changes coming down the pike, especially in "html plus extra bits" area, stuff like
<input type="text" [value]="newTodoTitle">
 <button (click)="addTodo()">+</button>
I really wonder about making such radical changes in syntax. (On the other hand, looking at Ember.js, I kind of liked that their templating takes the stuff out of the tags, and just uses the handlebars as a "this is out of band" marker, whether it's templating or logical structure.) Still, angular doesn't seem like a great choice if you wanted a stable platform going into the future. But it sure is popular in these parts.

Tuesday, October 28, 2014

who's that on my dang port?


On unix-y systems, 
lsof -i :8080
will show you processes listening to port 8080. You might have to sudo it.

Monday, October 27, 2014

notes to self: java HttpURLConnection weirdness

We have a suite of external tests we run for one of our adservers that happen to be written in Java and I'm writing a new test to ensure a cookie has been properly placed.

The connection code I ended up making was like this:
HttpURLConnection.setFollowRedirects(false);
HttpURLConnection connection = (HttpURLConnection) currentUrl.openConnection();
connection.connect();
What's odd about that is that we are setting whether to follow redirects on a static class field. Also, empirically it has to be done before the openConnection() on currentUrl (an instance of URL). Frankly it kind of feels like programming via side-effect (as my coworker points out this pretty much breaks any sane threading model).

Update: this stackoverflow question about why is "setFollowRedirects()" a static, class-wide method. It turns out there's an instance-specific "setInstanceFollowRedirects()" that you can call after creation... the page suggests that it would have been less confusing and more in line with the convention used elsewhere if  the two were called "setDefaultFollowRedirects()" and "setFollowRedirects()", respectively.

The other weird thing is that while a response might have multiple "set-cookie" lines, some of the convenience functions HttpURLConnection provide assume the field name can be used as a unique key, so that getHeaderField() returns a single String, even if there were multiple lines using. A stack overflow article gave me the following:
    static String[] getAllValuesForHeaderKey(HttpURLConnection con, String header) {
        List<String> values = new ArrayList<String>();
        int idx = (con.getHeaderFieldKey(0) == null) ? 1 : 0;
        while (true) {
            String key = con.getHeaderFieldKey(idx);
            if (key == null)
                break;
            if (header.equalsIgnoreCase(key))
                values.add(con.getHeaderField(idx));
            ++idx;
        }
        return values.toArray(new String[values.size()]);
    }
Which is roughly the same as getHeaderField() but returns an array of Strings instead.


Saturday, October 25, 2014

the fun of placeholder content

So, still a work in progress, but I'm helping my cousin with his portfolio website. He was able to construct a decent idea of the layout he wanted at wix.com but got frustrated when he wasn't able to customize the interaction the way he wanted to.

For simple stuff like this, it's generally easier to build up from scratch than to hack a generated page's complex HTML. It was an interesting challenge to make a system that would be easy for my cousin to customize without mucking with code; I use "data-" tags so that the "table of content" type links know what section to open, and it should be pretty easy work to show him the structures to use.

I didn't have a lot of placeholder content to work with, and I was having trouble getting traction without it, so I generated a bunch of images and thumbnails. I parsed out some colors from w3schools' html color page and http://listofrandomwords.com/ for words (got my editor macro mojo working to push it into code) I then made a image generator in processing for the squares, fullsize and thumbnail.

I took a snapshot of its current state and put it in my devblog archive. But one cool thing is we were able to grab the domain WDJ3.com (his initials) -- always fun to find a relevant 4-letter .com domain!

Friday, October 17, 2014

growing up

I am accepting that (most?) interesting jobs are using frameworks.

I still think that framework use can bring on 80/20 rule Dietzler's Law hells, and almost by definition makes debugging tougher (since what you're looking at in the browser is more and more removed from the code you as a developer actually wrote - a coder is forced to the techniques of holism without the fallback of reductionism) but there are some pluses, and a lot of smart people really embrace these advantages.

But I mean it's so humbling, going from knowing near-everything relevant (DOM and CSS and Javascript) to knowing near-nothing (trusting the framework to do the right stuff but having it provide whole new worlds to learn) and I need to muscle through.



Even though Plain Old JQuery (along with some clunky Server Side Include for rough reusable modules) proved its value for a rich and complex application at Alleyoop, I have to accept that not everyone believes this is a sustainable, scalable pattern - and also I might not have really rich experience with "one page applications", we got much better mileage when we switched to logical functional breaks tied into various html pages.

I have to remind myself of the learning curve I had to master, to get talented at bending jQuery and CSS to my will.  Sometimes I think the big frameworks fanbase has a lot of folks who actually don't dig HTML5/JS/CSS basics as much, so they don't mind the gap between browser and written code. But this is an unfair assumption.

Meanwhile:
What's Wrong With Angular, a retort Defending Angular, and then the original author assembled a piecemeal list of Angular.js alternatives; getting the functionality that people long for "À la Carte", not buying whole houses when you just want the hightech kitchen.


Tuesday, October 7, 2014

angularjs mistakes

The Top 10 Mistakes AngularJS Developers Make. At work, we agree that Batarang looks pretty awesome, and maybe the author is a bit too harsh on jQuery.