MySQL: Innodb Memory Usage Formula

December 23, 2008 – 3:43 pm

I hate looking for this….

This will give you a rough idea of your innodb memory usage. I know it’s in a hundred spots, but i hate looking for it when i double check things.

innodb_buffer_pool_size
+ key_buffer_size
+ max_connections*(sort_buffer_size+read_buffer_size+binlog_cache_size +2MB)

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Reddit

Linux: use lsof to find which files are open by a process

December 23, 2008 – 3:33 pm

lsof works under linux and MacOS X and will help you figure out what files are open.

lsof | grep ‘mysqld’

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Reddit

On cocoa…

December 21, 2008 – 7:01 pm

I found this pretty amusing…

me:
i’m terrible w/ cocoa
i don’t particularly like objective-c
it’s to verbose

matt:
[me putonSock:blueOne onFoot:rightFoot ignoringHangNail:YES]

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Reddit

Quickly Check every PHP file in your project for errors

December 16, 2008 – 12:28 pm

Here’s a quickie - make sure every PHP file in your project parses correctly.

find . -name ‘*.php’ -exec php -l {} \; | grep “Errors parsing”

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Reddit

OS X: Spaces + Fluid = Awesome

November 29, 2008 – 3:41 pm

I’ve tried so many times to use Spaces, and I keep failing. As useful as it *should* be, it just never was. And I’ve finally realized why. Most of what I do is in a web browser. And spaces just wasn’t made for that. I want Gmail to always be in space 3. Facebook on 4. It just wasn’t meant for that.

I’ve recently discovered Fluid. Fluid brings creates Site Specific Browsers. This means I have an actual application that I launch called Gmail. It’s independent from everything else, doesn’t crash when Safari does (which, to be honest, is all the time). I can assign it to a space. So good.

Also, I’ve discovered hitting F9 (expose) after triggering F8 for spaces, it’ll do expose over all the spaces. Pretty cool way to organize.

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Reddit

Switching from SVN to git

November 12, 2008 – 4:54 pm

I’ve been using SVN for several years now, so I’ve been partial to it, and reluctant to switch to another form of source control. I’m very comfortable with it, and I’ve got dozens of scripts to augment it and help me deal with it’s shortcomings, as well as a few blog posts.

  • Easier to create a repository from existing code.
  • This is the first thing I noticed about git that absolutely crushes subversion. With subversion, you have a repository that you check files out of. With git, you can literally create the repo while you’re in a directory.

    git init

    The above line creates a new repository for you in your current directory. Everything in there is now under version control. It’s awesome. So simple and elegant.

  • Git stash is really, really cool.
  • It’s nice to see that other people encounter the same problems I do when using SVN. I’d be working on something, need to switch to a different branch, but I don’t want to commit my work. It’s not done, and I didn’t create a branch to start. Yes, I should have, but I thought it would be less than an hours work, and SVN’s merging kind of blows. So I didn’t.

    Use git stash when you want to record the current state of the working directory and the index, but want to go back to a clean working directory. The command saves your local modifications away and reverts the working directory to match the HEAD commit.

    Yes, there are ways around this in SVN, but it’s still a pain to merge in changes when I’m done. Merging in your temporary stash is simple:

    git stash apply

    On my first day using git, I had already used this feature. Very handy.

  • I finally understand why I’d want the entire log on my machine.
  • I’ve always worked out of an office where my repo was on a gigabit line and was sitting nearby. I also was usually SSH’ed into the machine so I could just do the commands remotely and see the output. However, I’m doing some work over a VPN, and using SVN is incredibly slow and annoying. It’s also over http only, so I’ve lost my sweet file:///. Git absolutely crushes SVN here.

  • The git client supports SVN.
  • It’s nice that I don’t need to migrate everything over right away. I like making commits that aren’t shared with everyone right away, since I might do a lot of work that I consider valuable, but doesn’t end up compiling or working at all. I realize I could branch here, but I’m not always on top of things. This ties into the stash mentioned above.

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Reddit

I Like the Genius feature of iTunes

November 12, 2008 – 4:36 pm

