<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[HollandaiseParty]]></title><description><![CDATA[Ruby. Code. Security. Pokemon. British Television.]]></description><link>http://hollandaiseparty.com</link><generator>NodeJS RSS Module</generator><lastBuildDate>Sun, 08 Mar 2026 15:42:49 GMT</lastBuildDate><atom:link href="http://hollandaiseparty.com/rss/" rel="self" type="application/rss+xml"/><author><![CDATA[superscott]]></author><ttl>60</ttl><item><title><![CDATA[Mercurial Quickstart Guide]]></title><description><![CDATA[<h5 id="basiccommands">Basic Commands</h5>

<p><code>hg branch</code> - display the branch you're currently on.</p>

<p><code>hg branches</code> - display all branches for the current repository.</p>

<p><code>hg checkout &lt;branchname&gt;</code> - checkout the specified branch. Also if you want to disregard any local changes before switching use the <code>--clean</code> option.</p>

<p><code>hg status</code> - show all files that have changes pending.</p>

<p><code>hg diff</code> - output the pending changes of all files.</p>

<p><code>hg commit -m &lt;commit message&gt;</code> - commit pending changes to your current branch.</p>

<p><code>hg pull</code> - get the most recent changes done to the repo, from the remote server.</p>

<p><code>hg update</code> - this will attempt to merge all the changes from the remote pull, to your local file system. </p>

<p><code>hg push</code> - push all your changes up to the remote server.</p>

<hr />

<h5 id="extracommands">Extra Commands</h5>

<p><code>hg serve</code> - by default, will start a server on <a href='http://localhost:8000/' >localhost:8000</a>, which will give you a neat little UI in your browser to view your mercurial logs, branch graphs, tags, bookmarks, and branches. It also has a help section to get more detailed info on <code>hg</code> commands, and whatnot.</p>

<p><code>hg graph -r &lt;commit revision&gt;</code> - when you want to pull in a specific change revision to your branch without pulling anything else (similar to <code>git cherry-pick</code>). Also depending on your Mercurial version, you can also use <code>hg transplant</code> <a href='http://mercurial.selenic.com/wiki/TransplantExtension' >more info</a></p>

<p><code>hg shelve</code> and <code>hg unshelve</code> - set your pending changes aside temporarily and restore them at a later time. <a href='http://mercurial.selenic.com/wiki/ShelveExtension' >more info</a> </p>]]></description><link>http://hollandaiseparty.com/mercurial-quickstart-guide/</link><guid isPermaLink="false">bc864de9-95f3-4dcc-8e86-e30b03321c16</guid><dc:creator><![CDATA[superscott]]></dc:creator><pubDate>Mon, 12 Jan 2015 19:34:22 GMT</pubDate></item><item><title><![CDATA[Order of AbstractController::Callbacks]]></title><description><![CDATA[<p>After not being able to find a resource for the order of the current <a href='http://api.rubyonrails.org/classes/AbstractController/Callbacks/ClassMethods.html' >Rails4 Controller Callbacks</a>, I ran all the callbacks to see what ran when.</p>

<p>I made an action with the same name as the filter, and had it output to logger.error.</p>

<pre><code>class HomeController &lt; ApplicationController
  after_action :after_action
  before_action :before_action
  append_after_action :append_after_action
  append_before_action :append_before_action
  prepend_after_action :prepend_after_action
  prepend_before_action :prepend_before_action
  around_action :around_action
  prepend_around_action :prepend_around_action
  append_around_action :append_around_action

  def after_action
    logger.error("after_action #{Time.now}")
  end

  def append_after_action
    logger.error("append_after_action #{Time.now}")
  end

  def append_around_action
    logger.error("append_around_action #{Time.now}")
    yield
  end

  def append_before_action
    logger.error("append_before_action #{Time.now}")
  end

  def around_action
    logger.error("around_action #{Time.now}")
    yield
  end

  def before_action
    logger.error("before_action #{Time.now}")
  end

  def prepend_after_action
    logger.error("prepend_after_action #{Time.now}")
  end

  def prepend_around_action
    logger.error("prepend_around_action #{Time.now}")
    yield
  end

  def prepend_before_action
    logger.error("prepend_before_action #{Time.now}")
  end

