henry sztul

henry sztul

Physicist. Entrepreneur. Dad.
more about me @ henry.sztul.com


MySQL:Ex-Girlfriend :: MongoDB:Wife

MySQL is like an ex girlfriend.  She’s great, but you’re sick of here rules and nitpicking. You’re just over her.

MongoDB is like your wife.  You love her with all your heart.  She is thoughtful, caring, all you’ve hoped for.

Redis is like a mistress, the one you sneak out to on a cigarette run.

(Analogy conceived by @henrysztul, @mkrecny, @davidykay)

[This post in no way reflects my personal situation, views on dating or marriage.  Its just meant to be a funny analogy conceived while coding]

Getting RVM + Ruby 1.9.2 + Textmate to Play Nice

As I am getting a new dev environment setup this is something thats been bothering me on my old setup… below is the fix! 

You’re going to want to replace: ~/.rvm/bin/textmate_ruby

Here are the steps to do so: 

  1. cd ~/.rvm/bin
  2. mv textmate_ruby old.textmate_ruby
  3. Create a shell script called textmate_ruby in the same directory to replace the soft-link, using the following contents:
    #!/usr/bin/env sh 
    source ~/.rvm/scripts/rvm 
    cd . 
    exec ruby "$@" 
    
  4. chmod +x textmate_ruby

That should do it!


    (Source: stackoverflow.com)

    The Boxee Box, Remote Debugging, and OS X

    Starting to do some development of an HTML app for the Boxee Box.  Rob @ Boxee told me that I could enable remote debugging to my dev machine.  Awesome, right?!

    Turns out if you are on OS X there are some small hoops that you have to jump through to get this all set up to work.  Those hoops are outlined below [1]:

    1) In /etc/syslog.conf note the file that local0 is writing to.  I have local0.* set to write to /var/log/boxee.log

    2) Change the syslogd startup procedure:

        You should edit: /System/Library/LaunchDaemons/com.apple.syslogd.plist

        Ironically, uncomment the lines after the comment: Un-comment the following lines to enable the network syslog protocol listener.

    3) Restart syslogd by running:

        > launchctl unload /System/Library/LaunchDaemons/com.apple.syslogd.plist

        > launchctl load /System/Library/LaunchDaemons/com.apple.syslogd.plist

    And if your firewall is off, or better yet configure your firewall properly, you should be able to monitor your log however you wish… I am using tail -f /var/log/boxee.log 

    Voila!

    _____

    References:

    [1] http://meinit.nl/enable-apple-mac-os-x-machine-syslog-server

    Mongomapper, Embedded Documents, and Callbacks

    Here’s the story:

    Imagine you have a mongodb Document, lets call it Parent.

    Now lets imagine that a Parent has many Children so those Children are an embedded document within the Parent document. Great. All setup.

    Now, suppose after you create a Child you want to run a callback, after_create, to give that child an eye color (ie something like :eye_color => “blue”).

    Well, it turns out that embedded documents respond to their parents lifecycle instead of their own.  So our after_create callback would only get run for the first born child… (first kids get everything, don’t they?) not cool.

    My solution goes something like this…

    In my Child model I now have:

    class Child
    include MongoMapper::EmbeddedDocument
    embedded_in :parent

    after_validation :color_eyes

    def color_eyes
      if self.updated_at
        self.eye_color = “blue”
      end
    end

    So the method color_eyes will only get run when a document has not been updated yet.

    A hack, but its where I am right now.  Any better ideas?? Let me know!

    Kill a list of processes by their name (unix)

    I wanted to kill all processes (belonging to me, USER) that started with the same string, (EXPRESSION).

    The following does just that.

    ps -u USER | grep EXPRESSION | awk ‘{print $2}’ | xargs kill -9

    HTML5 Rocks

    html5watch:

    Google’s has a new tutorial site aimed at helping developers dive into HTML5. Pretty nice!

    How to Create a Valid Non-Javascript Lightbox

    Cool use of purely HTML and CSS to get our friend the Lightbox!

    Python Library for Google Search - good coders code, great reuse

    Top