Thursday, December 18, 2014

Building Protobuf on OSX

I wanted to play with protocol buffers on my local OSX machine but set up isn't so straight forward so I thought that I'd document the steps.

Step 1:  Get the build tools.

If you have all the build tools installed then skip ahead, but on the particular machine that I was using it didn't.   So I had to do the following:

Install Xcode command line tools

xcode-select --install

Install the GNU build tools (autoconf, automake, libtool):

curl -OL http://ftpmirror.gnu.org/autoconf/autoconf-latest.tar.gz
tar -xzf autoconf-latest.tar.gz 
cd autoconf-2.69./configure && make && sudo make install 
curl -OL http://ftpmirror.gnu.org/libtool/libtool-2.4.2.tar.gz
tar -xzf libtool-2.4.2.tar.gz 
cd libtool-2.4.2./configure && make && sudo make install 
curl -OL http://ftpmirror.gnu.org/automake/automake-1.14.tar.gz
tar -xzf automake-1.14.tar.gz
cd automake-1.14 
./configure && make && sudo make install

Alternatively you can use Homebrew or MacPorts to get the packages.

Step 2: Get the Protocol Buffer Compiler and Build It

git clone git://github.com/google/protobuf 
cd protobuf 
./autogen.sh
configure
make 
sudo make install

Since I wanted to use protocol buffer in Go, I have to install the Go plugin for the compiler:

go get -u github.com/golang/protobuf/proto
go get -u github.com/golang/protobuf/protoc-gen-go 

The system can now compile your proto files to let you use it in your code:

protoc --go_out=. 

Saturday, September 6, 2014

Fun Books for the Software Developers

After the serious readings for programming, algorithms and software craftsmanship here are some fun readings for our profession.

Entertaining History of Our Profession

Hacker Fiction

Rick Cook’s Wizardy series is a fantasy series for computer buffs that tells the story of a Silcon Valley hacker who finds himself in a different world where he discovers that magic can be “programmed” and is asked save the world from the “Dark League”. Rick Cook definitely have some familiarity with programming and I found his stories to be a fun read and his computer humor entertaining.


Friday, September 5, 2014

More Books for the Professional Developer

My previous post of books for developers focused on programming, but if you’re a professional programmer/developer/software engineer there are more things you’ll need to know besides writing code and algorithms.
Here are some books that I recommend for the professional or those who work with programmers.
The Mythical Man-Month: Essays on Software Engineering, Anniversary Edition (2nd Edition) - Describes Brooke’s Law that adding man power to a late project makes it later and other wisdom of software development project management.
Peopleware: Productive Projects and Teams (3rd Edition) - Software development is ultimately done by people (not cogs and robots) and it’s important to remember that.
The Practice of Programming (Addison-Wesley Professional Computing Series) - Talks about the practical aspect of programming including “topics like testing, debugging, portability, performance, design alternatives, and style.”
Facts and Fallacies of Software Engineering - A lot of common sense stuff about software engineering that are often forgotten in the thick of our work.
Making Things Happen: Mastering Project Management (Theory in Practice) - There is a level of project management from individuals to teams that every engineering should be aware of. This is a good pragmatic book about getting projects done and not about specific methodologies.

Tuesday, August 12, 2014

Cleaning Up Old Links

I recently started to clean up the http://www.lazyhacker.com website some parts of which I haven't touched in 10 to 15 years.  One of the pages that I was cleaning up with the utilities page that I had put together.

