Posted on

are you a logger?

Some people are debuggers.
Stepping their way through the binary jungle, one hack at a time.

For those of you who are loggers, staring  at the console for interesting events:
I had some time to write a small php script that will put a console.log for every method in a canjs controller.

Should save me loads of monotony when reverse engineering OPC ( other peoples code ).

Hope you find it useful:

<?php

if( !isset( $argv[1] ) )
$argv[1] = 'Storage.js';

$fileInfo = pathinfo( $argv[1] );
$outFile = $fileInfo['dirname'] . '/' . $fileInfo['filename'] . '_debug.' . $fileInfo['extension'];

$in = fopen($argv[1], 'r');
$out = fopen($outFile, 'w');

while( !feof( $in ) ){
$line = fgets($in);
if( preg_match('/:\W+function/', $line)){
preg_match("/\((.*)\)/", $line, $matches);
$function = explode(':', $line );
$functionName = trim($function[0]);

if( isset( $matches[1] ) && strlen($matches[1]) > 0  )
$line .= "\nconsole.log( '$fileInfo[filename]', '$functionName', $matches[1] )\n";
else
$line .= "\nconsole.log( '$fileInfo[filename]', '$functionName' )\n";
}
fputs($out, $line);
}

fclose($in);
fclose($out);

Posted on

CanJS is really the new hot thing in JavaScript

So its official.
I was at a Hare Krishna Temple in Silicon Valley. And while I was relaxing a bit, I overheard another pair of engineerings talking.
I couldn’t help but eavesdrop.

To my surprise, they were talking about CanJS. One of the engineers was RAVING about it to the other one. Finally I had to inject myself into the conversation and inquire as to where they worked.

And again to my surprise, they didn’t work at a large company, but a startup.
Bitovi is a name I am hearing more and more while I am up here in Silicon Valley!

Why? The simple answer, it makes things easier. You just have to write way less code. About 20% less.
It also organizes your code into better more logical, and therefore readable, structure.

So yes, thank you Brian Moschel, for JavaScriptMVC and for CanJS.

They are the IT thing in I.T. this year of our lord, 2013.

Posted on

PhantomJS + Jasmine vs Selenium Web Driver

Recently I started using phantomjs, which is a headless browser based on web-kit, for automated JavaScript testing.

Now when I was playing around with Selenium @ ABC Family, I really liked how the web driver started a browser instance and executed the test suite within it. This means Selenium is actually a better, or closer match, in terms of automated testing, because the browser is not headless. Although I don’t know all the internals of Selenium, that was my first impression.

But the positive thing about using the grunt, jasmine, phatomjs combo to run unit tests, is that we can start a jasmine server, which lets you check your code in many other browsers. That means you are not limited by the Selenium browser library of supported browsers. You can actually pick up your phone, or tablet, and point the browser to the test server, and see how your code executes on that particular system ( Device, OS, Browser). True this is not something that can be used with 100% automation on its own, but it does give you the freedom to experiment and see the behavior of code in a large variant of systems. This means that with services like DeviceAnywhere, you maybe able to cover and automate the testing of all kinds of strange fringe devices.

Something else that is interesting is that in Selenium, you can’t really hook, or spyOn member methods. While a lot of the tests written in jasmine, can be executed similarly with Selenium, because they just check for a class that has been added or removed from a DOM element, jasmine provides more integration with the code base.

The classes are loaded, along with a html fixture, and then executed. This is how the server works, by creating a #sandbox div where it loads the html fixtures for each test, loading the javascript into the page, instantiating the class, and then begins execution of the test suite. Now the opposite argument is, again, this is not how the site would be like in the wild. Other components would live on the page. So Selenium gives a more accurate assessment of how the code actually works on the end user’s system, since it loads the entire site, via a client side browser.

Now as a Computer Scientist, Java vs JavaScript argument is mute to me when it comes to choosing a “platform”. Because ultimately its like comparing apples to oranges, when you really look at the language structure and what they are designed to accomplish. Two different tools for different jobs. As a front end developer, who wants everything to be easy, there is definitely a benefit to having a unified language for creating build tools, server side applications, and user interfaces. So at some shops, where ROI is important, it’s a good idea to keep the tools all in the skill set of the human resources currently on staff. For UI people, this means JavaScript > Java. This is a good argument for using tools like grunt, and phantomjs, and jasmine, since they are all JavaScript based, they empower the new kingmakers (Open Source Developers).

