<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Hulihan Applications Blog</title>
    <link>http://blog.hulihanapplications.com</link>
    <description>Hulihan Applications - A design and programming firm Specializing in Web, Logo, and Graphic Design and programming, Web Design, Graphic Design, Logo Design, Network Administration/Security/Management and Web Site Hosting. Custom Design and Applications ar</description>
    <language>yourLanguage('en')</language>
    <item>
      <title>Sublime Text 2 Desktop Entry File </title>
      <description>&lt;p&gt;Are you using Ubuntu and Sublime Text 2 and need a handy launcher icon? Here's a &lt;code&gt;.desktop&lt;/code&gt; file That you 
can paste into &lt;code&gt;~/.local/share/applications/sublime_text.desktop&lt;/code&gt; or 
&lt;code&gt;/usr/share/applications/sublime_text.desktop&lt;/code&gt;: &lt;/p&gt;
&lt;script src="https://gist.github.com/2919938.js?file=sublime-text-2.desktop"&gt;&lt;/script&gt;
&lt;p&gt;
A couple things to note:
&lt;ul&gt;
&lt;li&gt;Remember to make this file executable.&lt;/li&gt;
&lt;li&gt;This file runs the &lt;code&gt;sublime_text&lt;/code&gt; binary. This assumes you already have the path to its parent directory in 
&lt;code&gt;$PATH&lt;/code&gt; or symlinked to &lt;code&gt;/usr/bin&lt;/code&gt; or something.&lt;/li&gt;
&lt;li&gt;If you don't have the Sublime Text icon on your machine, grab it &lt;a 
href="http://c758482.r82.cf2.rackcdn.com/sublime_text_icon_2181.png" target="_blank"&gt;here&lt;/a&gt; and save it as 
&lt;code&gt;~/.local/share/icons/sublime_text.png&lt;/code&gt;.
&lt;/p&gt;

&lt;p&gt;
Once you've set this up, you can lock it to your launcher. Here's a screenshot:
&lt;div align=center&gt;
&lt;a href="http://imgur.com/cjoJH"&gt;&lt;img src="http://i.imgur.com/cjoJH.png" title="Hosted by imgur.com" alt="" /&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;/p&gt;</description>
      <pubDate>Tue, 12 Jun 2012 13:28:00 -0400</pubDate>
      <link>http://blog.hulihanapplications.com/browse/view/74-sublime-text-2-desktop-entry-file</link>
      <guid>74</guid>
    </item>
    <item>
      <title>Nginx Unity Quicklist</title>
      <description>&lt;p&gt;Ubuntu's Unity Interface has many handy features, one of which is a new launcher bar that supports Quicklists. Each 
launcher icon can have a customizable list of options that let you run the program however you want. Here's a quicklist 
for the popular webserver &lt;a href="http://www.nginx.org"&gt;nginx&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img style="display: block; margin-left: auto; margin-right: auto;" src="http://i.stack.imgur.com/l8ocR.png" alt="Nginx 
Quicklist" width="308" height="356" /&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;First, Install &lt;a href="https://github.com/hulihanapplications/nginx-init-debian"&gt;nginx-init-ubuntu&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;
Add create a new file &lt;code&gt;.local/share/applications/&lt;/code&gt; named &lt;code&gt;nginx.desktop&lt;/code&gt; and paste this inside:
&lt;/p&gt;

&lt;pre&gt;
[Desktop Entry]
Name=Nginx
Comment=Nginx Webserver
Exec=sudo service nginx start
Icon=/usr/share/icons/nginx.png
Type=Application
Categories=Web;Servers;
StartupNotify=true
Terminal=true
#OnlyShowIn=GNOME;Unity;
X-Ubuntu-Gettext-Domain=nginx
X-Ayatana-Desktop-Shortcuts=Start;Stop;Restart;

[Start Shortcut Group]
Name=Start Nginx
Exec=sudo service nginx start
TargetEnvironment=Unity

[Stop Shortcut Group]
Name=Stop Nginx
Exec=sudo service nginx stop
TargetEnvironment=Unity

