Archive for the ‘Tech’ Category

The Lifespan of your Code

I’ve been spending a likely larger-than-ought chunk of my summer sitting here coding up a storm. It’s a great project though, one I believe could reap time-saving rewards in the future. It’s nearly 100% RSS-feed based, with all the jQuery bells n whistles. And immediately, I begin to fear.

Sure Javascript/ECMASCript has been going strong for nearly 15-20 years now, and furthermore shows little sign of slowing down in it’s dominance. Yet, these past few days I’ve been dealing with what I’m calling a “2-digit year bug.” Ya see, I’m trying to support the years before AD100. And it seems that’s a little rough for Javascript to prefer. Fine, fine, I’ll just code around it. But wait, we’re in a new century. What happens in the year 2101? Will future-javascript (or a 100 year old browser) interpret year AD101 as AD2101??

This is where I decided, “But I’ll be dead by then, so do I really care?” :) I mean, I’ll start caring once: (a) someone besides me likes my open-source socially-enabled RSS reader and/or (b) when the Javascript gods start caring that they don’t support serious (>2000 year old) timelines.

Randomly writing CSV data in PHP

Today’s project: add or replace values in a comma-separated-value file. The application is for tag-counting by week, so the first column is effectively an ID column & the rest (for me) are integers. But here’s the code with some sample data grabbed from a random Google search..

<?
/************** Vars ***************/

$str="id,age,sex,region,income,married,children,car,save_act,current_act,mortgage,pep
ID12101,48,FEMALE,INNER_CITY,17546.0,NO,1,NO,NO,NO,NO,YES
ID12102,40,MALE,TOWN,30085.1,YES,3,YES,NO,YES,YES,NO
ID12103,51,FEMALE,INNER_CITY,16575.4,YES,0,YES,YES,YES,NO,NO
ID12104,23,FEMALE,TOWN,20375.4,YES,3,NO,NO,YES,NO,NO
ID12105,57,FEMALE,RURAL,50576.3,YES,0,NO,YES,NO,NO,NO
ID12106,57,FEMALE,TOWN,37869.6,YES,2,NO,YES,YES,NO,YES
ID12107,22,MALE,RURAL,8877.07,NO,0,NO,NO,YES,NO,YES
ID12108,58,MALE,TOWN,24946.6,YES,0,YES,YES,YES,NO,NO
ID12109,37,FEMALE,SUBURBAN,25304.3,YES,2,YES,NO,NO,NO,NO
ID12110,54,MALE,TOWN,24212.1,YES,2,YES,YES,YES,NO,NO
ID12111,66,FEMALE,TOWN,59803.9,YES,0,NO,YES,YES,NO,NO
ID12112,52,FEMALE,INNER_CITY,26658.8,NO,0,YES,YES,YES,YES,NO
ID12113,44,FEMALE,TOWN,15735.8,YES,1,NO,YES,YES,YES,YES
ID12114,66,FEMALE,TOWN,55204.7,YES,1,YES,YES,YES,YES,YES
ID12115,36,MALE,RURAL,19474.6,YES,0,NO,YES,YES,YES,NO";

$tags2find_arr=array();
$tags2find_arr['ID12106']=array(1=>1,4=>100);  //additive numbers, or replacing?
$tags2find_arr['ID12102']=array(1=>1,4=>200);
$tags2find_arr['ID12114']=array(1=>1,4=>300);

$fn='test.txt';
/************** Runtime ***************/

writeCSV($fn,$str);
writeRandCSV($fn,$tags2find_arr,'add');

/************** Functions ***************/

