Category Archives: How-to

Launchd changes in Mountain Lion

After upgrading to Mountain Lion, I eventually noticed that all of my custom LaunchAgents had stopped running. When I tried to run them manually, I would just get a generic “nothing to load” error. Usually, that error implies you have a malformed plist file, but in this case plutil -lint reported that the files were valid.

After a ton of googling and comparing my own plist files against working vendor supplied plists on my system, I eventually discovered the problem.

In Lion and earlier, this was totally valid:

<key>label</key>

In Mountain Lion, the above will silently fail and you should instead use:

<key>Label</key>

Case sensitivity is the future.

Since I wasted a bunch of time on this and google searches for various permutations of “mountain lion launchd” turned up nothing, I’m hoping that this blog post (and my related git commit) will help someone else who happens upon this “feature”.

Ways to fix broken gemsets / best practices for gemsets

Assertion: If you maintain more than one ruby project on your system and you aren’t using rvm, you are wrong.

Nothing has made this more clear to me than rubygems‘s tendency to break all of your gems arbitrarily, a situation that can cause you to need to reinstall all gems unless you know the proper arcane method to repair them.

It is for these reasons that I’ve decided to share my notes on rvm best practices and rubygems repair. Hopefully, they will save someone else a lot of googling.

Setting up gemsets

