Archive for the ‘development’ Category

|

nginx + PHP on Mac OS X

Wednesday, December 2nd, 2009

I’m a big fan of the nginx server (it’s lighter weight than Apache, and at this point I’m just more familiar with it, so it’s my server of choice). When trying to get it to play nicely with PHP, however … well, it leaves something to be desired.

But, with some persistence (and quite a bit of help), I got it up and running on my development machine. The one thing that I wasn’t ever able to find an answer for (at least, an answer that worked) was to have my system start up FastCGI on launch. I really dislike having to start these things by hand and feel that any performance trade-off (always having this run in the background) is well worth it for the productivity boost.

This article addresses using a plist that runs on load (utilizing launchd), but as the author notes, it works inconsistently. After doing some digging of my own (by reading the nginx plist that ships with my MacPorts install of the server), I came up with the following:

com.panpainter.php-fastcgi.plist


<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>com.panpainter.phpfcgi</string>
  <key>EnvironmentVariables</key>
  <dict>
    <key>PHP_FCGI_CHILDREN</key>
    <string>2</string>
    <key>PHP_FCGI_MAX_REQUESTS</key>
    <string>1000</string>
  </dict>
  <key>ProgramArguments</key>
  <array>
    <string>/opt/local/bin/daemondo</string>
    <string>--label=php-cgi</string>
    <string>--start-cmd</string>
    <string>/opt/local/bin/php-cgi</string>
    <string>-q</string>
    <string>-b</string>
    <string>127.0.0.1:8888</string>
  </array>
  <key>OnDemand</key><false/>
  <key>Debug</key><false/>
  <key>RunAtLoad</key><false/>
</dict>
</plist>

(Get the code here)

After adding this to the /Library/LaunchDaemons directory (or symlinking it in to there, if you’d rather it live somewhere else), don’t forget to run the following to ensure that it’ll run on load:

sudo launchctl load -w /Library/LaunchDaemons/com.panpainter.php-fastcgi.plist

Now, this probably is not the most elegant solution, and I’m relying on the MacPorts-depedent daemondo, but it works. If you know of a better way to do this, I’d be happy to hear it.

Shortlink: http://panpainter.com/p/10

Tags: , ,
Posted in development | No Comments »

960.gs TextMate Bundle

Tuesday, October 13th, 2009

As part of the work I do every day, I use the 960.gs CSS framework, which means I spend a good portion of my day typing things like “grid_4″ and “container_16″ and “alpha” or “omega” a LOT.

This is stupid.

So I created a 960.gs Bundle for TextMate. Now, this doesn’t help with the CSS side of things (it won’t keep you from typing in .grid_4 for example), because there’s already a bundle that does that (and I did model some of my snippet structure off of his, so credit where credit’s due). I recommend installing both, since that Bundle also handles HAML (and, again, mine does not – just the HTML).

If you want to download it, you can grab it from here or you can grab the code from Github.

Also, if there are any problems that you run in to while using it (or if you have a request), please let me know! I’ll happily update the bundle.

Permalink: http://panpainter.com/p/9

Tags: , , ,
Posted in development, tools | No Comments »

Git Demote

Friday, August 28th, 2009

I’m a big fan of Trevor Squires’ Git Promote script, but one thing that’s bothered me about it since I started using it is that it tends to clutter up my .git/config file. So, I made a counter-script for it that I’m calling, appropriately, “git demote”

    #!/bin/sh
    #
    # Counter-script to Travis Squires' git-promote script
    # (http://hoth.entp.com/2008/11/10/improving-my-git-workflow)
    # Removes a 'promoted' branch from the git config file.

curr_branch=$(git symbolic-ref -q HEAD | sed -e 's|^refs/heads/||')

git config --remove-section "branch.${curr_branch}"

To install it, simply create a file called $HOME/bin/git-demote (assuming you have $HOME/bin in your PATH, otherwise place it somehwere that does exist in your PATH), then run the following from the terminal:

chmod 755 $HOME/bin/git-demote

Now, when you’re done with a branch, you can clean up your .git/config file by running:

git checkout topic-branch
git demote

And you’re good to go.

You can fork the Gist, if you don’t want to type all that.

Shortlink: http://panpainter.com/p/7

Tags: ,
Posted in code, development | No Comments »

A High Point

Thursday, August 27th, 2009

Last weekend I participated in Rails Rumble ‘09 (along with some really awesome teammates), and today we found out that we made it in to the Public Voting stage!

It really makes that weekend of hard work worth it (although we all really wanted to build Quippopotamus anyway). Congrats to my teammates, and to everyone else – go vote for us! :)

You’ll also notice that I’ve added something new to the sidebar (over there on the right) – that would be the by-product of last weekend’s endeavors, an embedded widget from Quippopotamus cycling through a collection of quips that I’ve started to build.

Shortlink: http://panpainter.com/p/5

Tags: , , ,
Posted in code, development, onehub | No Comments »

Featherdust: A Simple Twitter Gem

Sunday, December 28th, 2008

Not too long ago, I released a Ruby gem on GitHub.  You can read more about it over at the gem’s site, but in a nutshell it’s a gem that’s designed to be added in to your website, and it will aggregate however many status updates you want from your Twitter account.  It works similarly to many of the javascript Twitter aggregators, except that it doesn’t require the end user to have Javascript installed.

Shortlink: http://panpainter.com/p/3

Tags: , ,
Posted in Shameless Self Promotion, code, development | No Comments »

Something new and shiny

Monday, December 15th, 2008

Just to keep everyone in the loop; I’m in the process of working on a Ruby gem that will be released in the next week or so on RubyForge. When there’s more to know, I’ll post it here.  Or, you can keep an eye onThe project’s site (not much there now, of course).

This is being released as a part of the UW course that I’m taking focusing on Ruby, but is something that I plan on maintaining well after the course is over.

Shortlink: http://panpainter.com/p/2

Tags: , , , ,
Posted in code, development | No Comments »

|