Sunday, March 26, 2017

Handy Perl for Tax Time

Convert

1/15/15 Bought 10 MXL MAXLINEAR INC $14.38 4.95 164.2
1/2/16 Bought 60 MXL MAXLINEAR INC $14.38 4.95 724
3/2/2016 Sold -52 MXL MAXLINEAR INC $17.14 4.95 $0.03 $886.31

to

3/2/2016 MXL 70 886.31 various 888.2

You'll generate a bunch of these I hope and later put the column headings on - in Excel :

sell-date, ticker, quantity, proceeds, buy-date, cost-basis...... profit/loss easy to do in Excel..

Use :

#!/usr/bin/perl -w

open( INFO, "$source");

$cost = 0;
$sale = 0;
$qty = 0;
$buy_d = '';

while( ){
 /^\s*(\S+)\s+(\S+)\D+(\d+)\s+(\S+).+\s+\(?\$?([^\s)]+)\)?\h*\r?$/; $type = $2; $date = $1; $q = $3; $tick = $4; $total = $5; $total =~ s/,//g; if( $type =~ /bought/i ){ $qty += $q; $cost += abs( $total ); unless( 'various' eq $buy_d ){ if( '' eq $buy_d ){ $buy_d = $date; } else{ $buy_d = 'various'; } } } else { $sale += abs( $total ); $sell_d = $date;
  $sell_q = $q;
}
print; } $cost = $cost*$sell_q/$qty; print "\n$sell_d,$tick,$sell_q,$sale,$buy_d,$cost\n";

The astute reader will notice that I'm dumping a CSV line - so you could just pipe through perl -p -e 's/,/ /g;' - which will of course mess up the original - but who cares :) CSV's are more useful in Excel..

Saturday, March 25, 2017

Python is Crap Compared to Perl

When it comes to text processing.

Okay, this is a known fact. Question - why hasn't this gotten more attention?

How would you do this?

string : "Mary had a little lamb1" --> "Mary had1 a little lamb" . Okay, a lame example - I want to append a 1 after a d or a b. In perl, it's as simple as s/([db])/${1}1/g . What is it in Python????

Here's a guy who barely scratches the surface. A valiant attempt though .. better half a loaf.

What is the equivalent of using curly braces for variable names within interpolated strings?????

Anyways, here's one way of accomplishing this particular task (Thanks!) :

re.sub( r"(?P)[db])" , r"\g1" , myString )

Enjoy..

Always Valid Excel Time of Last Modification in a Cell

This one is crap : https://www.extendoffice.com/documents/excel/954-excel-created-last-modified-time.html

Look elsewhere..

It's simple :

=NOW()

And then, select that same cell, and Format > Format Cells and click on the one that says m/d/yyyy h:mm and then, when you do that, notice that the Type: field has now gotten populated. Click there and change to m/d/yy h:mm unless you expect to live till 9999 AD :)

And of course, it's not perfect :) You guessed it :) If you undo your change, then the cell doesn't retract :)

Who can be a hero and figure this out?

Sunday, March 19, 2017

Who Are These Geniuses? Instant OCR

And how can I get into the act? Wow!

Chris Brochtrup seems to be the name. Genius doesn't even have a LinkedIn. Man!

Ask and you shall receive

A Giant of Tech - Why Had I Never Heard of Him Before?

Reading this guy's book now and I highly recommend it.

https://www.youtube.com/watch?v=_LXw2PYvdN8

As we struggled to get Pixar off the ground, Deming's work was like a beacon that lit my way. I was fascinated by the fact that, for years, so many American business leaders had been unable to even conceive of the wisdom of this thinking. It wasn't that they were rejecting Deming's ideas as much as they were utterly blind to them. Their certainty about their existing systems had rendered them unable to see. They'd been on top for a while, after all. Why did they need to change their ways?

