Bash Remove Extension

I can’t imagine me ever needing this again, but it does highlight bash’s ability to strip extensions.

To convert avis to mkv’s and update language from unknown to english:

Nginx + Cloudflare SSL

Now that cloudflare will support ssl on every domain you host with them, I wanted to get some of my domains setup to use it.

I didn’t really get around to setting up the ssl cert on my side, but since cloudflare supports it, I wanted to redirect people to use it (as a convince, not a security factory) so setup this basic nginx config.

It blindly trusts the header, so it is possible to hit these domains without ssl, but I don’t want to prevent it, just let those that want it in.

Figured it might be useful for others as well

Update to the capistrano hack

So a while ago I had posted a hack that lets capistrano deploy code from a git server from behind a firewall.

So in a recent update to SSHKit they changed how they do ssh connections to use Threading and Pools. This broke my hack.


So long story short, I’ve updated my hack. This one uses net-ssh directly to make a forward.

Disclaimer: This works for us at $work, but I can’t claim it works anywhere else.



direnv is one of the coolest tools ever

I’ve always loved the idea of self contained environments but coming from doing perl and c/c++ a long time ago, I’ve never been able to really pull it off. It wasn’t until I encountered virtualenv for python that I finally got this working properly. I had encountered rvm’s gemsets before that, but they always seemed finicky at best.

I started to have complex vim configs, and bash rcs that tried to look at what directory you were in / file you were editing, and change configs accordingly. It never worked well. EditorConfig and vim-editorconfig helped a lot with that. No longer had to have really confusing vim configs. I could specify per project editor settings. I can’t wait till its more uniformly adopted.

That left bash configs though. Enter DirEnv. Its solved the second half for me. Makes all those configurations per project. A simple direnv edit . inside your project directory will open up $EDITOR. This lets you specify all kinds of things about that project. Anything you can do in bash you can do here. It works best with env variables but can do other things. I love the layout functions though.

adds node_modules/.bin to your path

Creates a new virtualenv and adds it to your path.

It makes it easy to work with heroku based apps as well. They do all your configurations as environment variables, its pretty easy to add a bunch of export statements to your direnv and emulate the same thing.

I’ve just submitted a simple patch to add layout perl. This makes local::lib so much easier to use per project.

I have to give Philip Nelson credit for letting me know about this toolset. Its changed how I develop applications. He and I disagree on exactly how to use it, but no matter how you do, it helps out.

Bash prompt linewrap with colors issues

So I’ve been fighting with trying to make a custom color prompt for a while now.

I’ve recently found out about tput to output color codes. That combined with local variables meant prompts became easier to read.

We started to create a custom prompt here for the team. Had all the info needed at a quick glance. Everything was good except long lines didn’t wrap properly. Ctrl+r would just get nutty.

So, after a lot of research and reading various forum posts, I found out that color codes should be wrapped in “\[...\]“. So example:

Note the \[ and \] wrapping the codes. This allows bash to properly figure out the length of the line. Note: I just grabbed random colors, I suspect this example looks bad.

I did find a slight exception

For the TITLEBAR (putty/xterm/screen) support:

case $TERM in
TITLEBAR="\[33]0;\[email protected]\h:\w07\]"

The \[ and \] should wrap the entire block as everything inside is considered part of the control code.

Renaming batch of files (with spaces) in linux

I rename a lot of files. Often by hand as it’s just easier. I’ve tried various combinations of find -print0 | xargs -0, and find -exec, without much luck.

Just So I have reference on what does work:

Yea I could probably drop the echo mv, and the |sh, but it feels safer to do a dry run

Updating WordPress Plugins Helper

Note, I’ve recently found WP Cli which makes all of this moot because i can now just do “wp plugin upgrade –all” or “wp plugin install blah”

Original post:

I decided a while ago to put pull all the plugin source codes for this wordpress install directly from subversion. This makes it easier when files need manual patching or more likely, a file gets deleted.

So I created this little helper script that I can use to do a mass update when I get too out of date.

How to change from mate-terminal to xfce4-terminal

Mostly for my own purposes

mateconftool-2 --set /desktop/mate/applications/terminal/exec --type string "xfce4-terminal"

I’m not a big fan of mate terminal, seems to hurt my eyes, like xfce better, so this still makes the “launch terminal” shortcut work, but launch a different terminal.

Probably should switch it to use the debian standard “x-terminal-emulator”

Busy Week here

Got lots of things committed this week.

Gitolite support for Gitalist

RetweetBot has been upgraded. It now has a ruby script to grab latest events from group, and post them to twitter. It was a good excuse to learn ruby. Try out gems and some modules.

Redmine auto-watcher patch – Very minor patch to support redmine 1.32

Collectd write_graphite patch – We at $work are just starting to play with collectd/graphite and before the 5.1 release we were using an older python module. Dusted off my C to add a few config options to keep the new C version outputting the same as the old python version.

mongo-c-driver very minor patch (the most minor of them all) to fix Makefile to output proper .so files (and learned a bit more about how .so files work)

And lastly,
puppet-module-supervisor minor patch to the awesome module so puppet can manage our supervisor daemons.

Lots of open source work this week, I hope even more, its been too long.

How to output pretty json in puppet

It kept seeming like it should be straight forward. Various attempts by myself (mostly because I don’t know ruby) seemed to fail. I’m just leaving it here now that I figured out how to get it working so I can find it again (and hopefully help others).


$config_data = { "foo" => "bar" }


<%= require "json"; JSON.pretty_generate config_data %>

I found config_data.to_json wasn’t going to work for me because it seemed to output things in different orders each run.

(it was that helped me figure this out)

Edit: While pretty, still doesn’t sort so puppet can update the config file each run :( I will figure this out.

Edit: After much trial and error, I ended writing my own library.