end
</code></pre>

<p>The output looked like this:</p>

<pre><code>  Started GET "/home/index" for 127.0.0.1 at 2014-03-12 15:41:02 -0700
  Processing by HomeController#index as HTML

prepend_around_action 2014-03-12 15:41:02 -0700
prepend_before_action 2014-03-12 15:41:02 -0700
before_action 2014-03-12 15:41:02 -0700
append_before_action 2014-03-12 15:41:02 -0700
around_action 2014-03-12 15:41:02 -0700
append_around_action 2014-03-12 15:41:02 -0700

  Rendered layouts/application.html.erb (0.5ms)
  Rendered home/index.html.erb (0.5ms)

append_after_action 2014-03-12 15:41:02 -0700
after_action 2014-03-12 15:41:02 -0700
prepend_after_action 2014-03-12 15:41:02 -0700

  Completed 200 OK in 12ms (Views: 9.8ms | ActiveRecord: 0.0ms)
</code></pre>

<p>Well balls, I needed something that ran after all my code but ran before I rendered the view, and none of the filters seemed to do that.</p>

<p>I found a type of answer on <a href='http://stackoverflow.com/questions/9281224/filter-to-execute-before-render-but-after-controller' >StackOverflow.</a></p>

<p>It called for injecting your own render action, and setting up a <code>before_action</code> filter that would set an instance variable to true for the action(s) you want to have your filter run on.</p>

<pre><code>before_action :set_global_modal, only: [:index]

def render(*args)
  build_global_modal if @do_global
  super
end  

def set_global_modal
  @do_global = true
end
</code></pre>

<p>It worked good for my situation. The only gotcha was that the monkeypatched render method will run for all of your renders in that controller. So just be sure to only run it in the controller you need it for and not have it in your ApplicationController, or every action in your entire program is going get routed through there.</p>

<p>If somebody has a better way to do this, let me know - cause this does seem kinda broken.</p>]]></description><link>http://hollandaiseparty.com/order-of-abstractcontrollercallbacks/</link><guid isPermaLink="false">06a931cf-77a7-42a0-9449-53eb5b676cf9</guid><dc:creator><![CDATA[superscott]]></dc:creator><pubDate>Tue, 25 Mar 2014 06:13:16 GMT</pubDate></item><item><title><![CDATA[Scumbag Rails .to_d]]></title><description><![CDATA[<p>Sigh.</p>

<pre><code>[1] hollandaise_party »  blank_string = String.new
=&gt; ""
[2] hollandaise_party »  price = blank_string.to_d
=&gt; 0.0
[3] hollandaise_party »  price.present?
=&gt; true
[4] hollandaise_party »  price = ''
=&gt; ""
[5] hollandaise_party »  price.present?
=&gt; false
</code></pre>

<p>Although I'm not sure what I expected to happen - when trying to figure out why </p>

<pre><code>validates :price, presence: true
</code></pre>

<p>was failing when I did not put a value into the input box on my form, turns out the above example is why. </p>

<p>I try not to rely on front end form validations all that much, and build out ActiveRecord validators first. And during the inital stages of testing, I couldn't figure out why that particular validation was failing when I didn't put anything in the input boxes.</p>

