MySQL 5.1.34 and Innodb

June 18, 2009 – 11:47 am

I don’t remember having to do this before, but I had compiled MySQL 5.1.34 recently on my dev box (os x) and I saw a warning on a create table statement. It turns out InnoDB was not enabled (or even listed in the list of storage engines.

Before:

mysql> show engines;
+————+———+———————————————————–+————–+——+————+
| Engine | Support | Comment | Transactions | XA | Savepoints |
+————+———+———————————————————–+————–+——+————+
| CSV | YES | CSV storage engine | NO | NO | NO |
| MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
| MyISAM | DEFAULT | Default engine as of MySQL 3.23 with great performance | NO | NO | NO |
+————+———+———————————————————–+————–+——+————+
4 rows in set (0.00 sec)

After:

mysql> show engines;
+————+———+————————————————————+————–+——+————+
| Engine | Support | Comment | Transactions | XA | Savepoints |
+————+———+————————————————————+————–+——+————+
| CSV | YES | CSV storage engine | NO | NO | NO |
| MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
| InnoDB | YES | Supports transactions, row-level locking, and foreign keys | YES | YES | YES |
| MyISAM | DEFAULT | Default engine as of MySQL 3.23 with great performance | NO | NO | NO |
+————+———+————————————————————+————–+——+————+
5 rows in set (0.00 sec)

I had to recompile MySQL with the following:

./configure –prefix=/usr/local/mysql –with-plugins=innobase

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

New Mac Dev Box Software Checklist

May 27, 2009 – 1:53 pm

When I get a new Mac, I go through the same steps every time. Yes I use a Mac as a dev box.

Software

Xcode
Adium
Launchbar
iTerm - change defaults to black background. (edit bookmarks, default, background)
Apache HTTP Server (source)
MySQL (source)
PHP (source)
Eclipse PDT
Omnigraffle
Fluid
BBEdit
SubEthaEdit
Git
SVN
Memcached

Tweaks

Remove everything from Dock.

Fix the look of the dock.

defaults write com.apple.dock no-glass -boolean YES
killall Dock

/etc/bashrc tweaks

alias v=”ls -lahG”
alias vi=”vim”

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

Mono Install Bug (Found when using Eclipse)

May 8, 2009 – 12:52 pm

I got this error after installing the Mono framework on MacOS X 10.5.6 and trying to set up a new project with eclipse.

NAnt 0.86 (Build 0.86.2898.0; beta1; 12/08/2007)
Copyright (C) 2001-2007 Gerry Shaw
http://nant.sourceforge.net

For more information regarding the cause of the build failure, run the build again in debug mode.

Try ‘nant -help’ for more information

BUILD FAILED

Failed to initialize the ‘Mono 3.5 Profile’ (mono-3.5) target framework.

Function call failed.
Expression: ${not pkg-config::exists(’mono’)}
^^^^^^^^^^^^^^^^^^^^^^^^^^

‘pkg-config’ failed to start.

ApplicationName=’pkg-config’, CommandLine=’–exists mono’, CurrentDirectory=’/Library/Frameworks/Mono.framework/Versions/2.4/share/NAnt/bin/’

A few google searches suggested that this might be because pkg-config wasn’t installed - but it’s included in the Mono distribution. I finally realized the symlink wasn’t being created in by the Mono installer. Running the below command fixed everything.

sudo ln -s /Library/Frameworks/Mono.framework/Commands/pkg-config /usr/bin/pkg-config

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

Why is Social Q&A Not Embedded into Operating Systems and Applications?

May 3, 2009 – 9:48 am

One thing that always bothered me about complex desktop applications like Adobe Photoshop or Eclipse, or even Desktop Linux is finding out how to use the more advanced features (or, truthfully, some of the basic features). I’ve always liked community response, so I’ve been on a number of mailing lists and it’s usually really helpful.

What if these types of useful feedback were available within the application itself? You could literally just type a question into your help box, and a minute later you would get answers. This would be incredibly helpful for hundreds of new users.

Answerbag has an available API that could be integrated this way. There are a number of other services that are similar and could be used as well (if they have APIs), such as answers.com, wikihow, or Yahoo! Answers.

An added benefit is now there’s a website with a VERY comprehensive FAQ that’s been indexed by google, and the people who aren’t even using the built in Q&A process can still find answers to their questions. The result? A decreased learning curve which will lead to a bigger user base.

Advantages

  • Very fast response time
  • Answerbag was achieving about a 90% response rate on new questions within just a few minutes, and that’s just from general community.

  • Does not rely on paid tech support, although it can be augmented this way by a company that can afford to do so.
  • Yes, you can get great answers from the community. But sometimes an official response is appreciated. A site like answerbag could add tools so that a parter company could take ownership of a category, reviewing submitted questions and answers for correctness, and modifying or locking answers after they’ve been deemed correct. It would be a departure from the current model of the site, but certainly an authoritative answer would be appreciated by a lot of people. About.com has a similar model, where experts own a particular category and maintain the content there.

  • The community has more time to help people with new problems.
  • Since it would be easier to find older how-to pages, experts can spend less time solving the same problem over and over. They’d be more likely to help people more often, since they wouldn’t be so annoyed.

Disadvantages

  • Initial answers might be inaccurate
  • I think in applications with a larger use base, or more tech savvy areas, this would be less of a problem. I’ve gotten some amazing answers on mailing lists and IRC channels, and I don’t see why the quality of the answers would be any different.

  • Getting the first customer
  • Since no one is doing this yet, the hardest implementation will be the first. It’s likely a company like Microsoft or Adobe wouldn’t want to be the first in the pool for an idea like this, but they’re also the ones that could pull off the best implementation. The true power of social Q&A isn’t really apparent till you get your questions put in front of a few million eyeballs.

    This would be a great opportunity for innovation in open source, in particular at the OS level. Linux adoption is lower than it could be, and it has a lot to do with the difficultly of figuring out some of the more basic tasks.

Since I no longer work on Answerbag, or it’s parent company Demand Media, I have nothing to gain at this point, except for more useful applications.

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

Amazon / Collective Intelligence

May 1, 2009 – 6:21 pm

collective intelligence is cool till you buy 1 macgyver DVD and amazon WON’T FUCKING STOP RECOMMENDING ME MACGYVER RELATED SHIT

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

Geek Links

April 23, 2009 – 3:25 pm
  • PHP Quick Profiler
  • This looks like a pretty cool tool to get a good idea of what’s going on in your PHP script without having to install tools like XDebug and Webgrind / KCacheGrind.

  • Apple files patent for browser specific volume
  • I’m not sure how this is anything new, tons of applications have their own volume setting. Quicktime, VLC, Windows Media Player.

  • Chris DeWolfe bails as MySpace CEO
  • Doesn’t seem like such a bad idea to get out now. It’s essentially just a giant ad for Fox TV shows and movies.

  • Tivo App Store
  • Joel Downs believes Tivo should open an app store. I suppose if they are going to continue with their business model, it would make sense, since it probably won’t be long till the Xbox has Tivo functionality. It might already, but I wouldn’t know.

  • App store hits 1 billion downloads
  • Speaking of an App store, Apple seems to be doing OK. The sad thing is I still haven’t thought of an interesting app to write.

Enjoy!

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

Apparently people hate me

April 22, 2009 – 4:16 pm

Not sure what I did, but I found this at the bottom of my chess game on facebook.

People hate me

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

Enable Mod Rewrite Error Log

April 22, 2009 – 12:53 pm

Just a quickie - throw this in your apache config if you need error logging for mod_rewrite. Useful in a dev environment, not so much in production.

RewriteLog /var/log/httpd/rewrite.log
RewriteLogLevel 9

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

Erlang: Understanding gen_server

April 22, 2009 – 11:08 am

Gen_server is a great way to create simple servers without having to write a lot of code at all. Here’s a brief overview to get you started.

For some reason, figuring out how the gen_server behavior works in erlang was kind of a pain for me. I think it’s because I can’t just implement something, I need to know why it works. Well, now I know.

So, lets get started. Gen_server is built into erlang. It abstracts the message passing away. As far as I can tell, yes, you could write this functionality yourself. But why would you want to when it’s done for you?

For starters, there’s a few functions you need to implement. If you’re using Erlide, you can create a new module and choose gen_server as the behavior, and it’ll give you a skeleton. Nifty. I strongly recommend going this route, as it has a lot of helpful comments in the code.

Lets write an addition and subtraction server. It’s really not that useful, but it’s enough to get started and understand what’s happening.

Init

%% ——————————————————————–
%% Function: init/1
%% Description: Initiates the server
%% Returns: {ok, State} |
%% {ok, State, Timeout} |
%% ignore |
%% {stop, Reason}
%% ——————————————————————–
init([]) ->
{ok, 0}.

Here’s a very important thing to understand. A gen_server maintains a state. The State that’s returned above is the starting state of the server. In our case, the initial state will be zero.

handle_call
Now we want to add some functionality. Lets add addition and subtraction. We’ll need to export our new functions as well, so lets make sure we put this in with the exports:

-export([add/1, start/0, subtract/1]).

And the actual code:

add(Num) -> gen_server:call( ?MODULE, {add, Num}).
subtract(Num) -> gen_server:call( ?MODULE, {subtract, Num}).

handle_call({add, Num}, _From, State) -> {reply, State + Num, State + Num};
handle_call({subtract, Num}, _From, State) -> {reply, State - Num, State - Num};

When you call counting:add, it will in turn call the gen_server:call function, which takes a module and a parameter. It will then call “handle_call” with this paramater, the Pid it came from, and the State of the server. The parameter can be anything, so if we use a tuple, we can take advantage of erlang’s pattern matching. handle_call will return what the gen_server should do next - reply (return a result), noreply, or stop. In this case, we’re replying.

The second parameter is the reply. We’re just going to return the current count here.

We also need to return the new server state in parameter 3. I chose to put the new state in param 2 because it’s useful, but we could just as easily put anything there - an atom, a random string, whatever.

There’s a lot of options within there, so you might want to check the docs.

I STRONGLY recommend using Erlide for your development. It auto compiles and gives you an interactive shell right in the editor. It made Erlang development so much easier. It’ll also create the stubs for the other functions you’ll need (terminate, code change, handle_info, handle_cast).

FYI, If you get an error like this:

** exception exit: {noproc,{gen_server,call,[calculator,{add,1}]}}
in function gen_server:call/2

It’s because your gen_server isn’t actually running. Make sure you start it before you test with

calculator:start().

Hopefully this is enough to get you started. Read up more in the official Erlang docs for gen_server. Scroll to the bottom to find the specifications on what functions you must implement, and what they need to return.

Enjoy!

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

Interesting Programmer Links

April 21, 2009 – 12:47 pm
  • Peeping into memcached.
  • Really interesting read about how to examine what’s stored in memcached.

    Peep uses ptrace to freeze a running memcached server, dump the internal key metadata, and return the server to a running state. If you have a good host ejection mechanism in your client, such as in the Twitter libmemcached builds, you won’t even have to change the production server pool. The instance is not restarted, and no data is lost.

  • Quick look at MySQL 5.4
  • Highlights include scalability improvements, subquery optimizations and join improvements, improved stored procedure management, out parameters in prepared statements, and new information schema additions.

  • EasyVMX
  • EasyVMX lets you create empty VMWare images. Very useful when coupled with the VMWare player.

  • For the next 5 days you can get Jira 5 user license for $5.
  • I used Jira about 3 years ago at Infosearch Media, which I don’t think exists any more. Anyway, it trounced bugzilla then and still does.

  • A cool rundown on what you can do with the information schema in MySQL.
  • I like this post, it makes a few really cool points. It explains how to get a list of all tables and their engine and how to get a list of foreign keys in your schema. Very cool.

  • Q4M, a Queue storage engine
  • Q4M looks like a pretty cool storage engine that aims to address twitter-like features. I’ll be trying this out for myself in the near future.

    Q4M (Queue for MySQL) is a message queue licensed under GPL that works as a pluggable storage engine of MySQL 5.1, designed to be robust, fast, flexible. It is already in production quality, and is used by several web services (see Users of Q4M).

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