Skip to content

Instantly share code, notes, and snippets.

View Harrisonl's full-sized avatar

Harry Lucas Harrisonl

View GitHub Profile
######app/models/debt.rb
#Calculates how long to pay off each debt in order of highest interest to lowest
def self.payoff_highest_interest(debts)
balance = debts.sort{|a, b| b.interest <=> a.interest}.first.balance
date = Date.current.beginning_of_month
debts.reduce(0) do |acc, debt|
while debt.balance > 0
date = date + 1.month
acc + 1
adj_bal = balance + debt.compound_interest
Your version of git is 1.9.3. Which has serious security vulnerabilities.
More information here: https://blog.heroku.com/archives/2014/12/23/update_your_git_clients_on_windows_and_os_x
2015-03-02T02:07:31.768794+00:00 app[web.1]: 2015-03-02T02:07:31.768Z 6 TID-ou1wtjpdw WARN: Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED)
2015-03-02T02:07:31.768399+00:00 app[web.1]: /app/vendor/bundle/ruby/2.1.0/gems/celluloid-0.16.0/lib/celluloid/actor.rb:357:in `block in task'
2015-03-02T02:07:31.768400+00:00 app[web.1]: /app/vendor/bundle/ruby/2.1.0/gems/celluloid-0.16.0/lib/celluloid/tasks.rb:57:in `block in initialize'
2015-03-02T02:07:31.768402+00:00 app[web.1]: /app/vendor/bundle/ruby/2.1.0/gems/celluloid-0.16.0/lib/celluloid/tasks/task_fiber.rb:15:in `block in create'
2015-03-02T02:07:31.768856+00:00 app[web.1]: /app/vendor/bundle/ruby/2.1.0/gems/redis-3.2.1/lib/redis/client.rb:317:in `establish_connection'
2015-03-02T02:07:31.768397+00:00 app[web.1]: /app/vendor/bundle/ruby/2.1.0/gems/celluloid-0.1
@Harrisonl
Harrisonl / gist:0189631a177d28353000
Created March 10, 2015 04:50
User Creationg Error
Parameters: {"utf8"=>"✓", "authenticity_token"=>"5107GfscRkAvndwPHh8c28Qp1fLerclg1gj28uXbVWs=", "user"=>{"email"=>"bigtest@example.com", "password"=>"[FILTERED]", "full_name"=>"Big Test"}, "invitation_token"=>"", "date"=>{"month"=>"7", "year"=>"2018"}, "stripeToken"=>"tok_15efB4FypFkD9EmnhefCFXdz"}
User Exists (0.3ms) SELECT 1 AS one FROM "users" WHERE "users"."email" = 'bigtest@example.com' LIMIT 1
(0.2ms) BEGIN
CACHE (0.0ms) SELECT 1 AS one FROM "users" WHERE "users"."email" = 'bigtest@example.com' LIMIT 1
SQL (0.4ms) INSERT INTO "users" ("created_at", "customer_token", "email", "full_name", "password_digest", "token", "updated_at") VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING "id" [["created_at", "2015-03-10 04:41:12.602079"], ["customer_token", "cus_5qLsuR7eSAXqH6"], ["email", "bigtest@example.com"], ["full_name", "Big Test"], ["password_digest", "$2a$10$8pOt/X.Y.7D08i5XKdY/8uSyHCVQ.ZY7XwrNCO.FPHUlm2IXZ98A2"], ["token", "3lKuRnQWBjE7wPDv32U4xw"], ["updated_at", "2015-03-10 04:41:12.6020
@Harrisonl
Harrisonl / 0_reuse_code.js
Last active August 29, 2015 14:19
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
def pay_by_card
# Get the credit card details submitted by the form
token = params[:stripeToken]
charge = charge_customer(@project, token)
if charge.successful?
create_payment(@project)
@project.update_attributes(paid: true)
@project.create_conversation_for_project
ProjectsMailer.inform_admin.deliver_later
@Harrisonl
Harrisonl / Interview_example_rspec.rb
Created December 16, 2015 05:57
Code Examples + RSpec Example
## Here is the corresponding test file for Project Model.
require 'rails_helper'
RSpec.describe Project do
it { should validate_presence_of(:title) }
it { should validate_presence_of(:brief) }
it { should validate_presence_of(:project_type) }
it { should validate_presence_of(:project_length) }

Title: Tech Enthusiast

Name: William Sommers (Prefers to be called William)

Age: 19

Sex: Male

Marital: Single

** (exit) exited in: GenServer.call(Sherlock.SiteQueue, {:process}, 5000)
** (EXIT) time out
(elixir) lib/gen_server.ex:564: GenServer.call/3
iex(18)>
19:48:27.286 [error] Task #PID<0.207.0> started from Sherlock.SiteQueue terminating
** (stop) exited in: GenServer.call(#PID<0.180.0>, {:scrape, "TITLE"}, 5000)
** (EXIT) time out
(elixir) lib/gen_server.ex:564: GenServer.call/3
(poolboy) src/poolboy.erl:76: :poolboy.transaction/3
(elixir) lib/task/supervised.ex:89: Task.Supervised.do_apply/2
defmodule Binary do
def strip_vowels("", acc), do: acc
def strip_vowels(<<head::binary-size(1), rest::binary>>, acc \\ "") do
strip_vowels(rest, acc <> check_vowels(head))
end
defp check_vowels("a"), do: ""
defp check_vowels("e"), do: ""
defp check_vowels("i"), do: ""
def strip_vowels(string, acc = "")
return acc if string.length <= 0
case string[0].downcase
when "a"
strip_vowels(string[1..-1], acc)
when "e"
strip_vowels(string[1..-1], acc)
when "i"
strip_vowels(string[1..-1], acc)