There’s a lot of people who don’t seem to like the genius feature of iTunes. In fact, quite a few seem to hate it.

The complaints vary. I’m still confused by this complaint by my friend David. He wants iTunes to recognize band names after he’s changed them. If a band has a name, why should iTunes still recognize the band name after you’ve changed it?

Of course, there’s always things that can be improved. Here’s a few ideas that I’d like to see, in no particular order.

  • Do not include songs that I’ve rated less than 3.
  • There’s a reason why a song in my library has a 2. Lets just assume I know that I don’t particularly like a song that I’ve given a 1 or 2. Or, make it an option. If it already is, then I’m a jackass and I can’t find it. Leave a comment letting me know where it is, if this is the case, and I’ll gladly choose it. Or, it could be solved by the next feature…..

  • Let me pick which playlists genius selects from
  • Say I’ve got a playlist of “songs I never heard”, which might be 8 thousand songs. I’d like genius to pick songs similar to “Cyanide” off the Death Magnetic Metallica Album, but only ones I’ve never heard before. Why? To do it’s job and find my music I’ve got stashed away and have no clue what it is.

  • Let me add songs to the playlists that I opt to save.
  • The current version of the genius playlists do not allow me to add songs that I feel are appropriate. That’s kind of a bummer, because if I click refresh, and then realize a great song was left off, I’m stuck. The only solution right now is to select all and create a new playlist from selection (shift apple n). Not terribly inconvenient, and I don’t even know how’d you deal with the UI mess of hitting refresh again and losing your customizations. Lose them completely probably.

  • Not genius specific, but I’d like to see more flexible smart playlists.
  • I just want an SQL like syntax for building playlists with nested AND OR support. I’m pretty sure I’ll NEVER get this. However, it seems like it wouldn’t be too bad to write if there’s a decent lexer/parser out there for objective C. I haven’t explored that.

    I’m aware I can create playlists based on other playlists. Unfortunately I’ve got about a dozen playlists laying around that I don’t even listen to. I know, put them in a folder. Yes, I’m nitpicking.

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Reddit

Erlang Records Cheatsheet

November 11, 2008 – 7:59 pm

I hate looking stuff up. I just like having this type of thing 1 click away, in a nice summary. This post is mostly for me.

Define a record:

-record( rule, {ruleid, site, rule, original} ).

You can define a record in the shell using rd:

99> rd(rule, {ruleid, site, rule, original} ).
rule

Create an instance of a record:

100> A = #rule{ ruleid=1, site=2, rule=2, original=3}.
#rule{ruleid = 1,site = 2,rule = 2,original = 3}

Access a single field in a record:

101> A#rule.original.
3

Extracting multiple fields:

102> #rule{ruleid=B, site=C, rule=D, original=E} = A.
#rule{ruleid = 1,site = 2,rule = 2,original = 3}
103> B.
1
104> C.
2
105> D.
2
106> E.
3

Recommended Reading
Introduction to Records

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Reddit

Erlang: Installing Leex

November 10, 2008 – 6:59 pm

Leex is an erlang version of Lex, a Lexical Analyzer Generator written by Robert Virding. Robert (and several others in #erlang on freenode) were incredibly helpful and considerate in helping me understand these tools.

Leex is a tokenizer. It breaks the pieces of your file or text into tokens. You can then use a tool like yecc to take these tokens and generate useful parsers.

First, you’ll need the source. Leex source is available here. Go down to the last post in the forum, download the attached file.

  1. Create a directory for your erlang packages. I chose ~/erlang.
  2. Drop the leex directory in your new erlang package directory.
  3. Edit your ~/.erlang file (it probably doesn’t exist yet) to include this line, making sure to use the path to your erlang package directory instead of mine:

    code:add_pathz(”/Users/jhaddad/erlang/leex/ebin”).

You should be able to use the leex libraries now.

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Reddit

4 GB of RAM for Mac Laptop is only $61….

November 7, 2008 – 1:39 pm

OK, so I haven’t bought new RAM in years, but still, $61 for 4GB of ram?

Unreal.

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Reddit