Which is actually still not a big argument against Selenium Web Driver, because Java is very easy to install, you are not going to be making many changes to the driver itself, and the interface for running the Selenium Web Driver could potentially still be written in JavaScript.

Therefore the argument could be made that Selenium and Jasmine don’t have to be mutually exclusive, while it would bloat the build time to include both systems, a separate box, and process, could be used, to test with both, or the one that is missing in the build process.

While its too soon for me to say, “Dude, Selenium is old news.” I can say that all this merits more experimentation and testing. A very exciting time for Computer Scientists indeed. So much Brain Candy!

Posted on

Real Web Developers don’t do “Builds”

I don’t want to wait for some MAVEN command to execute.
I just want to refresh the browser!

So this is where Charles Proxy comes to the rescue!
The “Map to Local” feature allows you to quickly map your resources to a live implementation on a production, or development environment.

Really great feature, that saves a lot of time. Even the uploading to a generic hosting step can be skipped when doing changes to static resources. So this tool is good for Enterprises and SMBs.

Usually I would completely avoid extraneous non open source solutions. The KISS principle is something I apply not just to my coding, but to my workflow as well. Unfortunately, I don’t always get to decide what platform and workflow structure I have to interact with. And this where tools like Fiddler and Charles become indispensable in preserving my sanity.

While on the Mac environment, I am currently using Charles Proxy, Fiddler2 also provides this feature, hidden in the AutoResponder tab. Simply activate “Map URLs to local files”. And Fiddler should be able to run on Linux / Mac, although I haven’t tried it yet.

Check it out http://www.fiddler2.com/fiddler/help/video/default.asp

Posted on

Mobile Web

Today I had the pleasure of meeting Maximiliano Firtman. An amazing speaker who kept my attention the entire time.
He really validated my perspective on mobile web. That even though it’s a complete fuster cluck when it comes to devices, screens, features, and may be an exercise in complete futility because as soon as your done coding everything is going to change anyway, you still can’t idly sit back and do nothing.

Though many of my co-workers were joking that his talk made them depressed about the current state of the mobile web, I really found it enjoyable, because he echoed back many of my own viewpoints regarding Responsive Web Design, system architecture, and even how job duties or roles should be defined. And since great minds think alike, I recommend you check out his books. They will reveal lots of great resources. And illuminate niches in capturing users, and getting a better ROI, when it comes to creating a mobile version of your website.

Spoiler alert, there is no easy way to go about creating a mobile version of your site. And as craftsmen, we have to first painstakingly measure, and remeasure, before we put our tools to work. Keep in mind, this gentleman has been doing web programming since 1995, and has been a subject matter expert in mobile web design since 2000, during the days of WML, and WAP.

Posted on

Parallel Processing in PHP?

So we have this requirement in our project to start up a “thread” of execution asynchronously.

First we had to come to an agreement that it can’t be done with multi-threading, but instead has to be done with multiple processes.  We can’t have our controller executing a thread, and waiting around for it to finish in memory.

This will leave a process living on the system that we don’t necessarily need. Although now that I think about it, it may have the visual effect of fulfilling our requirement, its not a good overall design.

What we really need is to start an external process that will execute not as a child of the current process.So we have tried it a couple of different ways.

pcntl_fork which doesnt work with Apache php module, so we have to redeploy as a FastCGI.

system()  call sending the shell into the background, which seems to be not working right now.

And the two things I coded in but never tested, proc_open and popen.

Now we are not trying to achieve true parallel processing, and utitlizing the computer’s multiple processes. Just a simple outside process.

Stay tuned, we’ll let you know.

_______________

The answer was popen with &> dev/null & in the command string.

Posted on

Innovation through Miscommunication