function writeCSV($fn='',$str=''){

$fh=fopen($fn,'w');
fwrite($fh,$str);
fclose($fh);
}
/****************************/
function writeRandCSV($fn,$tags2find_arr,$addreplace='add'){
$fl=filesize($fn);
$fh=fopen($fn,'r+'); //open for reading, and writing, but don't kill the contents
$str=fread($fh, $fl);

foreach($tags2find_arr as $tag2find=>$csv_data_addreplace){  //$tag2find='ID12108';
//find the line in the str			//alt: explode by '\n' or '\r' &amp;amp; get an array &amp;amp; it's size.. find in array, truncate array,implode &amp;amp; find strlen's for loc &amp;amp; write-len
$readtagloc=strpos($str,$tag2find.',');   //this could be a problem for smaller tags found in larger.. throw a \n before &amp;amp; a , after?
//echo "\r<br/>".$tag2find." @".$readtagloc;

//find it's corollary in the file
fseek($fh,$readtagloc);
$fcsv_arr=fgetcsv($fh); //should only get one line!
//for($i=0;$i<count($fcsv_data);$i++){
//$fcsv_arr[$i]=$fcsv_arr[$i]+$csv_data_addreplace[$i]; //58->59
foreach($csv_data_addreplace as $csv_idx=>$csv_addreplace){
  if($addreplace=='add') $fcsv_arr[$csv_idx]+=$csv_addreplace; //58->59
  else $fcsv_arr[$csv_idx]=$csv_addreplace;
}
//print_r($fcsv_arr);

/******************************/
//echo '\r<br/>'.ftell($fh).' or '.(ftell($fh)-strlen(implode(',',$csv_arr))-1 );
fseek($fh,$readtagloc); //back to beginning of line to write now
//$read=fread($fh, $readlen);
//hoping the pointer is still in the same loc &amp;amp; not @ line-end!

$ok[$tag2find]=fputcsv($fh,$fcsv_arr,',');
$sz=(strlen(implode(',',$fcsv_arr))+1);

//if($ok===false){ echo "FAILURE"; }
//if($ok==$sz){ echo "\r<br/>written length ok:".$ok; }
//else { "\r<br/>written length not ok:".$ok.'<'.$sz; }

} //end foreach tag
$ok[]=fclose($fh);
return $ok;

} //close function
/******************************/
?>

How Not to Design: Poor Logic

My RSS feed gave me this gem today:


I recommend taking a larger perspective than this overly-simple graphic displays. Note that it is without any credits to actual pyschological or sociological research, as well as being an example of the “slippery slope” logical fallacy .

Rather, the “real world” is filled with people who are managed into any one (not necessarily all!) of these positions by circumstances which themselves seem overly challenging, or have proven worthless. These can be seen as personal failures. Note also that self-confidence, cirumstances/environments of empowerment are NOT on this list, nor are they suggested to be on this list. Instead, Mr. Holmes presents the beginnings of a ‘blame-game’, a triage by which to score, judge and rate workers. Those who are already succeed will continue, those who fail will continue. Mr. Holmes offers no direct or clear recommendations or means of change. Such a false-dichotomizing info-graphic leads the viewer into negative feelings of self or worse, sets a keen eye to look out for and against the “fixed” folk. Enemy-creation is hardly the hallmark of civil society, yet it is the nature of Modernist thought.

This is an entirely sad “info”-graphic, placing all responsibility for change upon the individual, who likely is by now numb and blind to opportunity, having missed prior occasions for success. I fail to see how blaming the “victim” here solves any problems or moves anyone beyond self into sociable environments. Management means helping – something that was lost in the industrial revolution’s genocide of apprenticed trade-workers. People are moved by experience more than simple frameworks, however wonderful and cleanly presented they may appear.

Most of these statements I have made are likely familiar to sociologists; a field which is likely unfamiliar to much of the outstanding public. My reccomendation: Read Mark Schneider’s Theory Primer book.

Internet’s effect on Intelligence, or vice-versa?

Ahh the “New Media makes you dumb” debate. The WSJ has it going, and Slashdot picked it up.

My spin agrees with both sides, in the context of actor-responsibility/meaningless-drone. That itself is a rough divide for humanity; I mean, how many of us are *fully* determined in our thought patterns? Most of us are in small ways, but not in all ways. Further, we are only as determined by what is available to us. If no one is ever forced to turn off the TV, read a book, or read a full webpage, they never will. Humanity is *that* fickle. We’ll live in the present, assuming the past isn’t consequential. The Internet has only “given the people what they want” in that regard.  To this end, Shirky did a wonderful job with the history of new media; theories are only good if they hold water across time & place.

