Well, I thought I would share some tricks I use for easy data CRUD’s in C/C++/ObjC. I’m using sqlite here, but could apply to any database.
This is how my data access works - I’m not saying its the best approach, its just how I like it.
saving an account
1234567891011121314
/* The account table name */#define ACCOUNT_TABLE "account"/* a structure representing the account fields */field_mapaccount_values[]={{"login",&acc->login,SQL_TEXT},{"email",&acc->email,SQL_TEXT},{"password",&acc->password,SQL_TEXT},{"timezone",&acc->timezone,SQL_INT},{0}};/* saves the fields to the database */acc->id=db_save(account_values,ACCOUNT_TABLE,acc->id);
As you can see, saving a structure is as simple as creating a field_map table and calling db_save.
loading an account
12345678910
/* loads one account by id */if(db_load_by_id(account_values,ACCOUNT_TABLE,acc->id)!=SQL_OK)fprintf(stderr,"could not load account");/* a callback method */voidload_account_callback(sql_stmt*stmt);/* load all accounts using the callback method */if(db_load_all("account",load_account_callback)!=SQL_OK)fprintf(stderr,"could not load accounts");
Loading is the same for single instances, but I use a callback method to load multiple instances.
AppHarbor is to .NET what Heroku is to Ruby, which is - awsome.
I’ve deployed a silverlight test app, Scrabby, to the cloud with no problems or cost. If you a lover of C# and midly confused by Azure then its cool enough to blog about.
Today I went to go work on an older C project of mine and cringed at the thought of configuring my autoconfigure build system. Needless to say I find it messy and obviously wasn’t working very well if I had to tweak it on a fresh install.
There is a very nice Gem called rake-builder which handles this in a very clean way:
Today I found myself generating HeaderDoc html for a project and implemented a system to host the docs inside my bitbucket repository. Here’s how I did it:
First step is to create a project in bitbucket that is named after your account username in the format username.bitbucket.org.
Clone the project and add an index.html to it. I added bootstrap as well. Commit and push back to master.
Now assume I have a workspace folder devel with project xyz underneath that I use HeaderDoc with. I simply moved the documentation to username.bitbucket.org and made a symlink back to the project.
I use the index.html as a landing portal for all projects with subfolders containing project documentation. You can reference the subdirectories like any other link.
Sites with programmer quotes that always humble me with their laser-like honesty.
I’ve decided to keep a collection of my favourites here (in no particular order).
“They don’t make bugs like Bunny anymore.” - Olav Mjelde.
“Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program.” - Linus Torvalds
“Computer science education cannot make anybody an expert programmer any more than studying brushes and pigment can make somebody an expert painter.” - Eric S. Raymond
“In the one and only true way. The object-oriented version of ‘Spaghetti code’ is, of course, ‘Lasagna code’. (Too many layers).” - Roberto Waltman.
“Talk is cheap. Show me the code.” - Linus Torvalds