I recently had to change a piece of code from this …
return [convert_thing(k,v) for k, v in get_things()]
To …
things = []
for k, v in get_things():
try:
thing = convert_thing(k,v)
things.append( thing )
except Exception as ex:
logger.error(ex)
return things
Why would I convert this beautiful pythonic'y piece of code to a crude almost straight C version? Because it turned out convert_thing() could raise an exception if it could not convert the thing and there is no pythonic'y way I know of to do this.
On a second note, it would be nice if we could overtly recognize the concept of code personality. When a larger system (or framework if you prefer) is constructed it is often the case that with some configuration modifications it can perform various related functions. A simple example would be if we built a program to convert and transfer a file and then used it to convert CSV files to JSON for one deployment and then used the same code (with configuration changes) to convert a file from XML to CSV for a second deployment. It would be nice if we could refer to the two different deployments by personality (xfer_hr versus xfer_money_orders) which would ultimately refer to the same piece of code.
You can always do this using simple configuration files (which could be something a personality pre-processor could do automatically) but it adds a level of complexity which is unnecessary if code had a way of universally expressing its personality. It is always a good idea to reduce the level of configuration nesting.
Thursday, March 15, 2018
Monday, January 1, 2018
Firefox and OSX 10.8.5
For probably a multitude of reasons Mozilla has decided it no longer wants to work older versions of OSX. That sucks! I have an old MacBook Air that I use frequently and recently Firefox stopped working on Facebook and ESPN even though I had changed nothing. While Chrome seems to be working OK, I don't use it much and Safari works but who cares. I want my Firefox! So after a little digging I came upon this post which worked for me.
https://forums.macrumors.com/threads/best-browser-for-os-x-mountain-lion-in-2016.1985353/
The bottom line is - this is what I did and it ended up working for me.
1) Download the latest version of Firefox from the Mozilla site. It will complain and try to discourage you from downloading it but go ahead and download it anyway. This will download a .dmg file.
2) Open the .dmg file and drag it to your applications folder. In my case it had a big circle with an X through it but I dragged it over anyway. I am fearless.
3) If you now try to run it (again, in my case it said Firefox 3 with an ugly X through it) it will fail. This is because it wants a minimum OSX of 10.9. Boo! To fix this find where the new Firefox folder is (on my system it was /Applications NOT Applications!) Then inside that directory (typically called Firefox Bla.app where Bla in my case was space 3) you will see an Info.plist file. Open this with a text editor or if you have one, a plist editor (I prefer a command line type like VI since these don't do anything stupid, other editors sometimes try to convert the file or add an extension to it) and find the line that shows the minimum operating system version. In my case it was 10.9. Change this value to your OSX version. In my case this was 10.8.5.
4) Once you have done this, OSX will be the next obstacle. It will say things like file is corrupted move it to the trash, or other scary stuff. You can ignore this. The issue here is simply an OSX security setting. By default OSX doesn't like to run downloaded applications. To fix this click the Apple logo in the upper left to and select system preferences. Then select the security and privacy icon. Make sure you click on the lock on the lower left of this pop up dialog and enter your password. This allows you to alter the settings. It also makes the Advanced button clickable. Then click the Advanced button and from there click the General tab. Here you will see why you are having issues. Simply check the Allow Downloaded Applications checkbox and then close this dialog and click the lock again to once again lock your settings. Now OSX will allow you to run this application you just downloaded from the internet. Note that in certain cases it might actually have a checkbox for the Firefox application you just downloaded. If so, check that, otherwise it will just have a generic Applications Downloaded checkbox, but hopefully you get the point.
5) Now you should be able to use Launchpad or finder to start your new version of Firefox. Make sure you have quit any other versions of Firefox you might have had running. You can do this by right clicking the Firefox icon in the docker and selecting Quit.
6) Just to be safe here you should reboot your computer. All we have left to do now is modify one Firefox configuration parameter and we should be good to go. Once your computer has rebooted, again, make sure there are no Firefox icons showing in the dock. So if you are sure there are no other versions of Firefox running proceed to the next and final step.
7) Start the new version of Firefox we just installed (I typically use Launchpad). It will probably say it crashed. This is expected. In the address bar type about:config. This will bring up a scary warning page which we will click to accept the responsibility of altering a configuration setting. Now in the search box near the top of this page type in autostart. You should see several options listed. Find the one that says browser.tabs.remote.autostart.2 and change its value from true to false by simply clicking the value column.
Now you should close this page (maybe open it again to verify the change actually changed) and then shut down Firefox. Again, you do this by right clicking its icon in the dock and selecting Quit.
The next time you restart Firefox everything should be fine. A bit of a pain in the ass but not too difficult to accomplish.
Now keep in mind I have no idea what long term issues might happen but I followed these instructions and everything seems to be working fine for me. Facebook and ESPN once again work so that is all I really cared about. I suspect there might be some issues I run up against in the future and if that happens I will add a new post describing what I have found but for now everything seems to be working OK. It even retained all my settings, bookmarks, passwords, etc.
WooHoo!
https://forums.macrumors.com/threads/best-browser-for-os-x-mountain-lion-in-2016.1985353/
The bottom line is - this is what I did and it ended up working for me.
1) Download the latest version of Firefox from the Mozilla site. It will complain and try to discourage you from downloading it but go ahead and download it anyway. This will download a .dmg file.
2) Open the .dmg file and drag it to your applications folder. In my case it had a big circle with an X through it but I dragged it over anyway. I am fearless.
3) If you now try to run it (again, in my case it said Firefox 3 with an ugly X through it) it will fail. This is because it wants a minimum OSX of 10.9. Boo! To fix this find where the new Firefox folder is (on my system it was /Applications NOT Applications!) Then inside that directory (typically called Firefox Bla.app where Bla in my case was space 3) you will see an Info.plist file. Open this with a text editor or if you have one, a plist editor (I prefer a command line type like VI since these don't do anything stupid, other editors sometimes try to convert the file or add an extension to it) and find the line that shows the minimum operating system version. In my case it was 10.9. Change this value to your OSX version. In my case this was 10.8.5.
4) Once you have done this, OSX will be the next obstacle. It will say things like file is corrupted move it to the trash, or other scary stuff. You can ignore this. The issue here is simply an OSX security setting. By default OSX doesn't like to run downloaded applications. To fix this click the Apple logo in the upper left to and select system preferences. Then select the security and privacy icon. Make sure you click on the lock on the lower left of this pop up dialog and enter your password. This allows you to alter the settings. It also makes the Advanced button clickable. Then click the Advanced button and from there click the General tab. Here you will see why you are having issues. Simply check the Allow Downloaded Applications checkbox and then close this dialog and click the lock again to once again lock your settings. Now OSX will allow you to run this application you just downloaded from the internet. Note that in certain cases it might actually have a checkbox for the Firefox application you just downloaded. If so, check that, otherwise it will just have a generic Applications Downloaded checkbox, but hopefully you get the point.
5) Now you should be able to use Launchpad or finder to start your new version of Firefox. Make sure you have quit any other versions of Firefox you might have had running. You can do this by right clicking the Firefox icon in the docker and selecting Quit.
6) Just to be safe here you should reboot your computer. All we have left to do now is modify one Firefox configuration parameter and we should be good to go. Once your computer has rebooted, again, make sure there are no Firefox icons showing in the dock. So if you are sure there are no other versions of Firefox running proceed to the next and final step.
7) Start the new version of Firefox we just installed (I typically use Launchpad). It will probably say it crashed. This is expected. In the address bar type about:config. This will bring up a scary warning page which we will click to accept the responsibility of altering a configuration setting. Now in the search box near the top of this page type in autostart. You should see several options listed. Find the one that says browser.tabs.remote.autostart.2 and change its value from true to false by simply clicking the value column.
Now you should close this page (maybe open it again to verify the change actually changed) and then shut down Firefox. Again, you do this by right clicking its icon in the dock and selecting Quit.
The next time you restart Firefox everything should be fine. A bit of a pain in the ass but not too difficult to accomplish.
Now keep in mind I have no idea what long term issues might happen but I followed these instructions and everything seems to be working fine for me. Facebook and ESPN once again work so that is all I really cared about. I suspect there might be some issues I run up against in the future and if that happens I will add a new post describing what I have found but for now everything seems to be working OK. It even retained all my settings, bookmarks, passwords, etc.
WooHoo!
Wednesday, December 27, 2017
Managing the Lazy Pro
One of my first jobs in the early 1980s was at IBM in Boca Raton Florida. Our team was comprised of about 10 juniors/interns mainly from nearby Florida Atlantic University (FAU) and we worked primarily in industrial automation (robotic arms, CNC machines, etc). It was a rigid environment where sometimes it seemed the primary objective was to badge-in before 8AM and leave at 4:42PM on the button.
Our group was named 5J3 and we took our informal name from an IBM publication that we came across from the 1970s. Its title was "What To Do About The Lazy Pro" and so on all our login screens from then on you were presented with an ASCII art logo with the tag line "5J3, The Lazy Pros".
The article was interesting as well. It was the cover story for that month's run and had a photo of a young bespectacled fellow with a crew cut and pocket protector, examining an oscilloscope. He was the classic geek which was the predominate view of programmers back then. Though 'Human Resources' initially thought it would be the mathematicians and physicists who were best suited to learn this new science called 'programming', in reality it tended to be students from the arts and soft sciences (like psychology and philosophy) who migrated over.
The article took an almost algorithmic approach to the issue where it gradually worked its way down to the final solution; termination of the cancerous employee, though it did remind the reader that this was nothing new (it was a well understood problem in the manufacturing sector as well) and that there were already performance improvement programs in place for these sorts of things. As was often the case back then the approach was more negative management than motivational, with a goal of protecting the company from this unproductive resource being the primary objective. Almost like dealing with a faulty robotic arm.
The problem with this approach is that programming tends to be a more creative exercise then manufacturing (though as Kanban has proven this approach is inferior even within the manufacturing sector) and positive reinforcement can produce better results than negative management when dealing with creative individuals. In most cases the lazy pro isn't so much lazy as bored.
I had the good fortune to manage a team of superior quality Javascript programmers around 2010. It was a virtual office with programmers scattered across the globe. As is often the case, one of the owners was not a programmer and was what I like to refer to as your classic 'Marine Corp manager'; 'the beatings will continue until morale improves'. This individual would monitor the social media feeds of all employees and whenever, during business hours activity was detected I would get a call cajoling me to fix this problem.
In my mind this is where a manager earns their pay and can save the organization money. Management is not about controlling people but rather an attempt to get the most out of the resources at your disposal. This requires the manager to get the coder any resources they may need to get their job done more efficiently and to provide guidance when needed. Removing obstacles is a big part of the equation, but so is motivation. In fact many creative types (myself included) will work for less money on projects that are more interesting, or as I often hear "you couldn't pay me enough to do that".
Many will counter that motivation comes from within and there is certainly some truth to that but de-motivation is an external force and it is this we must be vigilant against. Putting an employee on notice is a de-motivating scare tactic that in my opinion is a short term solution to a long term problem. If you have hired correctly the employee is probably just bored. Boredom and burn-out are common concerns in the software community and addressing these head-on is typically the best way to deal with programmers.
For the sake of brevity I will not get into various motivational strategies available, however, it is imperative to avoid the death spiral. You are in or entering a death spiral when you are resource constrained and all projects seem to be behind schedule. This leaves little time for motivational strategies (like education, cross training, etc) and tends to de-motivate engineers. Proper planning should not only take into consideration execution estimates but also the intangibles like cross coverage of skill sets and motivational exercises. Creative resources liked to be challenged even when the job requirements might seem to offer none. Put succinctly, managers of creative resources need to be creative squared.
Saturday, November 11, 2017
US <> Capitalism
The United States Does Not Equal Capitalism
In my not so humble opinion, this country was founded on the concept of freedom, not capitalism. Somewhere along the way I think we lost sight of that and began equating capitalism with the US, and started elevating capitalism above freedom to the point where we now have our government attempting to enforce capitalism at the expense of our freedom. What's worse, any time we have government interference in capitalism it is attacked as a communist maneuver. I am not an advocate of communism in the US or anywhere else for that matter so please don't assume that is my point here.
Consider our monopoly laws and unions. Henry Ford and his ilk went to great lengths to squash unionization, and many supported anti-unions views with the rationale being they were fronts for communists and criminals but at the end of the day from the mile high perspective are unions not just a way for the average American worker to try to reclaim some of their life and freedom? Am I the only one who reads Steinbeck anymore?
The opposite of freedom is control and control comes in many subtle forms, not the least of which is financial control. Monopolies are illegal mainly because they attempt to control us, thus taking away our freedoms in a particular area. It is a classic example of freedom controlling capitalism, and it is not anti-American and communistic to have and enforce monopoly laws, it is exactly the American thing to do if we cherish our freedom above capitalism.
I am anti-welfare, anti-food stamps, etc. I do not agree with wealth re-distribution via taxation to enable a permanent underclass or allow the government to expand to monstrous pre proportions but I do believe somewhere along the way we have allowed the corruption that comes with money to misguide us into defending the ultra-wealthy at the expense of our basic freedoms. It is not noble to support a pharmaceutical company's excessive pricing for the sake of capitalism while Americans die because they can not afford contribute to that company's bottom line. It is not American to allow insurance companies to take nearly 80% of every dollar spent on healthcare. It is actually anti-American to place money above life, thereby depriving an American of their most basic freedom for the sake of capitalism. America does not equal capitalism it equals freedom. Push comes to shove, capitalism loses.
Consider the American sports industry as an example. At one point these guys were dealt with as property. The wealthy owners colluded, poor-mouthed and alluded to communism when they fought player unionization. Now the greedy players share in the wealth with the greedy owners. There was obviously enough money to go around. The player's unions did not signal the end of the sport, but rather it was the beginning of more freedom for the players at the expense of the owner's bottom line (wealth distribution) which is kind of my point. It is better for the economy when more than one person can afford to buy a loaf of bread.
Saturday, November 4, 2017
Weak Minded Strong Typing
It never ceases to amaze me the prejudice that exists within the coding community against weakly typed languages. Its almost as if variables have no rights. People can change. Why can't variables?
In the Python programming language I can write …
x = 2
print type( x )
x = str( x )
print type( x )
This is a thing of beauty. Its almost as if the variable can transcend its initial limitations and rise above to a greater social status. "I was a lowly int, but now I'm a string".
Try the same in a strongly typed language like Java and see what you get. Many programmers I work with look down their nose at languages like PERL and refer to them as write-only languages, and while I agree PERL's obscure syntax and side effect constructs can make it difficult to maintain, what language is immune to poor programming practices and sloppy hacking.
I have worked on massive PERL code bases that were easy to maintain because they were written properly, with attention paid to coding conventions and detail. In fact if I recall correctly, when I got to Amazon in 1999 a significant portion of the code base was written in PERL.
Lately it seems there is a push in the programming community to move towards more strongly typed languages. Even Javascript is not immune, nothing is sacred anymore. Why don't we just leave the language alone. If you are an advocate of strong typing then build your code base in that manner as a convention but don't impose these limitations on others. I have seen many Python projects that were obviously the product of a displaced Java engineer, with abstract base classes, inheritance work arounds and other rigid constructs more typical of a COBOL program than a modern programming language.
Part of the beauty of coding in a typeless language is the freedom to not have to worry about the particular constraints of the language. Instead one can focus on the design rather than the implementation. Strongly typed languages are notoriously difficult to work with when the class structures are dynamic in nature to the point that you often feel like you are fighting with the programming language to get the job done.
I once saw a Java stack trace that was 83 levels of inheritance deep. I can't think of anything that is that abstract in real life.
While I can appreciate the desire to produce maintainable code I can also appreciate the benefit of flexibility in a programming language. I sure hope the result of this recent strongly typed movement is nothing more than a set of recommended best practice design patterns, and not the onslaught of a bunch of strongly typed interpreters.
Wednesday, September 20, 2017
Definition and Tense
In philosophy we have the seemingly innocent concept of reference. To what do you allude to (the word 'allude', itself being a concept). But when we talk about a reference we must first consider what a definition is because we tend to refer to things as being defined when in reality they are anything but.
For example, I see an ant. I refer to that object as an ant. I step on that object and obliterate it to the point where its constituent components no longer exist yet what can be said about my reference to that ant. What about any modifications to its environment that ant may have made. It did exist at some point in time, even if that point in time does nothing more than define my relationship to that ant (IE the ant no longer existed in its ant type form AFTER it interfaced with me).
Consider Abraham Lincoln. Is this a hard reference to a well defined object or a loose reference to something that no longer exists? So the concept of tense is central to the concept of a reference and the concept of a reference is strongly tied to the definition of an object.
Consider a hard reference something to the effect "I saw Abraham Lincoln remove his hat' versus a soft reference like "Abraham Lincoln's mother passed away today".
Since Abraham Lincoln no longer exists we must rely on the definition of what an Abraham Lincoln was in order to understand what we actually have a reference to. In other words the reference may refer to something which exists in one of two tenses; exists, or does not currently exist. There are many other dimensions we must consider like 'is in my present space', which we can examine later but for now let's limit ourselves to separating references into one of two groups; currently exists and currently does not exist. We can group a bunch of these attribute like things together later and refer to these things in a context but for now let's keep things simple.
So in the simple case where we have a hard reference to a well defined object (I saw Abraham Lincoln remove his hat today) we can now think about the difficulty in actually defining an object and face head-on the fact that in all such cases we must ultimately limit our concept of a definition in some significant ways.
The statement 'Abraham Lincoln was a human' is pretty much accepted fact. The exact definition of a human MUST be abstract. Not all humans are identical therefore our definition of a human must be based on physical attributes (like organs, etc) clipped at some level, which themselves are abstract concepts predicated on other abstract concepts like atoms. Think of the concept of a hand. Is there an absolute limit on the size (small or large) of a hand? Must it be operational? Must it be attached to a human? Must it be part of a biological organism? Do monkeys have hands? If all things must ultimately be composed of some atomic entity can we measure all things using this unit of measure? Can we say this love is stronger than that love because it contains more atoms? How many atoms does it take to make a love and in what configuration?
Regardless of how we go about this defining business (since absolutely defining something is technically impossible) what this definition must ultimately reconcile is what we accept as historical facts (effects) about this entity, regardless of entity tense. One might argue that once a reference no longer refers to a physical object it MUST reference the set of effects (we will call these 'accepted facts') this entity caused, however, one could also argue the set of effects this entity has accumulated over time must also be considered even when evaluating existing entities. Put another way you (and every other entity in the universe) are simply defined as the set of things you have affected even if the only thing you effected was yourself. References to you are either direct or indirect and refer to this set of facts.
So basically all references are weak and all objects are loosely defined. Such are the concerns of true AI.
Tuesday, April 11, 2017
Percival and Such
Perhaps the reason we never hear from anyone after they leave this world (if as Percival believes we still exist) is because it is so insignificant in the grand scheme of things that it isn't even worth a passing thought.
Subscribe to:
Posts (Atom)