I came across a really handy tool to validate JSON strings. Kudos to the authors of this tool. Nice job!
Archive for the ‘Programming’ Category
First register the file with subversion for keyword substitution. For example, you may need to add the actual revision number to the source code.
$ svn propset svn:keywords "Revision" source_file.c property 'svn:keywords' set on 'source_file.c' $
Next, edit your source code and add the keywords that you wish to be replaced, e.g.
#define VERSION "V 1.0 $Rev$"
Finally, from now on each time you commit the file to subversion, e.g., after you commit the file:
$ svn commit source_file.c -m "file with rev. id" Sending source_file.c Transmitting file data . Committed revision 190. $
Now if you view your source code, it will have the revision number in the code, e.g.
#define VERSION "V 1.0 $Rev 190 $"
and each time you edit and commit the changes the revision number will be updated.
I was looking for a way to combine PDFs (without using Acrobat) and came across this note.
$ python '/System/Library/Automator/Combine PDF Pages.action/Contents/Resources/join.py' -o '/path/to/output.pdf' '/path/to/input1.pdf' '/path/to/input2.pdf'
This command will generate the PDF and it will echo the following warning (date and name of your computer will vary, of course) which apparently you can safely ignore.
Sun Jun 21 14:58:34 sj.local Python  : The function `CGPDFDocumentGetMediaBox' is obsolete and will be removed in an upcoming update. Unfortunately, this application, or a library it uses, is using this obsolete function, and is thereby contributing to an overall degradation of system performance. Please use `CGPDFPageGetBoxRect' instead.
Better yet, use the Mac Automator. You can use the Automator to combine multiple image files, or PDFs into a single PDF. You can then use the Previewer to re-arrange the pages and delete some of the pages if needed.
So you’ve been writing software for ever but never build a system that interfaces with a physical world. Well here comes Processing and Arduino. I’ve not been this excited about building a prototype since … well a long time ago. The book that sparked my imagination is O’Reilly’s Making Things Talk. Well it all seems pretty easy. Order a pre-built microcontroller such as Arduino USB Board from Sparkfun, connect its input to a sensor, its output to the physical object that you wish to control, program what you want in Java (using Arduino based on Processing IDE right from your MAC laptop), dust off your soldering iron and voila you got yourself a real prototype. I cant wait to receive my Arduino board.
Perl on MAC does not support SSL out of the box. So you must install SSL support:
sudo perl -MCPAN -e "install Crypt::SSLeay"
Looks like that in Rails 2, in addition to changing the default database, default sessions store, now some of the oldies such as render_text method no longer work as expected. If you’ve used
render_text "some text" in a controller, then you’ll need to replace it with
render :text => "some text".
My hosting company (bluehost.com) updates their system software now and then without any e-mail notifications to their users. Unfortunately, if you host a Ruby on Rails application (in my case sharepdf.com) each time they upgrade Ruby on Rails, there is a good chance that something will break. Recently, they upgraded to the latest version of Rails (2.0.2) and needless to say, my Rails application stopped working. It turns out that the latest version of Rails has changed the default sessions store from a file store to a cookie store. The problem is that if you stored anything other than a simple data in your session, then to get your application to work, you have to spend a few days porting your application. The fact that Rails upgrade is not backwardly compatible is really annoying. But that is a separate issue.
So what is the easiest way to port your file backed sessions application to Rails 2? The answer is to use the database for your sessions. But keep in mind that Rails 2 no longer uses MySQL as its default database. Here is how I ported my sharepdf.com application to Rails 2.0.2:
- Create a brand new rails application using the command
rails -d mysql appname
- Edit environment.rb file and explicity state that you wish to use database for sessions: simply uncomment this line:
config.action_controller.session_store = :active_record_store.
- Use the command
rake db:sessions:createto create the database definition for the sessions.
- Use the command
rake db:migrateto actually create the database tables (I’m assuming that you have updated the
database.ymlwith correct user name and password and have create the database in MySQL). The
rakecommand will then create the sessions database table.
- Copy your controllers, models, views, … from the your current Rails application to this one.
- You should be good to go!
yumto install both mysql command line tool and the server:
yum -y install mysql mysql-server
- Enable the MySQL service:
/sbin/chkconfig mysqld on
- Start the MySQL server:
/sbin/service mysqld start
- Set the MySQL root password:
mysqladmin -u root password 'new-password'The quotes around the new password are required.
Quite often I need to tail a server log file on a site that I need to login to using SSH. The task of opening a terminal, creating a SSH session, login, and then tail does get tedious. So here comes ssh with the -t option. Here is an example, where you CD to the appropriate folder and then tail the log:
ssh -t email@example.com 'cd /var/log/tomcat/myserver; tail -f catalina.out; $SHELL -i'
You can add a Flex control to a Google Map by taking advantage of DHTML DIVs and z-order tags. Here I’ve defined a Flex control to display the elevation chart associated with a route. In Flex, I specify the opacity of to be 0.5, this means that the chart will be partially transparent. The z-order of the Flex div ought to be higher than the z-order of the Google Map DIV.
Adding the power of Flex to Google Map gives you to option of selecting the best tools for designing a rich user experience.