Wednesday, November 25, 2009

Using a Simple C Macro inside another Simple C Macro

SOmetimes in C code, you want to put a macro inside another one. You have a string macro that you've defined for use in your code, and you also want to use it to create another string for insertion into a database table. So, you can do the following...

#define SQL_NAME "COLUMN VALUE 1"

#define TAG_INSERT "insert into master (name, type) VALUES "\
"(\' "\
SQL_NAME \
"\', 2)"

Monday, October 26, 2009

Giants plans for 2010

I don't think that the Giants will make any major news in the Free Agent area for 2010. They will be pretty tight in the salary area, and won't know their exact budget until Lincecum's and Wilson's arbitration hearings or contract signings. I expect that they will be owed around $15 million combined for 2010. They may want to sign Penny to a contract, but he should be long gone by the time Lincecum and Wilson are signed. Let's say some team in need of veteran pitching, like the Orioles, offers him 3 years and $30 million, there's no way the Giants can match that, without knowing the impact of the arbitration.

So, the Giants will probably sit tight with a rotation of Lincecum, Cain, Zito, Sanchez and Bumgarner for 2010.

The only real move that I foresee is that the Giants will exercise Freddy Sanchez' option for 2010. They certainly don't have a better option at 2nd base, and if they don't exercise the option, then Sabean will look like an idiot for trading away Alderson.

They'll probably not resign Bengie either, and will hand the catcher's spot to Posey. Winn will not be resigned either. So, your starting lineup for 2010 will be:

C: Posey
1B: Ishikawa/Garko (platoon)
2B: Sanchez
3B: Sandoval
SS: Renteria
OF: Rowand
OF: Velez
OF: Schierholtz
UT: Uribe

I guess that Whiteside will be back as 2nd string catcher, which leaves two open spots on the roster. We'll probably see Fred Lewis back as the 4th outfielder, and Bowker as the 5th outfielder who can also play first.

Friday, September 25, 2009

Ginats Centerfielder

Who would you rather have now, Aaron Rowand at $12 million per year, or Rajai Davis who the Giants released last year?

Rowand .264/.320/.428, 15 HRs, 63 RBIs, and 1 SB. RF/9: 2.44.
Davis: .317/.374/.437, 3 HRs, 47 RBIs, and 40 SBs. RF/9: 2.9.

Oops. I sure hope Rowand rebounds next year.

Thursday, September 24, 2009

Giants Salary Changes for 2010

Fitz and Brooks were talking about the Giants salary savings for next year. I looked into it, and the savings are not that great. Here's what I figure:

Subtractions:

Dave Roberts: 6.5
Randy Johnson: 8.0
Randy Winn: 8.25
Bengie Molina: 6.0
Noah Lowry: 4.5

Additions:

Edgar Renteria: 2.0
Freddy Sanchez: 8.0
Jeremy Affeldt: 1.0
Matt Cain: 1.6
Tim Lincecum: ~4.0
Brian Wilson: ~4.0
Jonathan Sanchez: ~2.0
Ryan Garko: ~1.0

Lincecum, Wilson and Sanchez are all eligible for arbitration (I think). It also looks like Brandon Medders and Justin Miller will be eligible for arbitration too, though
I wouldn't think that they'd get huge raises.

Approximate net savings = 33.25 - 23.6 = 9.8 million.

Pablo Sandoval will probably be a super two and be eligible for arbitration in 2011. The Giants should also plan for him getting a big raise in 2011.

Monday, June 29, 2009

SQLite sample code

#include

#include "sqlite3.h"

static int callback(void *NotUsed, int argc, char **argv, char **azColName){
int i;
for(i=0; i
printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
}
printf("\n");
return 0;
}