But this consistently distracted state is in some ways my own life. I have trouble filtering out background conversations when in a restaurant, among other examples. I’m sure it’s giving rise to affective disorders (let’s not get beyond simple parole: dis-order = out of order). How can someone know what to love if there is no order or priority to in and out-flow of info, people, experience, etc.

The spiritual consequences are huge then. Jesus’ 2 commands of love God & fellow-man could be well-undermined by this novelty. That’s why I’m agreeing with a friend’s recent Facebook status: “Discipline is remembering what you love.” Discipline isn’t about saying “no,” so much as remembering, and remembering & reflecting is being killed off.

Reflection is a time-intensive activity, one which now-now-now-or-you’ll-miss-it-or-get-too-far-behind media won’t allow for, and as noted, is required:

“The researchers were surprised by the results. They had expected that the intensive multitaskers would have gained some unique mental advantages from all their on-screen juggling. But that wasn’t the case. In fact, the heavy multitaskers weren’t even good at multitasking. They were considerably less adept at switching between tasks than the more infrequent multitaskers. “Everything distracts them,” observed Clifford Nass, the professor who heads the Stanford lab.” — Nicholas Carr

This is exactly what the other side of the debate agrees with as well:

“Reading is an unnatural act; we are no more evolved to read books than we are to use computers.”–Clay Shirky

But what I like about Clay’s statement is the next line: “Literate societies become literate by investing extraordinary resources, every year, training children to read.” Resources maybe anything from mothers to educators, from $ for private tutoring to the publishing industry.. but it is always about time. My own time reading is only worth it if I spend the time to stop every other paragraph or so. Ideas need to sink in for any foundation to be placed. Who wants a skyscraper built on unset, wet concrete? That’s the best analogy I can give for what the Internet is doing: providing shortcuts for our memory, and keeping us from remembering anything. Even the act of scrolling a webpage is vague. Turning a page is much more definitive. I can’t glance-back as easily as I can scroll back & forth. (Ok, maybe not the best example..)

I suppose what this means for future information-design is clearspace. Data can also be held better when it is interacted with. Static graphs are visualization of too many numbers; interaction/overlays, compare-contrast is a beginning for too many graphs. Fickle “daily info-graphics” sent to my inbox or RSS reader only clog my mind, unless they spark interest  for further research (assuming I know where & how to research it!). I’d much rather have the data in contrast with something else, both of which are in connection with present values and personal states of knowledge. This way graphics could be delivered to my inbox for me, which overlap/redundant, and over-time help me learn and meat specified goals.

And finally for a sociological perspective. This little idea about remembering can be expanded further to include any binary-division, even gender-roles. While there’s a pressure from amongst egalitarians to “be equal” between/across genders, there is also a consequence of each gender doing everything, overburdening itself with too much. But that is still no “win” for anyone who would espouse a fascist (Modernist) sociology, where each person must fit the role assigned 100%. (I’m looking at you SB-preachers!)

Update: NYT picked this up too with their own spin that sounds like a good middle ground/awareness campaign.

Future is awesome?

There’s such a future-push within the web-world, it’s a tad crazy (and ppl know it). The fact that I’m writing this short note is more about my interest in preservation that publication. I’d like to look back one day and say “Ha! I was sooo wrong (or right!).”

So without further ado, here’s my “Future of the Web Browser.” (as opposed to his)

First off, the internet has always been more than just the web. There’s numerous protocols which fly all around, and tonnes of data packets which go to places other than IE, Firefox or Safari (or Opera, Epiphany, Midori, etc). This is the first point: the web has turned into a 3-level programming arena with AJAX: JSON packets of data + css stlying onto an html frame. It’s the browser which glues ‘em together. But do we need a browser for all of this? Greasemonkey scripts have successfully edited the CSS & the browser needs some kind of framework, but the data.. ah yes, it’s always about the information. Ever put an RSS feed into your browser’s bookmarks-bar? Yup. That’s the future. But why should this be JUST in the browser? Why not in other applications? Or in the deskbar-panel (if such exists in the future).Excel has (for years) supported database connections, and in recent years, supported them over the web with XML. Keep. going.  Is a spreadsheet the only thing that needs raw data?

