Skip to content

Instantly share code, notes, and snippets.

View ericmathison's full-sized avatar

Eric Mathison ericmathison

View GitHub Profile
@ericmathison
ericmathison / triangle_bench.rb
Created October 7, 2020 19:36
Benchmarking codewars solutions
require 'benchmark/ips'
def triangle_calc(row)
return row if row.length == 1
triangle_calc(row.chars.each_cons(2).map do |a, b|
if a == b
a
else
(%w[R G B] - [a, b]).first
end
@ericmathison
ericmathison / gist:1d53b3f53fe68b0c351046df3422a4e0
Last active November 23, 2023 15:18
Deploy instructions for Rails using Puma, Nginx, and Ubuntu 18.04.

Deploy instructions for Rails using Puma, Nginx, and Ubuntu 18.04.

Sign up at www.atlantic.net (Select the Ubuntu 18.04 LTS operating system option). I was grandfathered in on Atlantic.net's $1 a month virtual private server (VPS) hosting. Unlike Heroku, you will have full control over the server. At some point in your application's lifetime this may become important to you for making customizations Heroku isn't capable of. Unless future limitations aren't a concern AND you don't want to learn how to set up a virtual private server, I wouldn't suggest using Heroku. The setup process below would be very similar for any of the other big hosting options like Amazon's EC2, DigitalOcean, etc.

Confirmation email will have log in instructions with IP, password and username.

Some of the commands below are run on the remote machine and others on your local development machine. I will prefix each command with one of the following:

remote-root#
remote$
eric@penguin ~/D/e/ethnic_la ((d04b3418…) $)> rails -v
Rails 5.1.5
eric@penguin ~/D/e/ethnic_la ((d04b3418…) $)> gem list rails
*** LOCAL GEMS ***
autoprefixer-rails (8.2.0)
coffee-rails (4.2.2)
dotenv-rails (2.2.1)
jquery-rails (4.3.1)
@ericmathison
ericmathison / server-setup-for-the-recycling-prices-application.md
Last active August 29, 2015 14:11
This gist describes the process that we used to set up the server for the Recycling Prices application.

Set up instructions for https://github.com/ericmathison/recycling_prices

Sign up at www.atlantic.net (Select the Ubuntu 14.04 LTS operating system option). Atlantic.net provides virtual private server (VPS) hosting for about $1 a month so it's a great option if you are learning how to set up a Rails application on a production server. Unlike Heroku, you will have full control over the server. At some point in your application's lifetime this may become important to you if you want to make customizations Heroku isn't capable of. Unless future limitations aren't a concern AND you don't want to learn how to set up a virtual private server, I wouldn't suggest using Heroku. The setup process below would be very similar for any of the other big hosting options like Amazon's EC2, DigitalOcean, etc.

Confirmation email will have log in instructions with IP, password and username.

Some of the commands below are run on the remote machine and others on your local development machine. I will prefix each command with on

@ericmathison
ericmathison / gist:8613357
Created January 25, 2014 08:11
Already Initialized Constant Warning
eric@penguin ~ $ pry [16:38:41]
[1] pry(main)> class Foo
[1] pry(main)* ASDF = 'hellooooo'
[1] pry(main)* class Bar
[1] pry(main)* class Baz
[1] pry(main)* def quux
[1] pry(main)* ASDF
[1] pry(main)* end
[1] pry(main)* end
[1] pry(main)* end