Show last two directories of pwd in BASH prompt

21 09 2009

Problem: Show current directory and one above it in bash prompt.

finished bash prompt

finished bash prompt

So ok googling for a few hours produced a failed attempt at using PROMPT_DIRTRIM=2 (which only works on bash v.4 which is not installed on OS X, you can get it from macports so i wish you good luck)

Found a post here that looked like it might have worked… nope. Then I looked this post which was sort of unrealated but there was a useful comment from swobodin which i used to get this to work.

The function is:

function last_two_dirs {
pwd |rev| awk -F / '{print $1,$2}' | rev | sed s_\ _/_
}

So I dropped that in my ~/.bash_profile and I call the function from my export PS1 line (with colors and git functions too):

export PS1='\[33[0;32m\]$(date +%H:%M:%S) \[33[0;36m\]$(last_two_dirs)\[33[0m\]$(__git_ps1)\[33[0;33m\]$(git_dirty_flag)\[33[0m\] ➡  '





MacPorts MySQL + MySQL Gem Install Protips

6 07 2009

We moved off of MySQL at work and I hosed my machine, so I never reinstalled mysql.

The I started working on the upgrade to Rails 2.3 for Rentmappr.com and I realized I needed mysql.

So you know, port install that shit right?

sudo port install mysql5 mysql5-server mysql5-devel

Ok that took forever boo. Yay for PostgreSQL’s quick port and gem install! I suggest moving big projects to that if you can and small ones to sqlite, ditch mysql people its not really worth it.

So now, we need the mysql gem. Gem install that shit.

sudo gem install mysql

uh fuck...

uh fuck...

uh fuck…

So I need to pass it some flags because MacPorts installs everything in /opt

Uh ok… so let’s try –with-opt-dir

almost

almost...

Closer but no cigar.

Now what? Google!

Finally googled for “macports mysql gem split TrueClass” and found the solution:

sudo gem install mysql -- --with-mysql-include=/opt/local/include/mysql5 --with-mysql-lib=/opt/local/lib/mysql5 --with-mysql-config=/opt/local/lib/mysql5/bin/mysql_config

credit: http://codeintensity.blogspot.com/2007/09/installing-ruby-mysql-gem-with-macports.html

Yay!

almost...

fucking finally!





Engineering Goals

16 03 2009

I got a lot of good stuff out of going to Mountain West Ruby Conference this weekend. Sitting here this morning I’ve come up with some goals I have for myself and my engineering team.

  1. Excel at usability
    • This is more a personal goal than anything
    • But its important for us to get right
    • If people can’t fully use our software they find shortcuts and often break things
  2. Improve cross team understanding
    • More pair programming – if we can each better understand everyone’s code, we can make sure we are doing things correctly, in a sane way, and we can better maintain each others code
    • I have learned so much from just spending a few hours looking over other team members shoulders. This helps me come up with new ideas and I better understand our complex code base and algorithms
  3. Improve testing
    • We have really great coverage on our models, i.e. we’ve unit tested the shit out of our code (mostly). However, these tests are way to close to the metal, we need a higher level set of tests (using something like Cucumber and WebRat). We need to know exactly how new features will affect the entire code base from a very high level.
    • This will help in organizing new features, instead of a bunch of us in a room going, “uh, well, uh I think that shouldn’t break anything”, we can say, first, “why?” and then second “this feature will break these X number of things and will take X number of hours to complete”
  4. More Instrumentation
    • how much load can our systems handle?
    • where are our bottlenecks and what pieces of infrastructure need to be retuned/replaced/recoded?
    • who actually uses each product?
    • this will also help us say either “yes, we can add more load, more data, new features, etc…” or “no we really can’t add X feature until we’ve fixed X piece of code/infrastructure”




Helper Methods for render :update do |page|

10 02 2009

@aneiro showed me this the other day and I just got it to work. So here’s what’s up.

Instead of having a metric crap-ton of rjs files I just started doing render :update do |page| in my controllers. This lets you do, as some people complain, javascript view logic in your controller. So I ended up with three actions that each call the same set of JS. Hide that thing, replace this div with a partial, show some stuff, fade some things, change the css class of that table row, etc…

So what you can do is this: define a method in your controller and put all the page.replace_html and page.hide calls in it. Do it. Ok so then in your render :update block you just call that method and pass page to it.

One caveat is you have to actually define your new method as a helper method, which is super easy. Just call, in your controller, helper_method .

Check out the gist: http://gist.github.com/61454





Design By Management = Bad Idea

5 02 2009

Management didn’t get to where they are by being good designers. They do not know what looks good and what looks bad. They do know, I hope, how to run a business.

You should leave complex things like typesetting, color theory page layout, etc to a designer. Management types should worry about getting their khakis to match their wingtips, and what color seats to put in the new Audi.

Steps for not letting management ruin your company’s image:

Step one: DO NOT LET THEM DESIGN THE WEBSITE