It was very interesting to see how much has changed (and in some cases how much haven't).  Some observations:

A number of the tools and programs that I linked to no longer exists, but a surprising number still do.  Mostly it was the commercial software that disappeared while community and open source stuff are still going strong.

The programming environment has sure changed a lot.  Back then, we tend to look for "utilities" that helped us with our work.  These days things are more on-line web applications and rather then small utilities it's more large applications.

Back then the major online programming resource was DejaNews (Usenet).  Software was obtained from FTP servers and now how many kids even know what FTP is?

We used to share code by zipping it up for download and now you have Github, Pastebin, etc.

EMACS and VIM.  Many will come and many will go, but these two always remain in the conversation.

One noticeable exception around commercial software was Microsoft.  Most of the Microsoft tools that I linked to were not only still alive, but Microsoft continue to make sure all the URLs to them still worked!  They actually do a better job then open source projects such as Fedora (moved from redhat.com to its own domain but no redirect from the old url to the new) and Jikes (IBM didn't redirect the old jikes page to its new domain).

I removed the Java related stuff since I don't do much Java anymore (not terribly sad about that), but I do wonder about the future of Java.  Perl has kind of faded from public view while C is always and will be C.  I haven't touched Scheme if forever!  I added a link to Go.

If I were to create a new page, I think the whole classification of things would be totally different with categories that wouldn't have been there 15 years ago and many of the old categories be unknown to the new programmer.

Monday, August 11, 2014

Books For Every Programmer's Shelf

Here are some books that I believe should be on every programmer’s bookshelf.
The C Programming Language, 2nd Edition” - By the creators of the C language, this concise book clearly teaches the foundations for the C language. For a more tutorial book on C, I would suggest “C Primer Plus”
Wiley’s Teach Yourself C++” by Al Stevens - My favorite book for learning C++.
Programming Pearls “ - A great collection of essays on programming including ways to approach programming problems.
Programming Perl” - The definitive book for the Perl language by the creator of the language.
The Art of Computer Programming, Volumes 1-4A Boxed Set” - This thick 4 volume set is a thick academic tomb of knowledge for computer science.
Software Tools” or “Software Tools in Pascal” - Writing software tools and utilities is a special discipline.
The Practice of Programming” - Easy to read text on programming practices.
Win32 Programming” by Brent E. Rector, Joseph M. Newcomer - While Petzold’s Programming Windows®, Fifth Edition is generally considered THE book on windows programming, I actually like this book better because of its more in-depth coverage of the topics.
Here are some books for the professional programmer that isn’t around coding.

Friday, August 1, 2014

Use Google Drive For Free Web Hosting on Custom Domains

Update:  Google Drive no longer offer the ability to serve web pages so this post is no longer relevant.

Google Drive allows a very convenient and free way host web pages.  You simply share the folder to the public and anyone can go to http://googledrive.com/host/<folder id> with their browser and see your web site.  Publishing a page or any file is just a matter of dropping it into the drive folder.  However, Drive currently doesn't support custom domains so if you have your own domain (e.g. example.com) you can't have http://www.example.com be served from Drive.

There is a site, http://gweb.io, that allows you to do this for about $10/year, but I've never used them or know much about them.  Instead, this article will describe one way to roll your own using Google App Engine (GAE) and if your site only have moderate traffic you should be able to stay within its free quota.  Note:  this was a quick hack I did and not meant to be a high performance web site.  Don't be running your own Google with this!  :-)

The basic idea is very simple.  GAE allows you to have custom domains so you create an app on it and it can map to your domain (e.g. http://www.example.com).  What the app will do is take the URL, translate it to the googledrive.com URL and fetch the page for you and return it through app engine.

From 
http://www.example.com/page1.html 
To 
http://googledrive.com/host/page1.html
With the mapping, use GAE's FetchURL service to grab the file and pass it back to the caller.  That's it.


Follow the GAE tutorial on setting up a basic helloworld app (such as this one for Go).  Instead of hello.go, I have file called "fetch.go" and instead of "package hello" it is "package fetch".  For the content of fetch.go:

Remember to put in your folder ID in fetch.go at line 20 (I should've made it a constant and easier to spot).

Now give it a try on your local server to make sure it works and then upload your project.  If everything is working well, you can them map this app to your domain.  That's it!

Now, this is not very optimized and only really recommended for small sites.  For example, this will fetch from googledrive on every request and the browser might not be able to cache it.  For the former, it would be easy to insert memcache to keep a cached version on the server side.  For the latter, we'd want to stick in some headers to help browsers cache the file unless the file is updated very frequently.

Anyway, with GAE's generous free quota, this might work well for many small sites out there to serve some examples web sites or landing pages.

One question we might ask ourselves is that why use Drive at all if you're using GAE already?  For me it was mainly convenience of being able to just drop the file into a drive folder and 'cause I just wanted to write some Go code on GAE.

Sunday, March 2, 2014

Disabling Anti-Aliasing on Chrome

Update:  To make it easier, I uploaded the files to https://github.com/lazyhacker/chromecss.  Just download it and point your Chrome browser to use it as an extension.

While I love Chrome and it's my favorite browser, the one thing I really dislike about it is the way it handles anti-aliasing.  I really don't like the seeing soft fuzziness around fonts.  It always makes me feel it's blurry.

Previously, to disable the anti-alias in Chrome you would create a "User Stylesheet\Custom.css" file (Chrome doesn't use the OS's font setting) with the following:

body { -webkit-font-smoothing: none; }

But starting with version 33, Chrome no longer load the user style sheet so one day I started Chrome and everything looked fuzzy again!

The "new" way around this to create your own Chrome extension.   All this involves is adding one new file.

Create a new directory and add a new file called manifest.json.  Have the following in it:

{    "manifest_version": 2,    "name": "Disable AntiAlias in Chrome",    "version": "0.1",    "content_scripts": [{        "matches": ["https://*/*", "http://*/*"],        "css": ["style.css"]    }]  }

Then create a file that matches the name used in the line "css": ["style.css"].  In this example, create a file called style.css.

Style.css should have the same thing as what was in the Custom.css file above.

Then on the url bar in Chrome, type "chrome://extensions/" (without the quotes).  Enable the "developer mode" checkbox and click on the "Load unpacked extension" button.  Select the directory that contains your newly created file.

Done.