<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Self-Reference on CodeGoalie</title><link>https://codegoalie.com/categories/self-reference/</link><description>Recent content in Self-Reference on CodeGoalie</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Tue, 19 Jul 2016 17:58:03 -0400</lastBuildDate><atom:link href="https://codegoalie.com/categories/self-reference/index.xml" rel="self" type="application/rss+xml"/><item><title>How shell scripting saves my side projects</title><link>https://codegoalie.com/posts/how-shell-scripting-saves-my-side-projects/</link><pubDate>Tue, 19 Jul 2016 17:58:03 -0400</pubDate><guid>https://codegoalie.com/posts/how-shell-scripting-saves-my-side-projects/</guid><description>&lt;p>I work on a lot of little side projects. Many of them are short-lived and small
scale. I start them to learn a new technology, to learn a new concept, try an
idea, or just to see if I can actually build something cool. I should also
mention that my memory is terrible. I &amp;ldquo;remember&amp;rdquo; things by figuring them out
again. Rote memorization is basically non-existent to me. I&amp;rsquo;ve recently come up
with a new best practice for my side projects which has saved my butt several
times now.&lt;/p>
&lt;p>It&amp;rsquo;s a &lt;code>deploy.sh&lt;/code> script and I put one in every project that I do which needs
to be built, deployed, or executed beyond the typical compile step. This
very blog &lt;a href="blog-deploy-dot-sh">has one&lt;/a>. There are also a few best practices
I&amp;rsquo;ve developed for making this file useful and not just another headache.&lt;/p>
&lt;h1 id="runable">Runable&lt;/h1>
&lt;p>This seems like a no-brainer, but hear me out. This file should be executable on
its own. It should not be &lt;code>deploy.rb&lt;/code>. It should not need to be compiled or
otherwise prepared to run. You are writing a script. Script away all of that
tedium. If you need to deploy with ruby, make your &lt;code>deploy.sh&lt;/code> simply contain
&lt;code>ruby deploy.rb&lt;/code>. The point here is that you can &lt;code>cd&lt;/code> into your project and run
this script. Period. If you have to remember to initialize your Python
virtualenv first, you&amp;rsquo;ve missed the point. Set it and forget it.&lt;/p>
&lt;h1 id="helpful">Helpful&lt;/h1>
&lt;p>Not &lt;em>everything&lt;/em> can be scripted away. Sometimes a deploy requires some unique
information, such as an environment or version number. Every microservice I
create is meant to run in a &lt;a href="docker">docker&lt;/a> container on
&lt;a href="kubernetes">kubernetes&lt;/a>. In order to automate building, tagging, pushing the
image, and then updating the deployment, the deploy script needs to know the
version number. Since I&amp;rsquo;ve deployed 10 times today to &amp;ldquo;fix&amp;rdquo; that one bug, I can
easily remember to pass the version to the script: &lt;code>./deploy.sh v1.0.1337&lt;/code>.
However, I won&amp;rsquo;t be so hip to that fact tomorrow. Good thing we are writing a
script. Just add some checks and helpful error messages to guide your future
self down the right path. Here&amp;rsquo;s an easy one for requiring an argument to
your script:&lt;/p>
&lt;pre>&lt;code>#!/bin/bash
if [ -z &amp;quot;$1&amp;quot; ]
then
echo &amp;quot;Please provide a version number, like v35&amp;quot;
exit 1
fi
# other deploy code here
&lt;/code>&lt;/pre>&lt;p>It may seem like a drag, but you&amp;rsquo;ll be so happy that you took the time to
take care of your own self now.&lt;/p>
&lt;h1 id="complete">Complete&lt;/h1>
&lt;p>Lastly, your deploy script needs to do every step on its own. It&amp;rsquo;s a grown-up
script now and can handle it. If you need to do just one more thing after the
deploy finishes, you might as well just &lt;code>rm deploy.sh&lt;/code>. Even steps which you
might consider &amp;ldquo;optional&amp;rdquo; now, &lt;strong>need&lt;/strong> to be included. For example, this blog
is &lt;a href="aws-s3-static">hosted on AWS S3&lt;/a> and CDN&amp;rsquo;ed by CloudFront. It really is
enough to only upload (read: sync; save those bits) the files. Eventually the
cache will expire and the new content will be shown. However, in just one more
line in the &lt;code>deploy.sh&lt;/code>, I can invalidate the CloudFront distribution and see
this awesome new post right away. If you think it&amp;rsquo;s optional, it&amp;rsquo;s required.&lt;/p>
&lt;p>Well, those are my three tips for keeping your side project deployments sane.&lt;/p>
&lt;p>Happy deploying!!&lt;/p>
&lt;p>&lt;strong>P.S.&lt;/strong> I&amp;rsquo;ve recently had a resurgence of shell scripting in general. In the
past, I&amp;rsquo;ve certainly been one to (ab)use
&lt;a href="sub-search">zsh&amp;rsquo;s history substring search&lt;/a> to re-run the same set of commands
over and again. See also: &amp;ldquo;Up 12 times then enter. 6 times.&amp;rdquo; By committing those
mini-scripts to &lt;code>~/bin/&lt;/code>, it really has made me much more efficient. A practical
example is streamlining my workflow at work. We use Github for code hosting and
reviews. We also use &lt;a href="youtrack">YouTrack&lt;/a> for our project management. I wrote a
&lt;a href="goutrack">command line client for YouTrack&lt;/a> and combined all the commands I was
doing to &lt;a href="checkout-story">checkout branches by story number&lt;/a> or create new
branches as well as marking stories In Progress/Under Review/etc. into shell
scripts like &lt;code>review_story c-1234&lt;/code> or&lt;/p>
&lt;pre>&lt;code>$ start_story -t bug -s c-1234 -b this-is-a-heisenbug
Applying &amp;quot;Assignee: me In Progress&amp;quot; to story c-1234
Switched to new branch 'bugs/c-1234-this-is-a-heisenbug'
&lt;/code>&lt;/pre>&lt;p>Get creative and really push yourself to save some time. Again, you&amp;rsquo;ll thank
yourself, and then me. ;)&lt;/p></description></item><item><title>Delete multiple branches with git</title><link>https://codegoalie.com/posts/2014-06-25-delete-multiple-branches-with-git/</link><pubDate>Wed, 25 Jun 2014 00:00:00 +0000</pubDate><guid>https://codegoalie.com/posts/2014-06-25-delete-multiple-branches-with-git/</guid><description>&lt;p>When working on projects with multiple developers following a feature branching
workflow, you can end up with a lot of branch laying around. I&amp;rsquo;ve been trying to
optimize my branch cleanup workflow for a while now and had a big breakthrough
recently.&lt;/p>
&lt;!-- raw HTML omitted -->
&lt;p>&lt;strong>UPDATE:&lt;/strong> I now use a &lt;a href="https://github.com/pengwynn/dotfiles/blob/master/bin/git-sweep">shell
script&lt;/a>
which has the meat of the git-sweep functionality. Thanks to @pengwynn
for letting me steal that.&lt;/p>
&lt;p>Before we get to that, I must mention &lt;a href="http://lab.arc90.com/2012/04/03/git-sweep/">git-sweep&lt;/a>.
It has been revolutionary to keeping branches (both locally and remote) clean.
If you care at all about the output of &lt;code>git branch&lt;/code>, install that now.&lt;/p>
&lt;p>However, there&amp;rsquo;s another simpler trick I just recently discovered. Deleting
multiple local branches with one command.&lt;/p>
&lt;pre>&lt;code>$ git branch -D old-branch-1 old-branch-2
&lt;/code>&lt;/pre>
&lt;p>That&amp;rsquo;s it! Simply pass as many branches into &lt;code>branch -D&lt;/code> as you want and &lt;code>git&lt;/code>
will gladly delete them all.&lt;/p>
&lt;h3 id="but-why-do-you-need-this">But why do you need this?&lt;/h3>
&lt;p>I just said that &lt;code>git-sweep&lt;/code> cleans up local and remote branches after they are
merged into &lt;code>master&lt;/code>. So, why would we ever need to delete local branches? For
one, you might not merge branches into master, but still want to delete them.
But more likely, you&amp;rsquo;ll need to do this after pulling down a colleague&amp;rsquo;s branch
to review. Once you give them the green light, it&amp;rsquo;s best practice for them to
rebase onto &lt;code>master&lt;/code> (interactively to prevent accidentally merging &lt;code>!fixup&lt;/code>
commits). However, you will have one state of the branch locally, but they&amp;rsquo;ve
merged a different, rebased state. This is just enough of a change to fool
&lt;code>git-sweep&lt;/code>, and &lt;code>git&lt;/code> herself, into missing the fact that these branches are
the same. Luckily, there is a quick way to identify and remove those branches
too.&lt;/p>
&lt;p>Handily, &lt;code>git-branch&lt;/code> has a super verbose mode which can be shown with the
&amp;ldquo;double v&amp;rdquo; flag (&lt;code>-vv&lt;/code>). This displays the branch name, HEAD commit, remote
tracking branch, and HEAD commit message.&lt;/p>
&lt;pre>&lt;code>$ git branch -vv
* gh-pages 123456 [origin/gh-pages] Show new features on the project website
master 654321 [origin/master] Merge features/super-new-feature into master
&lt;/code>&lt;/pre>
&lt;p>Additionally, super verbose mode will also show us when a remote tracking branch
disappears (is deleted). Immediately following the tracking branch name, we&amp;rsquo;ll
notice a &amp;ldquo;gone&amp;rdquo;.&lt;/p>
&lt;pre>&lt;code>$ git branch -vv
* master 654321 [origin/master] Merge features/super-new-feature into master
old-feature 523621 [origin/old-feature: gone] Users can see the brand new feature
&lt;/code>&lt;/pre>
&lt;p>I like to &lt;code>grep&lt;/code> for that and filter out the branches which I don&amp;rsquo;t want to
delete. Basically, my whole cleanup procedure goes like this:&lt;/p>
&lt;pre>&lt;code>$ git branch -vv | grep gone]
old-feature-1 523621 [origin/old-feature-1: gone] Link to the new account page
old-feature-2 856956 [origin/old-feature-2: gone] Toggle turtle visibility with feature flag
$ git branch -D old-feature-1 old-feature-2
Deleted branch old-feature-1 (was 523621).
Deleted branch old-feature-2 (was 856956).
&lt;/code>&lt;/pre>
&lt;p>And there you have it, removing multiple branches in git with a bonus of
finding branches who&amp;rsquo;ve lost their remote tracks.&lt;/p>
&lt;p>Happy branching!!&lt;/p>
&lt;p>&amp;ndash; Chris&lt;/p></description></item><item><title>Zeus gem error: "panic: runtime error: invalid memory address or nil pointer dereference"</title><link>https://codegoalie.com/posts/2013-03-16-zeus-gem-error-panic-runtime-error-invalid-memory-address-or-nil-pointer-dereference/</link><pubDate>Tue, 12 Feb 2013 00:00:00 +0000</pubDate><guid>https://codegoalie.com/posts/2013-03-16-zeus-gem-error-panic-runtime-error-invalid-memory-address-or-nil-pointer-dereference/</guid><description>&lt;p>I was getting this error and the &lt;!-- raw HTML omitted -->excellent Zeus rails environment loader gem&lt;!-- raw HTML omitted --> was crashing making it a huge bummer to dev.&lt;/p>
&lt;p>Luckily, I found a fix in &lt;!-- raw HTML omitted -->one of the open issues on the project&lt;!-- raw HTML omitted -->.&lt;/p>
&lt;p>It was easy to fix, just run a bundle install to add the missing gems:&lt;/p>
&lt;!-- raw HTML omitted -->
&lt;p>Easy as that. Hope this helps someone else!&lt;/p>
&lt;p>&amp;ndash; Chris&lt;/p></description></item><item><title>Ruby on Rails/ActiveSupport: To delegate or not to delegate</title><link>https://codegoalie.com/posts/2013-03-16-ruby-on-rails-slash-activesupport-to-delegate-or-not-to-delegate/</link><pubDate>Fri, 12 Aug 2011 00:00:00 +0000</pubDate><guid>https://codegoalie.com/posts/2013-03-16-ruby-on-rails-slash-activesupport-to-delegate-or-not-to-delegate/</guid><description>&lt;p>This is an account of my adventure with delegation from problem to apparent solution to bug in ActiveSupport to you&amp;rsquo;re doing it wrong!&lt;/p>
&lt;p>&lt;!-- raw HTML omitted -->TL;DR&lt;!-- raw HTML omitted -->&lt;/p>
&lt;p>Delegation is used when you want to forward a method call from on class/model to an associated class/model. The &lt;!-- raw HTML omitted -->Ruby on Rails Guides&lt;!-- raw HTML omitted --> use the example of a User model which has a Profile associated with it. This is a great example with a little subtlety which I overlooked. If you aren&amp;rsquo;t famaliar with delegation, go ahead and get yourself learned. I won&amp;rsquo;t wait for you though. This is text just come back when you&amp;rsquo;re up to speed.&lt;/p>
&lt;!-- raw HTML omitted -->
&lt;pre>&lt;code># app/views/drivers/show.html.haml
.truck_number
-if @driver.truck
= @driver.truck.number
-else
Not Driving any Truck
&lt;/code>&lt;/pre>
&lt;p>NBD. Here&amp;rsquo;s our problem:&lt;/p>
&lt;h3 id="the-problem">The Problem&lt;/h3>
&lt;p>As when any good application which acts as a font-end for a database, we track history on all edits, etc. So, when we update the Driver in a Truck, we want to add history for the Truck and the Driver. If the Driver is already in another Truck we want to show, in his history, that he moved from Truck 1001 into Truck 2002. We&amp;rsquo;ll say we have a create_history method included into our Entity classes whose declaration looks something like:&lt;/p>
&lt;pre>&lt;code>def create_history(attribute, prev_value, new_value)
&lt;/code>&lt;/pre>
&lt;p>So, we want to call something like:&lt;/p>
&lt;pre>&lt;code>@driver.create_history('Truck Number', @driver.truck.number, @new_truck.number)
&lt;/code>&lt;/pre>
&lt;p>Jackpot! Works perfectly. We get the old Truck number (1001) from the @driver instance and the new Truck number (2002) directly from the @truck instance. We are geniuses.
Hold the phone though. What if that Driver didn&amp;rsquo;t have a previous truck&amp;hellip; Spoiler Alert: &lt;!-- raw HTML omitted -->NoMethodError: undefined method &amp;lsquo;number&amp;rsquo; for nil:NilClass&lt;!-- raw HTML omitted --> I guess we could check that a Truck exists each time we want to access any attributes for Driver.truck. But, really, what do we expect Driver.truck.number to be if the Driver is not in a Truck? Nil would work&amp;hellip;&lt;/p>
&lt;h3 id="delegate-for-science">Delegate: for science!&lt;/h3>
&lt;p>I&amp;rsquo;ll allow it. Let&amp;rsquo;s delegate and allow_nil:&lt;/p>
&lt;pre>&lt;code># app/models/driver.rb
class Driver &amp;lt; ActiveRecord::Model
delegate :number, :to =&amp;gt; :truck, :prefix =&amp;gt; true, :allow_nil =&amp;gt; true
# ...
end
&lt;/code>&lt;/pre>
&lt;p>Works! Now, we&amp;rsquo;ve got history showing: Driver had no Truck and moved
into Truck 2002. Geniusness times 2. Delegation to perferction.&lt;/p>
&lt;hr>
&lt;p>Sometime later&amp;hellip;&lt;/p>
&lt;p>Instead of the Truck number, maybe we want to store the id of the Truck
in the history. Perhaps we know the truck number may change over time and want to link up the correct Truck record. Seems easy:&lt;/p>
&lt;pre>&lt;code>delegate :id, to: :truck, prefix: true, allow_nil: true
&lt;/code>&lt;/pre>
&lt;p>But, when our Driver doesn&amp;rsquo;t have a &amp;lsquo;previous&amp;rsquo; truck:&lt;/p>
&lt;pre>&lt;code>RuntimeError - Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id
&lt;/code>&lt;/pre>
&lt;p>WTF? I allowed nil. I know he doesn&amp;rsquo;t have a previous truck. I just want
my nil back and I&amp;rsquo;ll go about my business. Let&amp;rsquo;s get our hard hats on and
get digging into the source. I&amp;rsquo;ll save you some googling and just tell
you that the Delegation module is in ActiveSupport in the Core Extensions
under Module. Scroll, scroll, scroll. There! Line 136! They(we)(whomever)
are only rescuing from NoMethodErrors. Calling id on nil raises a
RuntimeError, which isn&amp;rsquo;t rescued and bubbles up to us. This is me
stomping my feet and wining. My knee jerk reaction was to just rescue
RuntimeErrors too:&lt;/p>
&lt;pre>&lt;code>rescue NoMethodError, RuntimeError
&lt;/code>&lt;/pre>
&lt;h3 id="were-gonna-be-famous">We&amp;rsquo;re gonna be Famous&lt;/h3>
&lt;p>It works! AND, how cool are we? We get to submit a bug fix to Rails.
Uber-cool. Uh-oh, uneasyness&amp;hellip;crap&amp;hellip;
It just doesn&amp;rsquo;t feel right to just catch any old RuntimeError and
possibly, silently fail to nil. However, the urge to try and submit a
simple &amp;lsquo;fix&amp;rsquo; to Rails was strong. Instead, I started doing more research
into delegate and Ruby Exception handling. Here&amp;rsquo;s what I&amp;rsquo;ve come up with:&lt;/p>
&lt;p>&lt;!-- raw HTML omitted -->&lt;!-- raw HTML omitted -->&lt;/p>
&lt;h3 id="the-moral-of-the-story">The Moral of the Story&lt;/h3>
&lt;p>You should delegate when you want to hide an architectural aspect and
expose the expected abstraction. In the Ruby on Rails Guides example,
we expect a user to have a name through @user.name even through name
actually resided in Profile. However, in our example, a Driver isn&amp;rsquo;t
expected to have a truck_id. A truck has an id, but a driver does not
have a truck_id.&lt;/p>
&lt;p>One of the classic &amp;lsquo;bad smells&amp;rsquo; in code for refactoring is using a
temporary variable in place a a query. Ruby and its optional
parantheses, blurs the lines between variable, attribute and method.
It&amp;rsquo;s easy to forget what you are doing and assume everything is an
attribute. Why shouldn&amp;rsquo;t a Driver have a truck_id? The same reason a
Truck doesn&amp;rsquo;t have a CDL. But, we can query the truck_id for the
kTruck associated with a Driver with a method.&lt;/p>
&lt;p>After all that, I should have just written a query method in Driver as
such:&lt;/p>
&lt;pre>&lt;code>def truck_id
self.truck.id if self.truck
end
&lt;/code>&lt;/pre>
&lt;p>Too easy&amp;hellip;&lt;/p>
&lt;p>&lt;strong>UPDATE 3/16/2013&lt;/strong>&lt;/p>
&lt;blockquote>
&lt;p>As I convert this blog to Octopress and reread
these posts, I&amp;rsquo;m see some imporvements. Instead of the code above, the
&lt;code>try&lt;/code> method is really what we want to use here:&lt;/p>
&lt;/blockquote>
&lt;blockquote>
&lt;pre>&lt;code> def truck_id
self.truck.try(:id)
end
&lt;/code>&lt;/pre>
&lt;/blockquote>
&lt;blockquote>
&lt;p>On &lt;code>Object&lt;/code>, &lt;code>try&lt;/code> will attempt to send the parameter as a message to
the invoking object. So, it works just like calling the method. However,
on &lt;code>nil&lt;/code>, &lt;code>try&lt;/code> simply returns &lt;code>nil&lt;/code>. It effectively exactly replaces
the first implementation nicely.&lt;/p>
&lt;/blockquote>
&lt;p>&amp;ndash; Chris&lt;/p></description></item><item><title>Ruby Auto-Responder for Postfix/Vmail</title><link>https://codegoalie.com/posts/2013-03-16-ruby-auto-responder-for-postfix-slash-vmail/</link><pubDate>Tue, 15 Feb 2011 00:00:00 +0000</pubDate><guid>https://codegoalie.com/posts/2013-03-16-ruby-auto-responder-for-postfix-slash-vmail/</guid><description>&lt;p>Not knowing perl, I set out to write my own script in Ruby to send auto-responses from e-mail addresses setup in a vmail folder structure. You don&amp;rsquo;t need to use postfix, just have the &amp;lsquo;new&amp;rsquo; folder where new messages are stored.&lt;/p>
&lt;p>I recently moved our company&amp;rsquo;s e-mail server to &lt;!-- raw HTML omitted -->a new VPS on slicehost&lt;!-- raw HTML omitted --> and started using postfix. I followed &lt;!-- raw HTML omitted -->this great tutorial on How-ToForge&lt;!-- raw HTML omitted --> (except for the squirrelMail part) to setup a mysql database with the vmail folders to store the mail. I couldn&amp;rsquo;t get the Autoresponder in the tutorial to function correctly. Actually, it was &amp;lsquo;eating&amp;rsquo; random mail, which was a weeks worth of headache in itself. So, we rolled out without any auto-response capabilities.&lt;/p>
&lt;p>I&amp;rsquo;ve been half-heartedly looking for another solution every few weeks, but haven&amp;rsquo;t found anything other than a few Perl scripts (I&amp;rsquo;m not really famaliar with perl). So, yesterday I decided to write a ruby script to send auto-responses. I wanted to use text files to hold each autoresponse. Then, I&amp;rsquo;d just move them int and out of a folder to activate and deactivate them. I also took advantage of the &amp;lsquo;new&amp;rsquo; folder within the vmail structure to reply to mail newer than the autoresponder config file.&lt;/p>
&lt;p>The format of the config files is:&lt;/p>
&lt;!-- raw HTML omitted -->
&lt;!-- raw HTML omitted -->
&lt;p>The message can be multiple lines until the end of the file.&lt;/p>
&lt;p>For each config file in the directory, the script parses the file for the above information. Then it will check that user&amp;rsquo;s new mail folder for files. Any new mail file which was modified (sent) after the modification date of the config file is parsed to get the sender&amp;rsquo;s address(es)*. A new e-mail is composed using &lt;!-- raw HTML omitted -->benprew&amp;rsquo;s pony gem&lt;!-- raw HTML omitted --> and sent to each of the senders. Finally, the script &amp;lsquo;touches&amp;rsquo; the config file to move the modification date newer than the messages for which it just responded.&lt;/p>
&lt;p>The nifty parts of the script are iterating over a directory listing of files:&lt;/p>
&lt;!-- raw HTML omitted -->
&lt;p>and using the &lt;!-- raw HTML omitted -->stat method&lt;!-- raw HTML omitted --> of a file object to get the modified dateTime:&lt;/p>
&lt;!-- raw HTML omitted -->
&lt;p>and lastly, using the FileUtils module to &amp;lsquo;touch&amp;rsquo; a file:&lt;/p>
&lt;!-- raw HTML omitted -->
&lt;p>Here&amp;rsquo;s the full source:&lt;/p>
&lt;script type="text/javascript" src="https://gist.github.com/827900.js">&lt;/script>
&lt;p>&amp;ndash; Chris&lt;/p></description></item><item><title>Keep ssh sessions from timing out</title><link>https://codegoalie.com/posts/2013-03-16-keep-ssh-sessions-from-timing-out/</link><pubDate>Thu, 20 May 2010 00:00:00 +0000</pubDate><guid>https://codegoalie.com/posts/2013-03-16-keep-ssh-sessions-from-timing-out/</guid><description>&lt;p>The &lt;a href="'http://embraceubuntu.com'">Ubuntu Blog&lt;/a> has a nice lil' article
about &lt;a href="'http://embraceubuntu.com/2006/02/03/keeping-ssh-sessions-alive/'">keeping SSH sessions alive&lt;/a>
It basically boils down to editing your &lt;code>/etc/ssh/ssh_config&lt;/code> file and
adding the following:&lt;/p>
&lt;pre>&lt;code># /etc/ssh/ssh_config
ServerAliveInterval 5
&lt;/code>&lt;/pre>
&lt;p>The number is the number of seconds to send the small keep alive which
keeps the connection open. Ubuntu Blog suggests changing it from 5 to
240 or 300 (4 or 5 minutes).&lt;/p>
&lt;p>&amp;ndash; Chris&lt;/p></description></item><item><title>Installing PianoBar - Console client for Pandora Radio</title><link>https://codegoalie.com/posts/2013-03-16-installing-pianobar-console-client-for-pandora-radio/</link><pubDate>Tue, 26 Jan 2010 00:00:00 +0000</pubDate><guid>https://codegoalie.com/posts/2013-03-16-installing-pianobar-console-client-for-pandora-radio/</guid><description>&lt;p>PianoBar is a console client for Pandora Internet Radio. For me, this
is a huge discovery. If you run Ubuntu, the flash player for Pandora
can be a pain in the ass to install. Plus, on my netbook, the flash
plugin for Chrome usually eats about 40-55% CPU constantly. A console
client for Pandora will resolve all these issues.&lt;/p>
&lt;p>However, the install instructions in the readme at the
&lt;a href="'http://github.com/PromyLOPh/pianobar'">PianoBar Github Repo&lt;/a> are very
sparse and for someone pretty new to linux (like me) may be a little
daunting. In the next few paragraphs, I will try to flesh out the
installation instructions for PianoBar on Ubuntu linux.&lt;/p>
&lt;h2 id="1-get-the-pianobar-source">1. Get the PianoBar source.&lt;/h2>
&lt;p>I downloaded the .tar.gz from &lt;a href="http://6xq.net/html/00/17.html">http://6xq.net/html/00/17.html&lt;/a> and
extracted it with&lt;/p>
&lt;pre>&lt;code>tar -xzf PromyLOPh-pianobar-e079b45.tar.gz
&lt;/code>&lt;/pre>
&lt;h2 id="2--try-to-make-the-pianobar-source">2. Try to Make the PianoBar source.&lt;/h2>
&lt;p>I say try because for me it didn&amp;rsquo;t work. I was missing some of the
required dependencies. But, you might not be missing the same ones as
me. So, try to make it and then follow the instructions below for the
dependencies you are missing.&lt;/p>
&lt;pre>&lt;code>cd PromyLOPh-pianobar-e079b45/
cmake .
&lt;/code>&lt;/pre>
&lt;h2 id="3-get-and-install-libao">3. Get and install libao&lt;/h2>
&lt;p>Libao is a cross-platform audio library for playing audio. I followed
&lt;a href="%22http://www.linuxfromscratch.org/blfs/view/cvs/multimedia/libao.html%22">these instructions from Linux from Scratch&lt;/a>
to install it. Download the source from that page. Extract the .tar.gz:&lt;/p>
&lt;pre>&lt;code>tar -xzf libao-0.8.8
&lt;/code>&lt;/pre>
&lt;p>Then, from withing the libao-0.8.8 directory, configure the library
with:&lt;/p>
&lt;pre>&lt;code>./configure --prefix=/usr &amp;amp;&amp;amp; make
&lt;/code>&lt;/pre>
&lt;p>Finally, install it as root:&lt;/p>
&lt;pre>&lt;code>sudo make install &amp;amp;&amp;amp; sudo install -v -m644 README /usr/share/doc/libao-0.8.8
&lt;/code>&lt;/pre>
&lt;p>Then, I retried step 2 to see that I didn&amp;rsquo;t need the LIBAO anymore.&lt;/p>
&lt;h2 id="4-install-faad2">4. Install FAAD2&lt;/h2>
&lt;p>Download the bootstrapped .tar.gz from
&lt;a href="%22http://www.audiocoding.com/downloads.html%22">AudioCoding.com&lt;/a>.
Extract the .tar.gz with:&lt;/p>
&lt;pre>&lt;code>tar -xzf f@d2-2.7
&lt;/code>&lt;/pre>
&lt;p>There are installation instructions in the INSTALL file in the
extracted folder. I&amp;rsquo;ll summarize what worked for me.
Configure it:&lt;/p>
&lt;pre>&lt;code>./configure
&lt;/code>&lt;/pre>
&lt;p>Make it:&lt;/p>
&lt;pre>&lt;code>make
&lt;/code>&lt;/pre>
&lt;p>Install it:&lt;/p>
&lt;pre>&lt;code>sudo make install
&lt;/code>&lt;/pre>
&lt;p>Then, I tried to make pianobar again. It still said it couldn&amp;rsquo;t find
libmad, but it turned out I didn&amp;rsquo;t need it.&lt;/p>
&lt;h2 id="5-install-pianobar">5. Install PianoBar.&lt;/h2>
&lt;p>After running the cmake from the extracted PianoBar folder, you should
see that the object files were made. Then, run make:&lt;/p>
&lt;pre>&lt;code>make
&lt;/code>&lt;/pre>
&lt;p>And install:&lt;/p>
&lt;pre>&lt;code>sudo make install
&lt;/code>&lt;/pre>
&lt;p>If all goes well, you will be able to run it:&lt;/p>
&lt;pre>&lt;code>./src/pianobar
&lt;/code>&lt;/pre>
&lt;p>Enter your pandora username/email address and password.
Choose your station.
Hear music!&lt;/p>
&lt;hr>
&lt;p>&lt;em>&lt;strong>UPDATE:&lt;/strong>&lt;/em>&lt;/p>
&lt;p>I recently used this post to install pianobar on another computer and was getting
&lt;!-- raw HTML omitted -->pianobar: error while loading shared libraries: &lt;a href="mailto:libf@d.so.2">libf@d.so.2&lt;/a>: cannot open shared object file: No such file or directory&lt;!-- raw HTML omitted -->
I needed to update the Shared Libraries (You can read more about Linux Shared Libraries from &lt;!-- raw HTML omitted -->this page&lt;!-- raw HTML omitted -->, specifically 3.5). I tried
&lt;!-- raw HTML omitted -->ldd /usr/local.bin/pianobar&lt;!-- raw HTML omitted -->
to see which shared libraries where being used by PianoBar and did see that libf@d/so/2 was not found.
&lt;!-- raw HTML omitted -->linux-gate.so.1 =&amp;gt; (0x0044c000)
&lt;a href="mailto:libf@d.so.2">libf@d.so.2&lt;/a> =&amp;gt; not found
libao.seeo.2 =&amp;gt; /usr/lib/libao.so.2 (0x00edb000)
libpthread.so.0 =&amp;gt; /lib/tls/i686/cmov/libpthread.so.0 (0x00507000)
libm.so.6 =&amp;gt; /lib/tls/i686/cmov/libibm.so.6 (0x00794000)
libc.so.6 =&amp;gt; /lib/tls/i686/cmov/libc.so.6 (0x00982000)
libdl.so.2 =&amp;gt; /lib/tls/i686/cmov/libdl.so.2 (0x00f20000)
/lib/0x00f20000ld-linux.so.2 (0x00f4e000)&lt;!-- raw HTML omitted -->
But I could find the &lt;a href="mailto:libf@d.so.2">libf@d.so.2&lt;/a> file in the &lt;!-- raw HTML omitted -->/usr/local/lib/&lt;!-- raw HTML omitted -->directory. Therefore, I needed to run ldconfig:
&lt;!-- raw HTML omitted -->sudo ldconfig&lt;!-- raw HTML omitted -->
Then I ran the ldd again and saw that &lt;a href="mailto:libf@d.so.2">libf@d.so.2&lt;/a> was now found in /usr/local/lib/ and PianoBar was now running again.
Also, I learned how to automatically sign in and change the keyboard short cuts.&lt;/p>
&lt;h2 id="6-pianobar-config">6. PianoBar config&lt;/h2>
&lt;p>You can change the configuration of PianoBar to switch up the keyboard short cuts and automatically login on run. To do this, you need to create and edit a file named &amp;lsquo;config&amp;rsquo; in the .config/pianobar/ within your home directory.&lt;/p>
&lt;pre>&lt;code>vim ~/.config/pianobar/config
&lt;/code>&lt;/pre>
&lt;p>To automatically login, add the following two lines&lt;/p>
&lt;pre>&lt;code>user = pandoraUserName
password = pandoraPassword
&lt;/code>&lt;/pre>
&lt;p>I also found that changing the &amp;ldquo;Loving Song&amp;rdquo; keyboard short cut from + to = worked out better, since I didn&amp;rsquo;t have to press Shift+=.&lt;/p>
&lt;pre>&lt;code>act_songlove = =
&lt;/code>&lt;/pre>
&lt;p>&amp;ndash; Chris&lt;/p></description></item><item><title>Notepad++ Color Configurator and styler.xml</title><link>https://codegoalie.com/posts/2013-03-16-notepad-color-configurator-and-styler-xml/</link><pubDate>Fri, 08 Jan 2010 00:00:00 +0000</pubDate><guid>https://codegoalie.com/posts/2013-03-16-notepad-color-configurator-and-styler-xml/</guid><description>&lt;p>Before I start talking about colors, let&amp;rsquo;s talk font.
&lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=22e69ae4-7e40-4807-8a86-b3d36fab68d3&amp;amp;displaylang=en">Consolas&lt;/a>.
That&amp;rsquo;s all you need to know. By far the best programming font. Get it. Use it. Love it.&lt;/p>
&lt;p>Recently I started learning Ruby on Rails and I found
&lt;a href="http://railscasts.com/">RailsCasts&lt;/a> with a ton of Rails focused screencasts.
I believe he use &lt;a href="http://macromates.com/">TextMate&lt;/a> for mac. I hadn&amp;rsquo;t really
thought much about color in my code before watching some of these screencasts.
But, it actually helps, a lot! I use Notepad++ in Windows and they have a great
styling system. You can use the in program Style Confirurator or you can
directly modify the XML style sheet.&lt;/p>
&lt;h1 id="style-configurator">Style Configurator&lt;/h1>
&lt;p>The Style Configurator is a dialog within Notepad++ accessible through the
Settings menu. The really great thing about the Configurator is that the styles
you choose are updated live in your code. So, open up a file with a lot of code.
Then open the Configurator and move it over to another screen. If you don&amp;rsquo;t have
more than one monitor, check the Transparency box in the lower right and you
will be able to see through the Configurator. The slider there sets the
Transparency level. Now you can see all of your code and pick styles for them.&lt;/p>
&lt;p>Start with the very first &amp;lsquo;language,&amp;rsquo; Global Styles. These not only include
default styles of text but many of the stuff around your code, such as line
number margin, inactive and active tab color, and the edge. The edge is great
to keep your lines of code to a certain length for printing or displaying in a
terminal. I also set the global font to Consolas. Also, be sure to set the
current line color and selected text background color.&lt;/p>
&lt;p>Now you are ready to style for you language. I usu PHP mostly at work so I&amp;rsquo;ll
go though that one. Hopefully, I&amp;rsquo;ll be familiar with Ruby soon enough to write
a post about Ruby styles.&lt;/p>
&lt;ul>
&lt;li>QUESTION MARK - This is the style of the opening and closing php tags
('&lt;!-- raw HTML omitted -->')&lt;/li>
&lt;li>DEFAULT - Text that doesn&amp;rsquo;t match any of the other styles will be this.&lt;/li>
&lt;li>STRING - Any string enclosed with double quotes&lt;/li>
&lt;li>STRING VARIABLE - variables enclosed withing literal strings: &amp;ldquo;The Count is
$count&amp;rdquo;&lt;/li>
&lt;li>SIMPLESTRING - These are string enclosed with single quotes. (I used a very
similar green to STRING)&lt;/li>
&lt;li>WORD - These are the keywords of PHP. There are a bunch defined. You can also
define some of your own in the blank box.&lt;/li>
&lt;li>NUMBER - Number literals, including array indices&lt;/li>
&lt;li>VARIABLE - Any word started with a $&lt;/li>
&lt;li>COMMENT - Text between matching multi-line comments ('/&lt;em>' and &amp;lsquo;&lt;/em>/')&lt;/li>
&lt;li>COMMENTLINE - Text on a line after and including two forward slashes (//)&lt;/li>
&lt;li>OPERATOR - Operators (+,=,-,etc.), matched parenthesis, brackets, curly
brackets and logical operators&lt;/li>
&lt;/ul>
&lt;h1 id="stylersxml">Stylers.xml&lt;/h1>
&lt;p>The stylers.xml file contains all the settings from the Configurator used by
Notepad++. In addition to using the Configurator, you can manually edit this
file. Or, download one from the web. The &lt;a href="http://notepad-plus.sourceforge.net/uk/download.php">Notepad++
site&lt;/a> has some under Theme
Files. &lt;a href="http://joyboner.com/60-free-textmate-notepad-styler-themes/">Joy Boner&lt;/a>
(read the &lt;a href="http://joyboner.com/about/">about page&lt;/a>) has 60 themes. I didn&amp;rsquo;t
check any of these out, but it might be worth a shot if you really don&amp;rsquo;t want
to set your own styles.&lt;/p>
&lt;p>I also put &lt;a href="http://gist.github.com/272115">my personal stylers.xml&lt;/a> as a gist
on github. Feel free to fork it.&lt;/p>
&lt;p>If you have any other Notepad++ styling tips, comment below!&lt;/p>
&lt;p>&amp;ndash;Chris&lt;/p></description></item></channel></rss>