student, traveler, technologist

Category Archives: Uncategorized

Post navigation

I’ve been an iPhone user since Novem­ber 2008, and tonight I bought my first Android device. It’s the Motorola Back­flip. Even though the phone is only run­ning 1.5 (sup­pos­edly to be upgraded to 2.1 in the next cou­ple months), it has a ton of fea­tures that I found myself desir­ing on the iPhone.

First and fore­most, it dis­plays noti­fi­ca­tion icons while locked to let me know if there is a new email from work or not. Really Apple? Is that so hard? But Android/MOTO­Blur doesn’t stop there; oh no, they actu­ally dis­play dif­fer­ent noti­fi­ca­tion icons for each email account. Sweet­ness. Gtalk? Inte­grated and run­ning in the back­ground. AIM? Inte­grated and run­ning in the back­ground. Pho­tos for con­tacts? Face­book. Awesome.

I was even able to cre­ate a new ring­tone with­out hardly any effort. I con­nected via USB, cre­ated a folder called “music” and drop a cou­ple of mp3 files in there. Unmounted it, and bam I can play the music from the media wid­get on my home­screen. I then down­loaded ring­droid from the Mar­ket­place and selected about 30s worth of a song, sav­ing it as a ring­tone. I con­nected the USB again, and what do you know: /media/audio/ringtones has been cre­ated and has a new mp3 in it. I copied that up to my linux box, con­nected my fiancé’s phone, copied the folder struc­ture down to her device (also a Motorola Back­flip), and then assigned the ring­tone to my contact.

Done. Less than 5 min­utes and I’ve got­ten a cus­tom ring­tone from my per­sonal music col­lec­tion. Fan­tas­tic. Well played Motorola and Google!

One down­side: Yahoo! search on the home screen.…. Solu­tion: delete it, and set browser home­page to google.com. Fixed. :)

As men­tioned in the pre­vi­ous entry, my good buddy Jayson is going to con­tribute addi­tional programming/technical/geeky arti­cles on the blog. Below is his first such arti­cle. Enjoy!

Today’s arti­cle is going to be about CMake. I started using this at work recently. It took a bit of time for me to get it work­ing with my setup at work; fig­ur­ing out how it oper­ates. So I’m here to pro­vide hints so that maybe if you’re start­ing out using CMake, you can have a bet­ter clue as to how to use it.

This guide is going to be generic and assume a gcc devel­op­ment envi­ron­ment; be that MinGW inside Win­dows or gcc inside Linux.

First and fore­most, as their doc­u­men­ta­tion states, you need a CMakeLists.txt file in each direc­tory you’re going to do some com­pil­ing in.

For just a sim­ple basic sin­gle file appli­ca­tion, you would have this as your direc­tory and file structure:

Now, on a Linux sys­tem, this is what I typed at the com­mand line to gen­er­ate Unix Make files: cmake –G “Unix Makefiles”

The above com­mand will then parse through the CMakeLists.txt file and gen­er­ate every­thing needed to build the project. After it com­pletes, all that is needed is to type make at the com­mand line. Actu­ally, from here on out, if you were to add other source files to the project, all you’d need to do is type make. The only time you ever need to run the cmake com­mand directly is the first time you run it. Every other time, you can sim­ply type make.

Now, the above small lit­tle project isn’t exactly using any­thing use­ful. Most of the time, if you’re doing a project, you’re using other libraries. CMake includes search func­tions for a lot of libraries. The syn­tax for search­ing for each library is fairly sim­i­lar, so I’m only going to give some exam­ples for a couple[1].

First, we’ll high­light using the wxWid­gets library. We’ll start with the struc­ture in the CMakeLists.txt file as to how to search for wx.

Now, this is still pretty sim­ple, but I’ve added a few things that I’d like to elab­o­rate upon. First, find_package(). Shipped with CMake are, as men­tioned above, some func­tions to search for pop­u­lar libraries. To use these, just call find_package() with the library name, some COMPONENTS you’d like to use from the library, and whether those com­po­nents are REQUIRED. What this does is searches the sys­tem for the pack­age, and the sub-components. If it finds them, the com­po­nents listed are auto­mat­i­cally added to the link stage. How­ever, as the code states below the find_package() call, you still need to explic­ity add the include and link direc­to­ries. Each library may have dif­fer­ent syn­tax for these vari­ables, so don’t blindly assume they are all the same.[1][2]

Next I add a vari­able to store the source files in. I just use this as a con­ve­nience, so that just in case I use it in mul­ti­ple places, I only have to type the variable.

Now that we have that work­ing, we’ll move on to add boost to our pro­gram. We’ll still not have it be very elab­o­rate. We’ll take one of the asio demo’s, so that we can use actual libraries; in addi­tion to some header only stuff.[3]

The lay­out stays the same, but here’s the mod­i­fied CMakeLists.txt file:

Now, the above will copy all the header files in the direc­tory list­ing, exclud­ing the .svn direc­tory. With­out the exclude, the .svn direc­tory would get copied to the instal­la­tion path. That will han­dle include pathing for your own cus­tom library, but the instal­la­tion of the library itsel would go like this:

add_library( STATIC )
install(TARGETS ARCHIVE DESTINATION lib)

This would cre­ate a sta­tic library [.a|.lib] for your project and then copy it to the lib direc­tory on the DESTINATION path. This path can be set up by set­ting the following:

I’ve started a cryp­tog­ra­phy class at DePaul and dur­ing the first lec­ture we first reviewed the Extended Euclid­ean Algo­rithm. It pro­vides a method, using only a table, pen­cil, and paper, to eas­ily find not just the gcd of two inte­gers, but the s and t val­ues as well. Aca­d­e­m­i­cally: Let a and b be two inte­gers, at least one of which is nonzero, and let d = gcd(a,b). There exists some val­ues s,t such that d = sa + tb.

When it was cov­ered in class, the table didn’t have the k col­umn as it does in Wikipedia so I didn’t quite grasp it the first time through. When I’m unsure of some­thing I attempt to write imple­ment it in code. So below is my quick Python imple­men­ta­tion of the Extended Euclid­ean Algo­rithm for find­ing d, s, and t, given a and b in d = gcd(a,b) = sa + tb . Not quite sure what we’ll use it for, but I have no doubt that I will learn that soon enough!

Recently I’ve wanted to review the account per­mis­sions on my home server that I use for backup. It has some­times served as a sand­box of sorts; not best prac­tice, but real­ity for hardware/monetary lim­its. Rather than spend the time right-clicking and check­ing the per­mis­sions on each folder I thought it’d be nice to write a WMI script to gen­er­ate a report.

I knew this had to have been done before, and after some quick googlefu I can across this script by Amine Abdelka­der that basi­cally did every­thing I wanted.

I didn’t like the HTML out­put though, I want CSV so that it can be eas­ily sorted, fil­tered, manip­u­lated in Excel. I also wanted to con­trol the depth of the search into sub­fold­ers and the total num­ber of fold­ers it would report on.