In general, manage gems via rvm ( http://beginrescueend.com/ ) to make life less painful
  1. rvm install 1.8.7
  2. rvm --default use 1.8.7
  3. rvm gemset create mycoolapp
  4. rvm gemset use mycoolapp
  5. rails >= 3:
    1. gem install bundler
    2. bundle install
  6. rails < 3:
    1. gem install rails -v '~>2.3.14'
    2. rake gems:install
Put an .rvmrc in your project’s root directory to tell rvm to automatically switch to the correct gemset when you enter that directory:
    rvm_gemset_create_on_use_flag=1
     rvm use 1.8.7@mycoolapp
When everything is fubar, empty the gemset and start anew, not affecting any other apps.
  1. rvm gemset use mycoolapp
  2. rvm gemset empty mycoolapp
  3. (follow 5|6 above)

Invalid gemspecs / rubygems deprecation warnings

If gemspecs are behaving badly, upgrade rubygems and rebuild gemspecs
  1. gem update --system
  2. gem pristine --all --no-extensions
You will get errors like, “Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.”, if you use a new rubygems with rails < 3 ( https://github.com/rubygems/rubygems/issues/84 ). Install rubygems 1.6.2 instead:
  1. gem update --system 1.6.2
  2. gem pristine --all
Sometimes you will just have to tough it out and edit the offending gemspec file by hand, removing or repairing the bogus lines. If it’s a date line that’s the problem, you can probably just remove it. Otherwise, the problem should be easy to locate and edit away.

Uninstalling ununinstallable gems

If you cannot uninstall a specific gem with gem uninstall, look for where it’s located (with the suggested gem list -d command), and uninstall it with the -i flag, providing the ‘installed at’ directory. ( http://stackoverflow.com/questions/4007074/uninstalling-rails-and-gems-getting-error-cannot-uninstall-check-gem-list-d )

Rails 3.1.0rc4, Dreamhost, WordPress, and you

Update: After a week of pretty poor performance I theorized that Dreamhost was killing off my Passenger processes, despite the fact that I was only using ~200MB of my allotted 300MB of memory on my VPS. Sure enough, increasing my allotment to 400MB seems to have resolved my site’s problems. I am left to conclude that you shouldn’t even try this unless you are on a VPS and have requested sufficient memory.

Correction: You need sudo access for this to work. Rails 3.1.0rc4 requires rack 1.3.0 and Dreamhost only provides rack 1.2.1. Installing a newer rack in your local gem directory will not help as rack is loaded before config.ru is read, so the wrong version will have already loaded before passenger starts. From testing just now, the only command you need to run as sudo is sudo gem install rack -v 1.3.0

Yesterday I spent most of the day struggling with getting my new rails site (this site, in fact) working on Dreamhost. To save others who might be trying to do the same thing some time, I figured I would share my findings here.

In the end it turned out to not actually be that complicated, once I gave in and accepted the fact that it’s best to use the passenger and ruby installations that Dreamhost offers, even though I have (limited) sudo access on my account and am using rvm.

That means you have to use ruby 1.8.7. So if you, like me, were developing under 1.9.2 that means you may have to change some code for compatibility.

First, set up your domain on dreamhost to enable passenger. Just go into the Dreamhost panel and the Manage Domains tab, check the ‘Passenger’ checkbox, and ensure that ‘Web Directory’ ends in ‘/public’. You can very easily deploy via capistrano by setting ‘Web directory’ to end in ‘/current/public’. I won’t go into more detail about setting up capistrano here, but the Dreamhost wiki has more info if you are interested.

Next, deploy your code to the location you specified above. The /public directory inside your rails root should match what you set ‘Web Directory’ to be, natch.

SSH into your Dreamhost, cd into your rails root, and bundle install. Set up rvm and be fancy about it, if that’s your bag. If you use rvm to set up a ruby gemset that is not MRI 1.8.7, then you will give yourself problems as passenger is still going to use 1.8.7 no matter what you say.

Now that you have passenger set up, your codebase in place, and all your needed gems installed, all you should need to do is tell passenger where to find said gems. To do this, edit your config.ru file in your rails root so it looks something like this:


ENV['GEM_HOME']="/PATH/TO/HOME/.rvm/gems/ruby-1.8.7-p334@GEMSET"
ENV['GEM_PATH']="#{ENV['GEM_HOME']}:/usr/lib/ruby/gems/1.8"
require 'rubygems'

require ::File.expand_path('../config/environment',  __FILE__)
Gem.clear_paths

run YourApp::Application

This basically just tells passenger to look for gems in your home directory/rvm gemset before looking in the system gem directories. The order of those lines is rather important. The Gem.clear_paths is exceptionally important.

After that, touch tmp/restart.txt and see if passenger complains in the browser. If it does, the logs saying what the actual problem was might not wind up in either your rails logs or the virtualhost specific apache logs dreamhost provides in your home directory. In my case, they were in /dh/apache2/logs/apache2-psXXXXX/error.log, the log for my VPS. If you don’t have sudo access you probably won’t even be able to look at that file.

If everything worked, then yay- you’re done.

Unless of course you want to run WordPress within your rails install, like I am. If so, add the following to the .htaccess file in your wordpress directory:

PassengerEnabled off

And restart Passenger.

If you copied or moved wordpress from another location and are using the wp-cache plugin, make sure you clean up the cache or wordpress might get confused and serve only blank pages.

Further reading…

I hope that that someone finds this helpful. If so, you may also find these posts by other people helpful- they certainly helped me:

Problems?

Since some of the things DreamHost uses are rather old and the rails I am using is so new it’s not even really released yet, there are some problems.

  • No Data Received Chrome periodically gives this error: Error 324 (net::ERR_EMPTY_RESPONSE): The server closed the connection without sending any data. The log shows the pages as being served without error, though. If anyone has any ideas about this, I’d love to hear them.
  • fcgid process manager died When this happens, Passenger restarts (slow): mod_fcgid: fcgid process manager died, restarting the server I wonder if this is some Dreamhost thing automatically killing off these processes?
  • backend application did not send a valid HTTP response When this happens, the rails view being generated will often trigger my 404 page: file=ext/apache2/Hooks.cpp:684 : The backend application (process XXX) did not send a valid HTTP response; instead, it sent nothing at all. It is possible that it has crashed; please check whether there are crashing bugs in this application.

A lot of these problems seem very similar, but only one will occur at any time. I have a feeling that the error that shows up in the logs depends on where in the transaction whatever process is dying / getting killed ends.
Update: I believe these issues were caused by Dreamhost killing off my passenger processes for using too much memory. Increasing my memory allotment seems to have resolved them.

Technicolor hair how-to

People always ask me how I get my hair to be such vibrant colors. After writing up a long list of tips for a friend, I figured it would be helpful to tidy them up and record them in a place that will be easy for me to find the next time the topic comes up. I’m thinking about maybe getting business cards made with this URL to hand to strangers who randomly ask me hair-related questions on the street :)

Anyway, before we start I’d just like to send you off to Zoetica Ebb and Gala Darling‘s respective articles on the topic. Their hair can put mine to shame, so if you like mine you’ll probably like theirs even more.

Now, on with the show!

What to use
I haven’t tried a whole lot of bleaches, but I don’t believe the specific brand makes much difference. It is probably a good idea to pick one by a brand like Manic Panic or Special Effects designed to be used on hair that will be dyed bright colors, as opposed to one that is designed to turn your hair into a realistic blonde.

I have heard a lot of people say you should follow up bleaching with a toner, but I have never needed to do this, and my hair is naturally dark brown. If you can’t get the yellow out, this may be worth looking into, but I’ve found that the colors I have tried have all covered the yellow just fine.

As far as dye, there is no doubt about it: Special Effects brand dye is the only dye worth your time. If you can’t find a store near you that carries it, you can buy it off Amazon, so no worries there.

The colors I’ve tried include: Nuclear Red,
kludge
Limelight,
kludge
Pimpin Purple,
kludge
Blue Mayhem,
kludge
and Electric Blue. I have heard people say that blue fades the quickest, but I had much more trouble with green than I ever had with blue. Green does nothing good for my complexion anyway, so I’m fine with that.

Speaking of which, your complexion and how it will interact with your hair definitely warrant consideration. By way of an example, when I went red I ended up looking more like this
kludge
than this. YMMV.

Bleaching
  • General rule of thumb: bleach as little as possible.
  • That being said, bleaching is good to do once, even if you have very light hair to begin with (it damages your hair in such a way that the dye will be able to stick to it better). Bleaching is necessary for any color (as opposed to faint highlights) to show if you have dark hair. This is because hair dye is more like wood stain than it is like latex paint- it adds to what you have more than it covers and conceals.
  • If you already have dye in your hair, especially black, consider getting it professionally bleached/stripped, just this one time. You can do your roots yourself from then on.
  • Bleach no more than once in 2 weeks or you WILL get bald spots.*
  • When tackling new growth, be sure to bleach only your roots or your hair WILL turn into straw after a few months.*
  • When bleaching roots, section your hair by parting it, applying bleach evenly to the roots with a tint brush, then parting the hair ½ – 1 inch to the side and repeating until the entire top and both sides of your head are done. Get the roots in the back of your head by holding all your hair up and making horizontal parts starting at the bottom and working your way up.
  • Once you’ve evenly applied the bleach, cover your hair with a plastic shower cap- some types of bleach come with a disposable cap for this purpose. If the bleach dries out it stops working.
  • Be aware that your scalp may burn a bit while bleaching, so discomfort doesn’t necessarily imply you are having a horrible reaction. Don’t panic!
  • Bleach for no more than two hours. I find that after 30 to 45 minutes my roots are practically white, but keep in mind the roots will always bleach faster because of the heat from your scalp. Getting the rest of your head to match is no simple task- another reason to consider getting your first bleaching done professionally.
  • Rinse out the bleach and wash your hair using a strong/clarifying shampoo, but do NOT condition it yet.

Dyeing
Warning! These tips ONLY apply if you are using a dye like Special Effects/Manic Panic/Punky Colors/etc which doesn’t contain developer. If you follow these instructions with some fancy dye that DOES contain developer, you will probably destroy your hair. (Thanks, Cheri!)
  • Liberally apply vaseline to your hairline and ears to keep your flesh flesh-toned.
  • If you have fresh piercings (less than a few months old), you may want to shield them with tape. My piercer told me nightmare stories of seeing the results of hair dye that made its way into cartilage piercings!
  • Before the dye goes in, blow dry your hair to make it warm. This makes your hair more receptive to dye.
  • Apply lots of dye. Then apply more. Repeat until you cannot find any spots you’ve missed, even with the aid of several mirrors and a few friends, if available. If you can mold your hair into a sculpture with the dye, all the better.
  • Run a comb through your hair to help make sure the dye is even. I’ve found the dye kinda froths a bit when I do this, and tends to drip all over the place, so be prepared.
  • Put a showercap on over your dye-full hair. This is to keep the dye fresh- if it dries out it stops working.
  • Clean up any dye on your skin with a paper towel and water. Some people swear by nail polish remover, but I’ve found it is no more effective than water. Don’t worry too much about any stains on your skin; Any spots you can’t clean off with water will be gone in a day or two as skin sheds quickly. If this worries you, make sure you dye it three nights before prom, not the night before. ;)
  • Blow dry the outside of the shower cap, again to warm your hair and allow the dye to seep in better. Don’t do it enough to dry up the dye; as I mentioned above, dye only works while it is wet.
  • Wait as long as you can stand. I wait at LEAST four hours, but have been known to leave dye in overnight. The showercap should prevent disasters while sleeping with dye in your hair. Don’t be afraid to leave this kind of dye in for a long time- it doesn’t damage your hair (in fact, it’s a mild conditioner!).
  • Stay away from vinegar (despite Gala suggesting it). I’ve heard bad things about it totally stripping new color away.
  • Rinse out the dye with cold water until the water runs clear. The cold water makes the hair less willing to bleed dye.
  • Use some intensive conditioner to give your hair some TLC after all that bleaching. Rinse that out with cold water too.
  • About this time you may find some spots you missed – just slap some dye on those spots and leave it in until your next shower. As long as those spots weren’t too big, this should blend them in sufficiently.

Maintenance
  • Shampoo as little as possible, and preferably with Sulfate-free shampoo. Your hair won’t get so oily after bleaching, so won’t need to be shampooed as often as you may be used to. Twice a week is plenty for me. Simply rinsing your hair with warm water every day in the shower will keep it surprisingly clean.
  • Consider skipping normal conditioner altogether and instead invest in a good leave-in conditioner to be used after you shower, but before you style your hair.
  • If you must use regular conditioner, add dye to it (Zoetica recommends one part dye to two parts conditioner, but I find that ratio doesn’t do enough conditioning for me. YMMV). Condition your hair whenever you shampoo it.
  • I reapply dye (without bleaching roots) about once every two to three weeks. Since the colors I use tend to be dark and intense, and my hair is naturally dark brown, new growth is not too noticeable as long as it is shorter than about half an inch. When I reapply dye, I repeat all of the steps in the dyeing how-to above, showercap and all.
  • I bleach my roots about once every two months.

That’s about it! I promise it’s not as terrible as it may seem :)