int main (int argc, char *argv[])
{
int rc = 0;
sqlite3 *pDB = 0;
char *createTable = "CREATE TABLE IF NOT EXISTS T (ID INTEGER PRIMARY KEY, Y, Z)";
char *insertStmt1 = "INSERT INTO T VALUES (1, 2, 3);";
char *insertStmt2 = "INSERT INTO T VALUES (2, 2, 3);";
char *szErrMsg = 0;

rc = sqlite3_open("foo.db", &pDB);
if ( rc != SQLITE_OK )
{
printf("Failed to open/create database foo\n");
return -1;
}
printf("Database foo opened successfully.\n");

rc = sqlite3_exec(pDB, createTable, callback, 0, &szErrMsg);
if( rc != SQLITE_OK ){
fprintf(stderr, "%s: SQL error: %s\n", createTable, szErrMsg);
sqlite3_free(szErrMsg);
}

rc = sqlite3_exec(pDB, insertStmt1, callback, 0, &szErrMsg);
if( rc != SQLITE_OK ){
fprintf(stderr, "%s: SQL error: %s\n", insertStmt1, szErrMsg);
sqlite3_free(szErrMsg);
}

rc = sqlite3_exec(pDB, insertStmt2, callback, 0, &szErrMsg);
if( rc != SQLITE_OK ){
fprintf(stderr, "%s: SQL error: %s\n", insertStmt2, szErrMsg);
sqlite3_free(szErrMsg);
}

rc = sqlite3_exec(pDB, "select count(*) from t", callback, 0, &szErrMsg);
if( rc != SQLITE_OK ){
fprintf(stderr, "BEGIN TRANSACTION: SQL error: %s\n", szErrMsg);
sqlite3_free(szErrMsg);
}

rc = sqlite3_exec(pDB, "select * from t", callback, 0, &szErrMsg);
if( rc != SQLITE_OK ){
fprintf(stderr, "BEGIN TRANSACTION: SQL error: %s\n", szErrMsg);
sqlite3_free(szErrMsg);
}

rc = sqlite3_close(pDB);
if ( rc != SQLITE_OK )
{
printf("Failed to close database foo\n");
return -1;
}
printf("Database foo closed successfully.\n");
return 0;
}

Friday, March 20, 2009

How to recursively touch files in current directory

Touch will update the access and modify time of a file, but it doesn't have a flag to descend recursively into subdirectories.

So, to do that, you have to use the find command to start the subtree walk, and have it call touch.

find . -exec touch {} \;

will do the trick!!!

Sunday, March 8, 2009

Dodgers vs. Giants

I was listening to Fitz and Brooks Friday (3/6/09), and a caller called in to talk about the Dodgers signing Manny, and how much better the Dodgers were than the Giants now. Fitz and Brooks disagreed with the caller, and challenged the caller to name one other hitter in the Dodgers lineup. I'm in my car talking to the radio telling the caller some names, but unfortunately, he can't think of any, and somehow that proved Fitz and Brooks' point. So now I'm wondering if they're right. So, here's what I came up with:

Dodgers Lineup Giants Lineup
============== =============
C - Martin C - Molina
1B - Loney 1B - Ishikawa
2B - Hudson 2B - Frandsen/Burriss
3B - Blake 3B - Sandoval
SS - Furcal SS - Renteria
LF - Ramirez LF - Lewis
CF - Kemp CF - Rowand
RF - Ethier RF - Winn

So, I'd make it a tossup at catcher, and give an edge on 3B to the Giants (if Sandoval can come close to what he did at the end of last year). But offensively, I think that the other 6 positions are on the Dodgers side. I think on the defensive side that the Giants have the edge, except at SS where Furcal is probably better than Renteria. In the discussion, Fitz and Brooks didn't talk about pitching, but I'll bring it up. Here's my guess at the rotations.

Dodgers Pitchers Giants Pitchers
================ ===============
S1 - Billingsley S1 - Lincecum
S2 - Kershaw S2 - Cain
S3 - Kuroda S3 - Johnson
S4 - Wolf S4 - Zito
S5 - Schmidt (?) S5 - Sanchez/Lowry
CL - Broxton CL - Wilson

Lincecum is clearly better than any of the Dodgers pitchers, but Billingsley is probably better than any of the other Giants pitchers. I'm optimistic that Cain will have a breakthrough year, and Kershaw is supposed to be the next real thing, but who knows? If Johnson can stay healthy at 45, and replicate what he did last year in Arizona, he'll be at least as good as Kuroda, maybe better. I'm just concerned about his durability. I know longer have any confidence in Zito to be anything but awful. I'd originally thought that he had a good 2nd half last year, but I checked out his 2nd half starts, and they were an improvement over the first half, but they were still pretty bad. So, I'll give the edge to the Dodgers on this one. Sanchez was pretty bad the 2nd half last year, but maybe it was a result of the injuries, and he'll bounce back. Schmidt or whoeve the Dodgers throw out in the 5th spot will probably be worse than Sanchez, right? I'd say that the closer position is pretty equal. Both Wilson and Broxton seem pretty good. So, it seems like the pitching is a tossup to me. Lincecum is the only clear plus for the Giants, Wolf is the only clear plus for the Dodgers. Hopefully, we'll get to see Bumgarner in a Giants uniform soon (maybe in 2009?).