[Restart Shortcut Group]
Name=Restart Nginx
Exec=sudo service nginx restart
TargetEnvironment=Unity
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Using your file manager (such as nautilus), drag &lt;code&gt;.local/share/applications/nginx.desktop&lt;/code&gt; to the 
launcher.&lt;/li&gt;</description>
      <pubDate>Thu, 09 Feb 2012 14:35:00 -0500</pubDate>
      <link>http://blog.hulihanapplications.com/browse/view/73-nginx-unity-quicklist</link>
      <guid>73</guid>
    </item>
    <item>
      <title>nginx init script for ubuntu/debian</title>
      <description>&lt;p&gt;For those of you using nginx and debian-based distributions such as Ubuntu, Mepis, Mint, etc. you may have noticed 
that the &lt;a href="http://wiki.nginx.org/Nginx-init-ubuntu"&gt;init script&lt;/a&gt; on nginx's wiki doesn't work very well with 
newer distributions such as Ubuntu 10.04/11.10, etc. Instead, let's use upstart, which is much cleaner.
&lt;/p&gt;

&lt;p&gt;
First, add this to &lt;code&gt;/etc/init/nginx.conf&lt;/code&gt;:
&lt;/p&gt;

&lt;pre name="code" class="bash"&gt;
description "Nginx HTTP Server"

start on filesystem
stop on runlevel [!2345]

respawn
exec /opt/nginx/sbin/nginx -g "daemon off;"
&lt;/pre&gt;

&lt;p&gt;
Note:  By default, this script thinks nginx is in &lt;code&gt;/opt/nginx&lt;/code&gt;. If your nginx configuration is different, change 
it to specify the correct location.
&lt;/p&gt;

&lt;p&gt;
...now start 'er up:
&lt;/p&gt;

&lt;pre&gt;
&lt;code&gt;
$ sudo start nginx
nginx start/running, process 11922
&lt;/code&gt;
&lt;/pre&gt;

&lt;p&gt;That's all there is to it. You can fork this script over at &lt;a href="https://github.com/hulihanapplications/nginx-init-
debian"&gt;github&lt;/a&gt; if you 
want to make any changes or suggestions. This repo also includes an old System V style script if you need it.&lt;/p&gt;

&lt;h3&gt;Kudos&lt;/h3&gt;
&lt;p&gt;This script is based off of Big Rock's upstart script from their&lt;a 
href="http://blog.bigrocksoftware.com/2011/01/07/rvm-nginx-passenger-rails-3/"&gt;
RVM + Rails 3 + nginx + Phusion Passenger&lt;/a&gt; guide.&lt;/p&gt;

&lt;p&gt;
* Updated 2012-04-10: Added upstart instructions
&lt;/p&gt;</description>
      <pubDate>Thu, 26 Jan 2012 07:37:00 -0500</pubDate>
      <link>http://blog.hulihanapplications.com/browse/view/72-nginx-init-script-for-ubuntu-debian</link>
      <guid>72</guid>
    </item>
    <item>
      <title>Aptana desktop entry file</title>
      <description>&lt;p&gt;For those of you Linux users using Gnome, KDE, or Unity, here's a desktop entry file that you can use to create a 
shortcut/launcher 
icon to Aptana Studio 3. Just add this to &lt;code&gt;/usr/share/applications&lt;/code&gt; or &lt;code&gt;~/.local/share/applications&lt;/code&gt;.&lt;/p&gt;

&lt;pre&gt;
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Name=Aptana Studio 3
Comment=The professional, open source development tool for the open web
Icon=/opt/aptana-studio-3/icon.xpm
GenericName=Aptana Studio
Type=Application
Exec=/opt/aptana-studio-3/AptanaStudio3
MimeType=text/plain;
Categories=Development;IDE;
&lt;/pre&gt;

&lt;p&gt;This assumes you've installed Aptana to &lt;code&gt;/opt/aptana-studio-3&lt;/code&gt;, so if yours is in a different directory, be sure to 
change it.&lt;/p&gt;
&lt;h3&gt;Kudos&lt;/h3&gt;
&lt;p&gt;Credit goes to &lt;a href="http://wvega.com/"&gt;Willington Vega&lt;/a&gt; for supplying the &lt;a 
href="https://gist.github.com/1024232"&gt;original&lt;/a&gt; desktop entry file.&amp;nbsp;&lt;/p&gt;
&lt;h1 class="avatared" style="font-size: 30px; height: 54px; letter-spacing: -1px; text-shadow: #ffffff 1px 1px 0px; color: #495961; 
line-height: 54px; font-family: helvetica, arial, freesans, clean, sans-serif; padding: 0px; margin: 0px;"&gt;&lt;span style="color: 
#99a7af;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h1&gt;</description>
      <pubDate>Mon, 23 Jan 2012 00:25:00 -0500</pubDate>
      <link>http://blog.hulihanapplications.com/browse/view/71-aptana-desktop-entry-file</link>
      <guid>71</guid>
    </item>
    <item>
      <title>Introducing fletcher</title>
      <description>&lt;p align=center&gt;
  &lt;img src="http://www.hulihanapplications.com/images/projects/fletcher.png"&gt;