Please comment with any questions you have, and I will answer them if I can. Also, if you have pointers that have worked for you, let me know! I will try to keep this post as up-to-date and accurate as possible.

*: In the immortal words of jwz, “My one purpose in life is to serve as a warning to others.”

  • When I first started doing this, I would bleach all of my hair each time, not just my roots. My hair became weak and lost all its elasticity, and stopped holding onto color. Eventually, I had to start dying it black as nothing else worked.
  • About three years later (after all the brittle hair had been grown out and cut away), I decided to go blue. I bleached twice in one day trying to get all the black dye out. My hair fell out in chunks in several places, and I had to learn to style it in such a way to cover bald spots, and later, new growth that appeared black under my blue and insisted on sticking straight up through the rest of my hair.

Learn from my mistakes! I’m telling you this because it happened to me, and I don’t want it to happen to you!

DIY Theremin

My friend Beth made her own theremin once. While this is less permanent, it’s also much easier, and much more tasty. Plus, I don’t see any way that this could be an unintentional reference to the Infinite Improbability Drive:

The principle of generating small amounts of finite improbability by simply hooking the logic circuits of a Bambleweeny 57 sub-meson Brain to an atomic vector plotter suspended in a strong Brownian Motion producer (say a nice hot cup of tea) were of course well understood – and such generators were often used to break the ice at parties by making all the molicules in the hostess’s undergarments leap simultaneously one foot to the left, in accordance with the Theory of Indeterminacy.

