Skip to content

Instantly share code, notes, and snippets.

View yrgoldteeth's full-sized avatar

Nicholas Fine yrgoldteeth

View GitHub Profile
@yrgoldteeth
yrgoldteeth / nginx.conf
Created December 30, 2015 02:06 — forked from davidcelis/nginx.conf
Nginx configuration to redirect HTTP traffic to HTTPS (Puma)
upstream puma {
server unix:///var/www/app/shared/tmp/sockets/puma.sock fail_timeout=0;
}
server {
listen 80 default deferred;
server_name example.com;
rewrite ^/(.+) https://example.com/$1 permanent;
}
@yrgoldteeth
yrgoldteeth / benchmark.rb
Created October 25, 2012 21:19 — forked from panthomakos/benchmark.rb
Benchmark Your Bundle
#!/usr/bin/env ruby
require 'benchmark'
REGEXPS = [
/^no such file to load -- (.+)$/i,
/^Missing \w+ (?:file\s*)?([^\s]+.rb)$/i,
/^Missing API definition file in (.+)$/i,
/^cannot load such file -- (.+)$/i,
]
@yrgoldteeth
yrgoldteeth / _orders.html.erb
Created November 11, 2011 03:34 — forked from gonzedge/_orders.html.erb
Rails 3.1 - will_paginate and ajax
<ul>
<% @orders.each do |order| %>
<li>
<!-- Show order stuff -->
</li>
<% end %>
</ul>
<%= will_paginate @orders %>
# I want this method in ruby-core
def let
yield
end
def fib(i)
let do |n = 1, result = 0|
if i == -1
result
else
#so very stolen from http://gist.github.com/145676
require 'open-uri'
def download(from, to = from.split("/").last)
#run "curl -s -L #{from} > #{to}"
file to, open(from).read
rescue
puts "Can't get #{from} - Internet down?"
exit!
end