Office of Secret Intelligence

Who taught you to be a spy, fucking Gallagher!?!

Posts for February, 2015

Snippet: Run fsck On LVM Partitions

lvm pvscan
lvm vgscan
lvm lvchange -ay /dev/VolGroup00/LogVol_home
^ volume group ^ logical volume name
ex: kodiak-dev ex: home, var, usr lvm lvscan fsck -yfv /dev/kodiak-dev/home

Rinse and repeat for the rest of the logical volumes you wish to fsck.

Introducing: Fluorescent

I've been working on a gem called fluorescent for a little while, and I just recently cleaned it up and released it.  This CMS is using it, so it seems to be working.


Basically, I wanted to be able to highlight search terms in search results and only show them in context for things like article bodies, which could potentially be several pages long.  Truncating them to a certain length is certainly beneficial.


Here's a brief rundown:


Add fluorescent to your Gemfile:

gem 'fluorescent'

Next, you need to pass your search results from ActiveRecord to fluorescent.

I do it like so:

Then, in my model:

Some very simple controller code:


How you display the results in the view is up to you.  I simply make sure the query parameter exists, then make sure there are actual results, and then iterate over the array of hashes:


I realize there are several points here that need to be brought up to the Rails 4 code standard, but I think these snippets get the point across.  I think it would be wonderful just to be able to call something like @results = fluorescent(@resultset) and have it just do the right thing, but that's down the road a bit in terms of development and complexity.

You'll also note that I keep track of the raw ActiveRecord resultset.  This isn't really used right now, but originally it was in case you needed to get to the non-hash serialized ActiveRecord row objects.


All thoughts and suggestions, feedback, and critique are welcome.  Please enjoy!

Treeify 0.05 Released

I've released version 0.05 of treeify, mostly just updating gems.  Here's the changelog:

Also, slightly embarassing, it turns out I need to update the gemspec file with the last edited date.  I thought that was the authored field.


Anyway, enjoy!

Snippet: Prepend git log To Your Changelog

git log --pretty=tformat:"  * [%ad - %s%n%b](" --since="$(git show -s --format=%ad `git rev-list --tags --max-count=1`)"|cat - > /tmp/out && mv /tmp/out 


 This basically tells git to show all commits since the last tag, pipe them to cat, which will concatenate the new changes on top of the old, redirect the output to a temp file, and then rename that temp file back to the changelog file.


An exercise left to the reader would be to modify this to prepend the version number/tag name to the change set so that it's easily discernable what changes belong where.