It would be decades before Deming's ideas took hold here. In fact, it wasn't until the 1980s when a few companies in Silicon Valley, such as HP and AAPL, began to incorporate them. But Deming's work would make a huge impression on me and help frame my approach to managing Pixar going forward. While Tootay was a hierarchical organization, to be sure, it was guided by a democratic central tenet: You don't have to ask permission to take responsibility.

A few years ago, when Toyota stumbled - initially failing to acknowledge serious problems with their braking systems, which led to a rare public embarrassment - I remember being struck that a company as smart as Toyota could act in a way that ran so counter to one of its deepest cultural values. Whatever these forces are that make people do dumb things, they are powerful, they are often invisible, and they lurk even in the best of environments.

IN the 80s, while we were building Pix, Steve was spending most of his time trying to establish PeST, the personal computer co he'd started after being forced out of AAPL. He came to the Pix offices only once a year - so rarely, in fact, that we had to give him directions each time. But I was a regular visitor to PeST. Ever few weeks, I'd head down to Steve's office in Redwood City to brief him on our progress. I didn't relish the meetings, to be honest, because they were often frustrating. As we struggled to figure out how to make Pix profitable, we needed frequent infusions of Steve's money to stay afloat. He often tried to put conditions on the money, which was understandable but also complicated because the conditions he imposed - whether they involved marketing or engineering new products - didn't always correspond to our realities.

No time? Here's someone trying to make money off a summary :)
Toyota Culture : Another pending read

Sunday, March 12, 2017

Who Are These Geniuses?

Ask and you shall receive :)

The infamous position. I've been doing the cube routinely (memorized solutions of course, nothing original) for almost 2 years now.. no clue how I got in this state..

Verdict :


Okay, good to know you can mishandle your cube and have such things happen without some prankster swapping stickers..

And... you betcha - just did the top-right as I was holding it and applied the old moves and got it clean. Good :)

Tuesday, March 07, 2017

Now! Unix Delete All Files (Including Directories) Less Than Five Minutes Old

find . -mmin -5 -exec rm -rf {} \;

Thank you

Now that's what I Call Great Journalism

Except, what's President Dumb going to do about it? He's going to ban immigration into the top paying charities, that's what.

https://www.gfmag.com/topics/syndicate/39743130-charity-officials-are-increasingly-receiving-million-dollar-paydays

Anthony Tersigni : Ascension Health Alliance : $18 million, about 30b in operating revenue

Congratulations Andrea Fuller.

"The leaders of one small ministry earned several times that. Hal Lindsey and his wife, JoLynn, operate Hal Lindsey Website Ministries, a Texas-based evangelical group. Mr. Lindsey hosts the "Hal Lindsey Report, " available online and on Christian television networks, and is the author of books on current events and prophecy.

The charity's revenue in 2014, which came almost solely from contributions, was $8.1 million. The ministry paid Mr. Lindsey $2.2 million and his wife $1.8 million. For each, this included a $1.5 million bonus.

Mr. Lindsey, 87 years old, and his wife, 62, declined to be interviewed. In a written statement, Mr. Lindsey said the bonuses were approved by the board and intended as one-time retirement benefits. He said he worked many years for little or no compensation.

The ministry's IRS filings show it paid Mr. Lindsey less than $50,000 during most years in the early 2000s but paid him and his wife a total of more than $7.8 million from 2007 through 2014."

What about Paula Wallace!! Head of Savannah College of Art and Design - how do they rake in $400 million  year? She raked in $10 million in 2014 and at least 1m a year for the prior 10 years. Here's what she's bragging about :

Letter from the president

Welcome!
Thirty-eight years ago, my family and I invented SCAD ex nihilo. I still marvel at the faith that the very first SCAD students and professors placed — sight unseen — in what would soon become a revolution in higher education. In founding SCAD, I was led by the principle that education is a fundamentally optimistic endeavor, one that presupposes that minds and bodies can be transformed through changes in behavior. Further, I believed that this same principle applied to arts education. Creativity can be taught and refined!