&lt;/p&gt;

&lt;p&gt;We recently created a new ruby gem called &lt;a href="https://rubygems.org/gems/fletcher"&gt;fletcher&lt;/a&gt;. It's a cross-
website product/item information fetcher. To use fletcher, all you have to do it pass it a url to a product on one of 
favorite 
websites. You'll get back an easy-to-use ActiveRecord-like object(a &lt;a 
href="https://github.com/intridea/hashie"&gt;Hashie::Mash&lt;/a&gt;) that contains useful information about that product, 
including 
its name, description, images, etc. Let's see it in action.&lt;/p&gt;

&lt;pre name="code" class="ruby:nocontrols"&gt;
item = Fletcher.fetch

item.name # =&gt; "Avenir Deluxe Unicycle (20-Inch Wheel)"

item.description # =&gt; "A wonderful unicycle"

item.image # =&gt; {:url =&gt; "http://ecx.images-amazon.com/images/I/41b3TNb3uCL._SL500_AA300_.jpg", :alt =&gt; "Picture of 
Unicycle"}

item.image.url # =&gt; "http://ecx.images-amazon.com/images/I/41b3TNb3uCL._SL500_AA300_.jpg"
&lt;/pre&gt;

&lt;p&gt;We originally wrote fletcher for use in our wishlist-sharing website, &lt;a 
href="http://www.wishlistfactory.com"&gt;WishlistFactory&lt;/a&gt;, so you would only need to enter the url of a gift you want, 
and 
the gift information would automatically be fetched and included on your wishlist. We thought other people might find 
this 
useful, so we packaged it up as a gem and released it to the public. &lt;/p&gt;
&lt;p&gt;The &lt;a href="https://github.com/hulihanapplications/fletcher"&gt;source code of fletcher&lt;/a&gt; is also on github, so if 
you'd 
like to add a supported website to fletcher, or make any other changes, feel free to fork it!&lt;/p&gt;</description>
      <pubDate>Tue, 20 Dec 2011 08:49:00 -0500</pubDate>
      <link>http://blog.hulihanapplications.com/browse/view/70-introducing-fletcher</link>
      <guid>70</guid>
    </item>
    <item>
      <title>Autodetecting OAuth Providers with OmniAuth</title>
      <description>&lt;p align=center&gt;
&lt;img src="http://blog.hulihanapplications.com/images/uploaded_images/normal/omniauth.JPG" alt="" 
style="width:600px" /&gt;
&lt;/p&gt;
&lt;p&gt;OmniAuth is a great gem for OAuth authentication in any rack application such as Ruby on Rails, Sinatra, etc. If 
you're using it in Rails, I wrote a handy little initializer that will automatically load in your OAuth provider credentials 
from a yaml config file instead of defining them directly in the initialzer. &lt;/p&gt;
&lt;pre name="code" class="ruby:nocontrols"&gt;
# config/providers.yml
providers:
  google:
    key: CONSUMER_KEY
    secret: CONSUMER_SECRET 
  facebook:
    key: APP_ID
    secret: APP_SECRET
  twitter:
    key: CONSUMER_KEY
    secret: CONSUMER_SECRET

# config/initializers/omniauth.rb
if Rails.env != 'test'  
  config = YAML::load(File.open(Rails.root.join, "config", "providers.yml")))
  if config &amp;amp;&amp;amp; !config.empty?
    Rails.application.config.middleware.use OmniAuth::Builder do        
      config["providers"].each do |name, credentials|
        provider name.to_sym, credentials["key"], credentials["secret"], {:client_options =&amp;gt; config[:client_options]}       
      end
    end
  end