Instructions for turning a mug of tea into a Theremin:

1 Prepare some tea
2 Expose the L/R leads on an 1/8″ cable
3 Immerse leads in tea
4 Plug cable into audio input
5 Start up max/pd/processing/etc. and average every 735 samples (882 if you’re in Europe/running on 50Hz)
6 Scale value and drive oscillator

(The tea should not be neglected, be sure to drink it once you’re done making noise.)

My camera’s been acting funny, hence the jitter.

See the Max patch for a more in-depth explanation: flickr.com/photos/kylemcdonald/2126494098/

Via VideoSift

How to avoid religious nutjobs

Today I was walking through the commons, and one of those pamphlet-weilding religious whacks was gonna offer me one of his tracts or whatever, but thought twice of it when he saw my black dress, eyeliner, fishnets, and knee-high Dr Martens. It was great- he turned to me, and started to offer his paper, thought twice of it, and kinda pulled back and pretended to be looking off in some other direction. He then tried to give one to Peter (a friend visiting from New Jersey), who was walking a few feet behind me and looking much less gothic. Peter pretended to be one of the enlightened, and the pestering summarily ceased.

So, in short:
(a) When asked “Have you accepted Jesus Christ as your personal savior”, say “I certainly have!”, in otherwords, be a wolf in sheep’s clothing.
(b) Look to be what a born-again would consider “Satanic”, in otherwords, be a wolf in goat’s clothing.

I don’t know whether metaphorically pretending to be other livestock works as well or not, but these two methods seem rather effective (with the caveat being that the latter method may make the braver zealots try harder, unless you are very intimidating; and that the former method makes you a lying bastard).

DIY Moblog

Setting up your own moblog is easy. I know, I did it. The only problem I have with mine is that emails sent from my verizon phone often arrive really slowly (rarely, they never show up at all). This however, is a problem with Verizon, or the way in which Verizon talks to my mail server.

Anyway, since this is on /. today, and since Sax recently asked me how I do my moblog, I figured I’d share with everyone.

First, I have the following lines in my .procmailrc on my mailserver:

:0:
* ^TO_${photoblog_email}@terisolow.com
|/home/tekniklr/camblog.pl

Which pipes the messages sent to ${photoblog_email} to this script: camblog.pl, which performs some error/spoof checking and the like, cleans up the message, saves the image, creates a thumbnail, and indexes the image, along with it’s subject and message body (if set).

After that, all that’s left is the display, which is handled by my photoblog PHP script. The formatting there is highly dependent on your site, but splitting the image index file with file(), and then each line with explode() should get you pointed in the right direction.

Anyway, if you find any of this helpful to you in setting up your own moblog (probably not), then great. If not, then ignore it- no harm done :)