So that’s my first-round of ideas: open data, in open formats, available in dispersed locations. Such diffusion of the web into separate, external apps or media seems inevitble. People can handle 5 different things on one table-top, but why cook where you disassemble your car? Maybe I’m human, and LIKE to get up from my seat, see the world from other angles.

Second, now that we have removed raw-data from the web browser (and put it to good use), we are left with the other genre’s of content: news & blogs (oh wait, that’s already in your RSS reader). Friends status updates (again, why can’t this be integrated somewhere useful, where you want it to be). Youtube and videos can also be extracted (if corporations get their grubby hands out & let content be open & free!) What’s left for a browser? Not much. Nothing unless there is novel content which is not diffused into another application.

Notice all my ideas still revolve around a “desktop” (which I actually despise). All I’m saying is that so long as the native-coded, windowed environment exists, the web can be in places other than the browser. iTunes is the prime example. Second, yes, there is a chance of “every window is a browser.” That’s already the case/possible with Prism, making your OS useful only as a windowing manager (which I debate doesn’t manage very well).

Anyways that’s the future as I can see.. Either content is re-embedded into HTML, for proprietary purposes, or it is free. Either way, it is in native code somehow.

The only other point is caching, which HTML5 brings. I love caching, I’m writing an “everything-checker-viewer” right now which survives on caching alone. Live-data is nice, but until connections across the world become faster, consistent and needless-to-mention available/accessible, caching will inevitably rule.

The Apple Tablet Insanity, Localized.

The WSJ sent a 99% full-sized image in it’s paper today, so I did what anyone else would do: I cut it out and went around the house comparing!

First up, a Kierkegaard book I just got done writing a paper on. It is the size of said small book opened up.  Next, a sheet of college-ruled paper: the screen is a little shorter & wider than such paper, folded in half. That’s more precisely 5 3/4″ x 7 3/4″: The same width of a CD (1.3 times taller), and just about the same size as a DVD-case! Compared to my 13″ macbook screen? The right-half of it, but a bit longer/taller.

The whole thing is nearly the same area as my 7″x10″ Canson sketchpad, which I already carry around everywhere, and like the size of (uh oh!). But overall, it is a tad smaller than I expected.

The icons on the screen are just over 1/2″ in size, and just over 3/4″ apart. So, any ideas about Chess or Checkers are do-able (8×8), but I wouldn’t want a grid anything larger (smaller blocks!) than 10×10. That means full-on Scrabble (R) might not be for grandpa’s cataract-eyes. Likely a non-fullsized board will be made, or panning/scrolling. Either way, better than the present solution, right?

One “feature”: the screen when widened is technically capable of supporting the same keyboard distance from q-p on the 13″ macbook. But my little fingers tend to notice & live between those keys, in cracks which glass-screens don’t have.

Critique: once it decouples from iTunes (and becomes its own device), lets me plug in USB & SD card-stuff, and generally improves as a media creation-device, I’ll be sold. Until then, I’ll be theorizing on all these new toys (Courier!!) could become!

Private Space Flight

With the latest NASA buzz being on “commercial spaceflight“, I figured I would do my part to be curious enough about what that means.

Below is a simple bar-graph (height = ..height! in feet ) of each of the following:

Notice the extra-ong "still to go" between the WK2 Plane and Space, let alone LEO!

Low Earth Orbit 1056000
Glenn’s First Orbit 612480
Offically “Space” 328083
WhiteKnightTwo Plane 60000
SpaceShipTwo 268083
For those of you who aren’t “in the know”, Scaled Composites isn’t doing heavy-lift rockets (like others), but instead getting people into space.

Affective News Feeds

Just last night I found out the glory of Yahoo Pipes. The idea is one for which I’ve wanted & waited a long time: Take *any* web-source & turn it into (through combining, filtering, etc) any other web-source: iCal, RSS, etc.