Funny story right. A friend of mine is working with some interesting people right, and he tells me about this graphic/web designer, who was asked to make a drop down during the daily standup. So my friend is telling me about how he is doing a total facepalm cause this guy is estimating the addition of a drop down as an eight hour task, right. I mean, that was all that was there, find a space on the page, design a niche spot in photoshop maybe, where this drop down will go nicely and contain some hard coded values. I gotta say, I agree with my buddy cause you think drop down you think select tag. Bada bing Bada boom. Heck the wireframe had a freaking select tag based drop down in it. But apparently the designer didn’t quite get it, so it took him a while to even answer back. He took like 5 minutes to make sure what he was supposed to do, looking all confused and the rest of the team totally accepted his estimate. So about 8 hours into his task, it becomes apparent that he is actually making a fly out pane that drops from the top! And my friend tells me its beautiful. With a great design, and nice tween, a great value added to the project.

But who would have thought it, that what someone else might interpret as a miscommunication, is actually innovation!

Posted on

Dell Suffering: A Scanner Darkly

lol. Okay that’s a dirty trick that should get me some traffic. 🙂

Anyways. The printer is finally up on the network and working great. I couldn’t be happier with that right now.
But I am stuck at a new problem. I can’t configure the scanner to ‘Scan to PC’ or to ‘Scan to FTP’ correctly.
Oh sure, there is a drop down in the printer’s web interface and tool box software.
But the drop down only gives you the choice of which do you wish to use, SMB / FTP, changing the selection doesn’t make input boxes appear or anything.
You would think the printer is not psychic, and needs to have host, username, and password information entered somewhere.

But alas, I am left in a Death Cap Daze, staring at the printer, my senses and cognitive abilities distorted, and like Keanu Reeves, all I can do is utter a: ‘Woohh.’

Posted on

Dell Suffering

Yes, I know.

I complain A LOT.

But when you waste like an hour trying to get your 1355cnw printer on the wireless network, what else are you going to do!
First, the printer itself:

I can’t make heads or tails of the experience / display / setup process. Its horrid. I feel like I’m using an interface from the 80’s.
Not just in design of the external panel, or buttons, or other hardware components. But the over experience itself. The constant restarts, the non responsive menu.
This is poor product design from the soul to the heart of the printer and even the external support for the product, the dell website, has a horrible user experience.

So second poor product from dell, their website:

I believe the dell team should realize that the first page result for the search query “1355cnw drivers” results as the product detail / buy page being the first result.
You would think that a product’s detail page would contain on it, all pertinent links to the product. Such as the drivers. The word drivers is no where easily found above the fold, but it does exist in the footer.

So having not found a direct link to the specific drivers, I clicked back, and went on to the second result.

But this was the download page for the Mac version. At least I am assuming its the mac version because it has ‘_Mac’ in the name. No where does it say for which type platform or version or processor type on the download page.

Wait, it gets worse!

So having to go to the driver downloads home, I try to search for the printer. I choose  ‘Select product from my products’ or a link to that says something to that effect.  The resulting page is a login form. I am thinking that once I login into dell, they will know what printer I bought. But the list is empty, even after I click on it, and login. I am stuck staring at a page with almost nothing on it. So I go back and select ‘Choose from product list’ and begin to refine the search down.

Finally I arrive at my product download page, select three items to download, which is also a f*king confusing page as list multiple drivers with confusing labeling system, and get prompted with an ‘INSTALL OUR DOWDNLOADER  ON YOUR SYSTEM’ prompt.

G*d Dang it.  Oh, man, I am just trying to scan a check so I can start my contract with KForce, and a routine printer installation has become a nightmare.

I have to download, before I can download. Dell, KISS my shiny metal a**.

 

Posted on

From Bill Maher’s Blog

The Endth Degree

By Bill Maher

Is going to college still even worth it? College grads are coming out with degrees, yes – and herpes – but also with student loan debt totaling $60,000, $80,000, $100,00. These kids haven’t even gotten started in their careers and they’re already saddled with what’s tantamount to a full mortgage. In this sucky economy, graduates find themselves back in their old bedrooms at their parents’ homes, taking jobs in the service industry that they could have gotten without a college degree.

Wouldn’t a bright, industrious kid be better off in this economy to just jump into the job market and try to excel through merit?

[full article]