Step two: DO NOT LET THEM DESIGN POWERPOINT TEMPLATES

Step three: DO NOT LET THEM DESIGN LETTERHEAD OR LOGOS

Step four: DO NOT LET THEM DESIGN EMAIL SIGNATURES

Management likes to think they can do anything. Its America, anyone can do anything right? No. You are wrong. Management is good at telling people what to do and doing things like quarterly projections and attending bullshit conferences to speak on bullshit panels to other bullshit management people.

They are not designers. They are rarely creative. They rarely know how to even open Photoshop. They need to be told Microsoft Word is not professional design software. They need to be told to not use shitty fonts like Impact and Trebuchet.

If you can’t afford good design help, then fine, leave your image and brand to the wind. Its not like huge corporations ever got anywhere by thinking a lot about how things look and how other people perceive their company through visual mediums. Nope that never happened.





Don’t leave this page cause I said so dialog

26 01 2009

I have a process where I create an object on one screen, and then in the next screen add some information to that object.

Problem is, if you navigate away from that second page I have an object that has no important info attached to it.

My process is a wizard approach to setting up a new account, which only really has a name, and then the account has users and billing info attached to it in separate models/tables. So give it a name and save it, redirect to the next screen and add users and billing.

So I want the “Hey you! Don’t navigate away” dialog to appear on all but a few links and form submits on the add users and billing page. Its actually super easy.


Take a look at this very nicely formated gist
I would put this stuff in code tags and display it here but it looks like crap and I can’t embed gists unless I pay wordpress. And wordpress stripped all my erb and html tags so just go look at the gist.






Give Wikipedia some money, you know its helped you win bets.

22 12 2008

Wikipedia Affiliate Button





Rentmappr.com ToDo

24 11 2008
  • ajax change city
  • lightbox welcome (after choose city) (with a don’t show this again – store in session – if they then login check that option and add to db)
  • get rid of saved_houses div if not logged in
  • scroll_to for images/streetview
  • click city name to choose city in addition to ‘pick this city’ link
  • searching not working




How’d this happen?

29 10 2008

So I’m not really sure how I’m at where I’m at and why its so awesome.

Big news in my life is that my company had to layoff about 20% of our staff, which meant 4 really talented people from our engineering team got fired on Monday.  My boss then writes me in an email that the a huge portion of the company is riding on me and my team (i.e. me, Fernand and Nate) to really make the company succeed.  And that is a little scary but also totally kick ass.  On one hand I’m a little surprised that I didn’t get the axe this week, but on the other hand I fucking rock and maybe its my attitude that’s seen me through this.

Its hard having to see people that i respect and look up to get fired.  Its like I got chosen for the kickball team b/c the captains are betting that what I provide is more valuable than what the other people who didn’t get picked provide. Weird.

So I’m sitting here looking back at life over the past few years going “wow what a fucking crazy ride” and sure its not “i’m touring the world with a band a djing” kinda crazy, which would have, or could still be really cool, but I somehow have built a career out of pretty much nothing to the point where people are betting on me to make shit work for them.

At the same time I have a pretty awesome living situation with people who actually are in similar boats as me and to boot I get along with and actually hangout with AND can talk to about work (believe me girlfriends don’t want to hear about programming and design) AND who are into the same kind of art and music shit that I’m into.  Awesome.

I feel like the life I’ve wanted to live has presented itself to me.  And a lot of the lives that I was trying to live in the past few years never felt quite right and now this, this finally feels like me.  Life is being lived solely for me.  The breakup this summer was really crazy and hard to deal with but really, I’m glad it happened.  Looking back at some pictures tonight I wasn’t in that relationship for the right reasons even though I was happy, I wasn’t as happy as I am now.  And I have to know that I can be happy and at ease with who I am and with what I love about life and that there are people who will respect and appreciate me for that.

So where I am now is just so awesome.  I mean I got a big big big wake up call this week that my job can disapear over-fucking-night and that the only reason I’ll have a job going forward is because of my hard work and that I’m smarter and more talented than the rest of the world, and I am, I’ll tell you all about it. Not to say that I don’t have people that I greatly respect, Tim Pease, who got fired, being one of them, but wow, this whole shit is up to me to put in the work and be smart enough to do shit right the first(ish) time.

I want to thank the people that have helped shape me and put me where I am right now.  First my mom, for always pushing me to keep an open mind and have fun, and for my dad for always throwing me into situations I didn’t think i was ready for and forcing me to grow by “sink or swim” oh and he’s a smart mother fucker, I love you, and hate you sometimes, but really, thank you.  Also to the few women that have been a serious part of my life for the last 6 years, thank you for putting up with me and putting up with my whining and my never thinking i’m good enough, seriously, it had to be rough.

So yeah, life’s pretty freaking real right now and pretty freaking unreal in a lot of good ways.  The future is bright and shining with a thunderstorm on the horizon, good thing I have big ass sunglasses and an umbrella.