So the consequence? I now have 3 rss feeds: One for Friend’s Statuses (twitter+facebook), one for news (google news feed) and another for everything else from friends blogs to tech-news.

It would only seem obvious that these 3 can and should be on the same rss reader (I use google reader’s iphone interface, even on my main computer).

The trouble with combining these 3 or 4 types of news into ONE ‘technological ontology’ (a single rss reader) is a simple lessons learned from psychology.. there’s lots of theories like this, but I learned it from Urie Bronfenbrenner, “The Ecology of Human Development.” Basically, we all have various circles, some more core than others, of family, friends, and aquaintences. They affect us differently.

Likewise, we can say data from each source must retain it’s affective priority. Notice how different this is than most News/Social Networking Aggregrates, which merely pull in everything without priority. Likewise, facebook and other marketing groups try to get your affectively involved in their little sphere.

With a little finesse and basic coding-think, yahoo pipes allows me to get each level of data from friends, news & otherwise. Reading them one by one allows me to maintain a relatively consistent affect when reading all 500 tweets, instead of trying to have little affective response to a random news-blip, and then to care deeply over another friends’ status, only to return to not caring. Perhaps that emotional flexibility is possible and desireable in kids, but I’m getting too old for that?

Smart(er)phones mean affective consumer trends

Remember your first cell-phone? It was likely not the *original* cellphone,

In my case, it was a kyocera green-screen on my parents verizon network. It DID have mobile-web (remember those WHTML/WAP-sites?) when I went to Chicago. My next was a color-screened nokia until both myself and the web got serious and my sony-erickson was the fastest GPRS connected phone (which I infrared-connected to my HP WinMo device quite requently!)

Enough about my history, on to my point: I’m a geek, so I loved the capabilities of the phone, no matter how tedious it was. Most consumers aren’t willing to go through the tedium for the glory, and *finally* we have a crop of large-screened phones which allow something aside from left-down-right-up-left-left-down-ok magic of the early Nintendo days!

WinMo tried to be this player years back. Wow! An interface that was colorful, full and wasn’t ridiculously hidden behind 19 menus. It had a Today screen which told me more than the TIME! But Windows/M$ got lazy, were happy to ignore emerging tech while raking in the cash, and Apple took over, overnight.

Now, in the wake of the iPhone, LG & Samsung have created their own semi-smart interaces. I’ve been running the Samsung TouchWiz for awhile now, and I like it. I’ve played with LG’s, and it seems quite on-par.

But just look at this:

LG's newest

Facebook. There. Touch it!

Compared to 4 yrs ago:

Right-Down, Right, ok, Right?

Compared to 10 yrs ago:

Old Kyocera

There's an interface? Where?

This last sort of phone has no affective association (consumer gratitude for being simple, easy, beautiful) as much as the newer phones. Perhaps this is evidence of over-indulgence of luxury, but if I’m going to use this device, then I want it easier. I’m going to switch each time to another brand, trying to find a better edition. But worse off, the companies back then never stopped changing their interfaces, making it more and more confusing to consumers looking to latch-on. I’d be willing to bet Nokia owns the world-market simply on the history of a consistent Symbian interface.

Comcast’s math

Just got a notice in the mail from Comcast:

“You recently received a message from Comast that stated that we offer ‘unlimited’ high speed internet usage. The message you recieved was in error on this point. Comcast has a usage threshold of 250 Gigabyes per month.. We deliver a high value Internet service that gives you .. the fastest download speeds available – up to 50 Mbps.”

Let’s do the math:

250 GB = 2000000 Mbits
2000000 Mbits/50 Mbits = 40000 seconds
40000 seconds / 3600 seconds = 11.11 hours.

Seriously? I can only use your service for 11 hours out of the 30 days (720hrs)?? That’s 1.5% of the time. That’s worse than pulling a play from a doctor’s office: 10 minutes after waiting 1 hour.

I can’t believe there’s no competitor in my neighborhood.