end
&lt;/pre&gt;
&lt;p&gt;
This makes it easy to add/delete providers by editing the providers.yml config file.
&lt;/p&gt;</description>
      <pubDate>Thu, 15 Sep 2011 17:10:00 -0400</pubDate>
      <link>http://blog.hulihanapplications.com/browse/view/69-autodetecting-oauth-providers-with-omniauth</link>
      <guid>69</guid>
    </item>
    <item>
      <title>Introduction to Humanizer</title>
      <description>&lt;p&gt;&lt;a href="https://github.com/kiskolabs/humanizer" target="_blank"&gt;Humanizer&lt;/a&gt;&amp;nbsp;is a great little Rails 3 gem 
that provides basic text-based captcha validation to your models &amp;amp; forms. This verifies whether the form 
submitter is human or not.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;While&amp;nbsp;many other captchas are image based, they're not usually suitable for applications that can be used 
with several locales/languages. You wouldn't show a Russian user an image with English text, right?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Humanizer solves this problem by using I18n-based question and answer files. It also comes with several 
prewritten question files in several languages, and it's easy to edit these later if you want to add custom questions.
&lt;/p&gt;
&lt;h3&gt;Installation&lt;/h3&gt;
&lt;pre&gt;
gem install humanizer
rails g humanizer
&lt;/pre&gt;
&lt;h3&gt;Usage&lt;/h3&gt;
Add this to your model:
&lt;pre name="code" class="ruby:nocontrols"&gt;
class User &lt; ActiveRecord::Base
  include Humanizer
  require_human_on :create
end
&lt;/pre&gt;

Then add this to your form:
&lt;pre name="code" class="ruby:nocontrols"&gt;
&lt;%= f.label :humanizer_answer, f.object.humanizer_question %&gt;
&lt;%= f.text_field :humanizer_answer %&gt;
&lt;%= f.hidden_field :humanizer_question_id %&gt;
&lt;/pre&gt;

&lt;h3&gt;Controller Support&lt;/h3&gt;
&lt;p&gt;Right now, Humanizer is used only with ActiveRecord models and FormBuilder(ie: &lt;em&gt;form_for&lt;/em&gt;). If you 
want to add Humanizer support to Rails forms that don't use these(such as &lt;em&gt;form_tag&lt;/em&gt;), you can add 
controller support with an initializer. Copy this to &lt;em&gt;config/initializers/humanizer.rb&lt;/em&gt;:&lt;/p&gt;
&lt;pre name="code" class="ruby:nocontrols"&gt;
module Humanizer
  module ActionController
    def self.included(base)
      base.send(:include, ::Humanizer) # add Humanizer support to Controller class
      base.send(:include, InstanceMethods)  
    end
    
    module InstanceMethods
      def check_humanizer_answer
        unless human?
          flash[:failure] = I18n.translate("humanizer.validation.error")
          redirect_to :back
        end
      end
      
      def human?
        if params[:humanizer_answer] &amp;&amp; params[:humanizer_question_id]
          self.humanizer_answer = params[:humanizer_answer]
          self.humanizer_question_id = params[:humanizer_question_id]
          return humanizer_correct_answer?                        
        else
          return false
        end 
      end
    end
  end
end

ActionController::Base.send :include, Humanizer::ActionController # add humanizer support to controller
&lt;/pre&gt;
&lt;p&gt;Then add this to your form:&lt;/p&gt;
&lt;pre name="code" class="ruby:nocontrols"&gt;
&lt;%= label_tag :humanizer_answer, controller.humanizer_question %&gt;
&lt;%= text_field_tag :humanizer_answer %&gt;
&lt;%= hidden_field_tag :humanizer_question_id, controller.humanizer_question_id %&gt;
&lt;/pre&gt;
&lt;p&gt;And this to your controller:&lt;/p&gt;
&lt;pre name="code" class="ruby:nocontrols"&gt;
# app/controllers/your_controller.rb
class YourController &lt; ApplicationController
  before_filter :check_humanizer_answer, :only =&gt; [:send_email]
