Monthly Archives: April 2014

Daily Vitamin #15 – iOS Web Server, Ubuntu 14.04LTS

Lightweight GCD based HTTP server for OS X & iOS (includes web based uploader & WebDAV server)

GCDWebServer was originally written for the ComicFlow comic reader app for iPad. It allow users to connect to their iPad with their web browser over WiFi and then upload, download and organize comic files inside the app.

GCDWebServer

Ubuntu 14.04LTS – New LTS, desktop looks lot more like Mac OS X, which means it’s friendlier to use.

Tips for Starting Haskell

I began recording a series of Haskell screencasts, but as always, had to move all my focus aways from anything personal due to work. Rather than throwing the notes away, I’ll post some of them here as I go through my spring cleaning.

Below are the links I was going to mention in the screencast.

To install Haskell on your Mac, use Homebrew by following these steps:
$ brew update
$ brew install haskell-platform
$ echo 'export PATH=~/.cabal/bin:$PATH' >> ~/.zshrc
$ cabal update

Please be advised that I use zsh, so that’s why the third step is .zshrc. If you use bash, then change that to .bashrc or .profile.

To verify that the installation, start ghci.

cabal is a package manager for the platform. Test the cabal by installing pandoc (since it’s an essential tool, right?) for documentation since we all LOVE documentation. 😉
$ cabal install pandoc

BTSync – Better Alternative to Dropbox

Although I still think that Dropbox is a great service, I just didn’t like the limitation and uneasy feeling of having my files sitting on someone else’s server. That’s why when BTSync came out, I decided to give it a try and it’s been a year since I switched and thought it was about time I gave my thoughts.

I won’t go into technical details here, but it’s not any insecure than other services. You can find more about it at https://www.bittorrent.com/sync

BitTorrent_Sync_Beta

Things I Like

1. The file syncs lot faster between my computers.
2. Works without making me think about it.
3. The files are on my machines and on my server with a web UI. See below.
BitTorrent_Sync
4. Free!!!
5. Automatically syncs anywhere.
6. Did I mention it’s FAST?
7. Super easy to set up.

From Security Now

Final Thoughts

Don’t let the “beta” fool you. I’ve been using this for over a year and didn’t even know that this was still in beta. It’s lot better than Dropbox since it also keeps versions for you just in case you make the mistake of deleting files. I personally believe that BTSync IS the Dropbox killer. I have yet to find anything that would make me think that Dropbox is a better product.

Cocoa’s Nil Behavior to Ruby

As you may or may not know, when you send a message to nil in Cocoa, it doesn’t do anything and certainly doesn’t raise any exception. You may or may not agree with the design, but we’ve all programmed just fine with this fact.

Having said that, what if you wanted the same behavior in Ruby?

NilClass.class_eval { define_method(:method_missing) {|*args| self} }

Is this a good idea?

* this is a code joke, please don’t take it too seriously

Management

If you’re a manager or is about to become one, try these lessons I’ve learned starting from business school (I have a degree in Finance) and all throughout my career at this point. I realized that I’ve forgotten some of these and this is a great reminder.

The best managers do not “manage”, instead, they inspire and create a working environment for others to flourish. They also hire the right people for the job with the personality that fits the team, no matter how talented someone is. The same goes for getting rid of anyone that throws off the team balance.

Here’s my list of “things”:

  1. Always eat together. I made it mandatory for everyone to eat lunch together. I never compromised on this and you shouldn’t either.
  2. Don’t interfere with productive creativity. In other words, stay out of the way and let people soar.
  3. Learn to sell your ideas. The sales skill I learned (yes, it’s learned, not born with as some people would say) still applies to all aspects of my life.
  4. Always put yourself in their shoes.
  5. Entertain. People should look forward to talking to you, not dread it
  6. Protect your people. Never throw anyone under the bus, even if they deserve it.
  7. Listen!
  8. Don’t try to change things that will never change. It’s okay to accept the fact that cows can’t talk no matter how hard you try to teach it.

Rehashing Old Contents

I’ve realized that when I switched over to selfthis.com, I abandoned lots of personal notes from RubyHead blog. In any case, now that I’m going through digital spring cleaning, I’m going to transfer them here.

Passing in Arguments to Rake – My Way

** This is an update from RubyHead post ***

I’ve seen many interesting ways to pass arguments to rake tasks. The fact of matter is, I really don’t like messing around with any constant or global variable. Here’s how I like to do it.

rake mytask:do_something 1 2 3

Arguments 1, 2, and 3 will be available in the task. Therefore, if you look at the arguments($*), you’ll see [“mytask:do_something”, “1”, “2”, “3”]. Just reject the first in the Array and you got yourself arguments

Here’s another example of passing in “Hash”. This is with quotes because there’s a bit of manipulation needed.

rake mytask:do_something setting:WHATEVER user:me

Using the argument facility built into Ruby, just create a hash inside of my task. I can even create a method to do this for all tasks. Below is my implementation.

desc "my task do something"
task :do_something => :environment do
  options = {}
  $*.each {|arg| options[arg.split(":")[0]] = arg.split(":")[1]}
  options.reject! {|k,v| v == "" || v.nil? }
  # I now have {"setting" => "WHATEVER", "user" => "me"}
  # for whatever I want to do.
  # ...

  exit
end


Make sure you have exit or it will try to run arguments as a series of tasks.

I think it’s cleaner and easier way to do it, but that’s just my opinion. By the way, $* has an alias, ARGV.