Skip to content

Instantly share code, notes, and snippets.

View ahoward's full-sized avatar
💭
probably outside if i'm not hacking.

ara.t.howard ahoward

💭
probably outside if i'm not hacking.
View GitHub Profile
@ahoward
ahoward / a.md
Created December 26, 2014 23:24
rails generates urls with different default_url_option default in controllers vs. views - surprised the hell out of me ;-/
class ApplicationController < ActionController::Base
  def index
    @a = url_for(:action => :index)
    @b = url_for(:action => :index, :only_path => true)
  end
end
@ahoward
ahoward / a.rb
Created January 7, 2015 20:25
some of my favorite hacks on ruby's numeric classes
class Numeric
def parity
(self.to_i % 2) == 0 ? 'even' : 'odd'
end
end
class Fixnum
LONG_MAX = ( (2 ** (64 - 2)) - 1 )
INT_MAX = ( (2 ** (32 - 2)) - 1 )
@ahoward
ahoward / a.rb
Created January 9, 2015 00:26
one of my favorite utility methods
=begin
Util.relative_path('/any/path/to/root/foo/bar/a.png', :from => '/any/path/to/root') #=> 'foo/bar/a.png'
=end
module Util
require 'pathname'
require 'map'
@ahoward
ahoward / a.rb
Created January 10, 2015 22:14
sometimes you make teeny changes and want lighting fast deploys: add this task to your Capfile's for life-changing time savings
##
# cap production fast:deploy # taks about 3 seconds!
#
namespace :fast do
task :deploy do
run "cd #{ current_path } && git pull origin master 2>&1 && bundle install >/dev/null 2>&1 && touch tmp/restart.txt"
end
end
@ahoward
ahoward / a.md
Last active August 29, 2015 14:13
my perspective

we need to realize that covering women's racing might not equal coving men's racing

pros can only race so much, if one wants to increase exposure one needs to look outside making today's female pro racers earn coverage by working harder than the boys

@ahoward
ahoward / a.rb
Last active August 29, 2015 14:13
# hash ordering, combined with conversion, is very fragile
#
[1] pry(Site::Page)> attributes = args.extract_options!.to_options!
=> {:_id=>"54c004cab5b417316f000011",
:title=>"Atque cum ullam aliquid omnis aut.",
:path=>"atque-cum-ullam-aliquid-omnis-aut",
:body=>
"![itaque](/fake/images/tumblr_lu5gt565uZ1qe2jero1_1280.png \"Explicabo voluptatum expedita voluptatem voluptates dignissimos ipsum.\")\r\n\r\nlist\r\n------\r\n\r\n* one\r\n* two\r\n* three\r\n\r\nhttp://dojo4.com\r\n\r\n\r\nOmnis in est dicta amet non. Laudantium voluptatibus placeat officiis non commodi maxime aut. Aut deserunt omnis quod et quo velit. Dignissimos optio laboriosam iusto quia neque quisquam. At sed et.\r\n\r\nAlias neque non sint ipsum itaque. Consectetur unde nesciunt fuga atque. Voluptas dolores aut pariatur laboriosam.\r\n\r\n# heading 1\r\n## heading 2\r\n### heading 3\r\n \r\nhttp://dojo4.com\r\n\r\n\r\nIusto et assumenda beatae optio deleniti provident. Est laborum id voluptatem. Harum quas a possimus nemo
@ahoward
ahoward / a.sh
Created February 25, 2015 15:56
node.js is easy, but it's even easier with this ruby program, which is capable of generating any node program.
a:~ $ cat a.rb
(cb=proc{|*a| a.size < 42 ? cb.call('cb(', *a, ')') : a.join }).call(ARGV.shift).display
a:~ $ ruby a.rb 42
cb(cb(cb(cb(cb(cb(cb(cb(cb(cb(cb(cb(cb(cb(cb(cb(cb(cb(cb(cb(cb(42)))))))))))))))))))))
a-2:~/git/ahoward/fucking_favicons $ gem push pkg/fucking_favicons-1.0.0.gem
Pushing gem to https://rubygems.org...
<html>
<head><title>500 Internal Server Error</title></head>
<body bgcolor="white">
<center><h1>500 Internal Server Error</h1></center>
<hr><center>nginx</center>
</body>
</html>
a-2:~/git/ahoward/systemu $ gem push pkg/systemu-2.6.5.gem
Pushing gem to https://rubygems.org...
Successfully registered gem: systemu (2.6.5)