&lt;/pre&gt;
&lt;p&gt;
That's it!
&lt;/p&gt;</description>
      <pubDate>Sun, 11 Sep 2011 14:21:00 -0400</pubDate>
      <link>http://blog.hulihanapplications.com/browse/view/68-introduction-to-humanizer</link>
      <guid>68</guid>
    </item>
    <item>
      <title>Mass rename .rhtml files to .html.erb</title>
      <description>&lt;p&gt;Are you upgrading an old Rails 2.x application to Rails 3? If so, you'll probably want to change any files ending in 
&lt;i&gt;.rhtml&lt;/i&gt; to &lt;i&gt;.html.erb&lt;/i&gt;. Here's a handy command that will recursively rename every .rhtml file in your entire 
application:
&lt;/p&gt;

&lt;pre&gt;
find ./ -name \*.rhtml -type f | sed 's/\(.*\).rhtml$/mv "&amp;" "\1.html.erb"/' | sh 
&lt;/pre&gt;
</description>
      <pubDate>Sat, 27 Aug 2011 03:06:00 -0400</pubDate>
      <link>http://blog.hulihanapplications.com/browse/view/66-mass-rename-rhtml-files-to-html-erb</link>
      <guid>66</guid>
    </item>
    <item>
      <title>Teamwork: whenever and bundler</title>
      <description>&lt;p&gt;Here's a quick &lt;a href="https://github.com/javan/whenever" target="_blank"&gt;whenever&lt;/a&gt; schedule.rb file for of you who are using bundler to run rake commands(via bundle exec).&lt;/p&gt;
&lt;pre name="code" class="ruby:nocontrols"&gt;
job_type :bundle_exec, 'cd :path &amp;&amp; bundle exec :task :output' # :path is set to project dir by default

every 1.hours do
  # bundle_exec "rake [task]"
  bundle_exec "rake log:clear"
end
&lt;/pre&gt;

</description>
      <pubDate>Wed, 24 Aug 2011 19:27:00 -0400</pubDate>
      <link>http://blog.hulihanapplications.com/browse/view/65-teamwork-whenever-and-bundler</link>
      <guid>65</guid>
    </item>
    <item>
      <title>RSpec &amp; Rails: Simulating File Uploads </title>
      <description>&lt;p&gt;Do you need to simulate file uploads while testing in Rails &amp;amp; RSpec? Well, It's easy to do. Let's  pretend you're using rails 3.0.9 and you want to test uploading a picture, which will be stored as an record of an Image model. Let's also assume that you can pass an uploaded file directly to your model. Here's what your model might look like:&lt;/p&gt;
&lt;pre name="code" class="ruby:nocontrols"&gt;class Image &amp;lt; ActiveRecord::Base
  attr_accessor :file
  before_create :save file

  def save_file
    File.open(Rails.root.join('public', 'images', file.original_filename), 'w') do |file|
       file.write(file.read)
     end
  end
end
&lt;/pre&gt;
&lt;p&gt;To simulate a file upload in your test, save a real file in a directory somewhere(we'll use spec/fixtures/images), and then create a new Image record and pass it a &lt;strong&gt;ActionDispatch::Http::UploadedFile&lt;/strong&gt; object (which rails uses to handle uploaded files).&lt;/p&gt;
&lt;pre name="code" class="ruby:nocontrols"&gt;file = File.new(Rails.root + 'spec/fixtures/images/rails.png')
@image = Image.new(:file =&amp;gt; ActionDispatch::Http::UploadedFile.new(:tempfile =&amp;gt; file, :filename =&amp;gt; File.basename(file))
file.close
@image.save
&lt;/pre&gt;

&lt;p&gt;That's it! Now your Image record has a valid file, just like the real thing. If you're using factory_girl for testing, you can automatically create a record with a file already "uploaded" to it:&lt;/p&gt;
&lt;pre name="code" class="ruby:nocontrols"&gt;Factory.define :image do |o|
  file = File.new(Rails.root + 'spec/fixtures/images/rails.png')
  file.rewind
  o.file ActionDispatch::Http::UploadedFile.new(:tempfile =&amp;gt; file, :filename =&amp;gt; File.basename(file))
end

@image = Factory(:image)
&lt;/pre&gt;</description>
      <pubDate>Mon, 22 Aug 2011 14:41:00 -0400</pubDate>
      <link>http://blog.hulihanapplications.com/browse/view/64-rspec-rails-simulating-file-uploads</link>
      <guid>64</guid>
    </item>
  </channel>
</rss>