<p>Looking into further (I'm bad at source browsing) it looks to be doing something similar to <a href='http://www.ruby-doc.org/core-1.9.3/String.html' #method-i-to_f">Ruby's <code>to_f</code></a> method (even though I can't confirm it in the Rails/Rails repo). <br />
<code>If there is not a valid number at the start of str, 0.0 is returned.</code></p>

<p>So now we know if a blank string is passed to <code>price.to_d</code> method we're going to get <code>0.0</code>. Well we could just do a check to see if it's blank? <code>price.to_d if price.present?</code> which would technically work. But let's say a user passed in text to our input boxes, instead of an Integer. At that point, the previous example is going to fail. </p>

<pre><code>[6] hollandaise_party »  price = "loltext"
=&gt; "loltext"
[7] hollandaise_party »  price.present?
=&gt; true
[8] hollandaise_party »  price.to_d
=&gt; 0.0
</code></pre>

<p>Balls.</p>

<p>There were a few ideas floating around on StackOverflow on how to deal with this - most people opted for regex. However, a more clever solution which I think works better than regex was this:</p>

<pre><code>def is_a_number?(value)
  true if Float(value) rescue false
end
</code></pre>

<p>Which works for just about nearly any value you pass to it.</p>

<pre><code>[9] hollandaise_party »  Float('-1000.00')
=&gt; -1000.0
[10] hollandaise_party »  Float('1000')
=&gt; 1000.0
</code></pre>

<p>The only thing I found an issue with was if a comma was included in the value.</p>

<pre><code>[11] hollandaise_party »  Float('1,000.00')
ArgumentError: invalid value for Float(): "1,000.00"
from (pry):11:in `Float'
</code></pre>

<p>Easy enough solution for that, just <code>.tr</code> <a href='http://www.ruby-doc.org/core-1.9.3/String.html' #method-i-tr">(source)</a> the string and remove the comma, then pass that number to the <code>Float(value)</code>. The whole method that I ended up using looks like this. </p>

<pre><code>def is_a_number?(value)
  number = value.tr(',','')
  true if Float(number) rescue false
end
</code></pre>

<p>Now! Back to our validations! Should look something like this.</p>

<pre><code>price.to_d if is_a_number?(price)
</code></pre>

<p>Shazam. <br />
If there is a better way to do this let me know!</p>]]></description><link>http://hollandaiseparty.com/scumbag-rails/</link><guid isPermaLink="false">2da28a3f-522a-4dc0-a03e-a401fc5ef619</guid><dc:creator><![CDATA[superscott]]></dc:creator><pubDate>Wed, 01 Jan 2014 02:58:24 GMT</pubDate></item><item><title><![CDATA[Dynamic XML Element Names with Nokogiri]]></title><description><![CDATA[<p>Building an API with Rails and I wanted to respond back with a certain error message just using a hash. Easypeasy with JSON, however with XML it wasn't as straight forward.</p>

<p>Using this error_hash as our example response: <br />
<code>error_hash = {'LOGINFAILBOAT' =&gt; 'Yo Your Login/Password Failed'}</code></p>

<p>With JSON, you can pass that to your response block and works just fine; try to respond with XML and no bueno. However Nokogiri let's you make it work, by passing the key of your hash as the xml element name.  </p>

<p>When I hit my conditions to throw an error, I have it call the following method with the type and message, which is mostly a generic respond_to; with the exception of the XML response.</p>

<pre><code>def return_error_response(error_type, message)
  error_response = { error_type =&gt; message }

  respond_to do |format|
    format.json { render json: error_response }
    format.xml  { render xml: build_xml_error_message(error_response) }
  end
end
</code></pre>

<p>And if it's an XML it gets sent to this method.</p>

<pre><code>def build_xml_error_message(error_hash)
  error_attr = error_hash.keys.first
  error_valu = error_hash[error_attr]

  xml_error_message = Nokogiri::XML::Builder.new do |xml|
    xml.send(error_attr.to_sym, error_valu)
  end

  return xml_error_message

end
</code></pre>

<p>Pretty simple, but pretty simple was all I needed. </p>]]></description><link>http://hollandaiseparty.com/dynamic-element-names-with-nokogiri/</link><guid isPermaLink="false">5b883b9b-5a0b-4a8e-809d-5443176e3aa5</guid><dc:creator><![CDATA[superscott]]></dc:creator><pubDate>Sun, 22 Dec 2013 23:05:13 GMT</pubDate></item><item><title><![CDATA[Favorite Mac Addons]]></title><description><![CDATA[<p>For little over a year now I've been using a Mac at work and home, and I've come across some pretty legit programs that have made my life easier. </p>

<p><strong><a href='http://fluidapp.com/'  target="_blank">Fluid:</a></strong>
This let's you take any URL and turn it into it's own .app file. It's free, but paying the $5 USD price tag allows you to have your apps have their own cookie storage. (I have Facebook/Twitter/Gmail setup to use Fluid)</p>

<p><strong><a href='http://www.alfredapp.com/'  target="_blank">Alfred:</a></strong>
Assign a global hotkey that'll bring up a prompt to let you type out nearly any command you can think of - use it instead of using your mouse. </p>

<p><strong><a href='http://justgetflux.com/'  target="_blank">Flux:</a></strong>
Changes your monitor during sunrise/sunset to the white point you select to make your eyes hate you less.</p>

<p><strong><a href='http://totalspaces.binaryage.com/'  target="_blank">TotalSpaces:</a></strong>
Let's you do all the things you wanted to be able to do with desktop spaces. Being able to assign applications to open up in specific spaces is almost worth the price alone.</p>

<p><strong><a href='http://istumbler.net/'  target="_blank">iStumbler:</a></strong>
See all the wireless access points around you. <br />
<img src='http://hollandaiseparty.com/content/images/2013/Dec/Screen_Shot_2013_12_15_at_5_36_00_PM.png'  alt="istumb" /></p>

<p><strong><a href='http://kapeli.com/dash'  target="_blank">Dash:</a></strong>
Sometimes you don't have internet and you can't remeber the difference between <code>days_ago</code> and <code>days_since</code> </p>

<p><strong><a href='https://itunes.apple.com/us/app/rss-notifier/id618111399?mt=12'  target="_blank">RSS Notifier:</a></strong>
Cool RSS feed notifier that sits in your menu bar. (<a href='https://gist.github.com/superscott/7981207'  target="_blank">exportable copy of the feeds i follow</a>) </p>]]></description><link>http://hollandaiseparty.com/favorite-mac-addons/</link><guid isPermaLink="false">16ededb3-5e02-49ec-aff2-596dbd224883</guid><dc:creator><![CDATA[superscott]]></dc:creator><pubDate>Mon, 16 Dec 2013 01:49:08 GMT</pubDate></item><item><title><![CDATA[Ghost &amp; Nginx - Ubuntu 12.04]]></title><description><![CDATA[<p>Well the good thing is using DigitalOcean has a image for creating a ghost/nginx/ubuntu - so if you're using DO, then you can do what I did and just create a droplet with that image and be up and running super quick. </p>

<p>With that said, I wanted to list what the configs are incase anybody wants to use them. Most of these are default settings, so feel free to adjust as needed.</p>

<p>nginx version: nginx/1.1.19 <br />
<a href='https://gist.github.com/superscott/7979624'  target="_blank">NGINX Configs</a></p>

<p>Node.js: npm -v 1.3.11 <br />
<a href='https://gist.github.com/superscott/7979689'  target="_blank">Ghost: config.js</a> , <a href='https://gist.github.com/superscott/7979774'  target="_blank">Init.d Script</a></p>]]></description><link>http://hollandaiseparty.com/ghost-nginx-ubuntu-12-04/</link><guid isPermaLink="false">1fb7d5d8-c8ba-4843-81d0-dc8183547aad</guid><dc:creator><![CDATA[superscott]]></dc:creator><pubDate>Sun, 15 Dec 2013 23:28:08 GMT</pubDate></item><item><title><![CDATA[First.]]></title><description><![CDATA[<p><a href='http://www.crunchyroll.com/attack-on-titan'  target="_blank">Attack on Titan</a> is a fantastic show.</p>

<p><img src='http://hollandaiseparty.com/content/images/2013/Dec/654681f8eefdc13ad8dee196ff2a74f71366329524_full.jpg'  alt="aot" /></p>]]></description><link>http://hollandaiseparty.com/neat/</link><guid isPermaLink="false">63a935ad-5439-4701-bfea-bec4e2621f37</guid><dc:creator><![CDATA[superscott]]></dc:creator><pubDate>Sun, 15 Dec 2013 22:34:57 GMT</pubDate></item></channel></rss>