Skip to content

Instantly share code, notes, and snippets.

Avatar

Ryan Bigg radar

View GitHub Profile
View spec and code
it 'has a method that will call the transaction class' do
Transaction.should_receive(:new);
bank.send(:make_deposit, 5);
end
def make_deposit(amount)
Transaction.new(self, 'deposit', amount);
end
@radar
radar / index.html.erb
Created Jun 15, 2018
Problematic code
View index.html.erb
<table>
<tr>
<th>Subject</th>
<th>Created At</th>
<th>Status</th>
</tr>
<% @tickets.each do |ticket| %>
<tr>
<td><a href="/ticket/<%= ticket.id %>"><%= ticket.subject %></a></td>
View part 2?
totalprice=0
totalitemcount=0
laborcharge=0
discount= 0
totalgccount=0
View gist:8125a3a8f6d88f73e6d6e7b4f4452820
require 'concurrent'
class Test
def update(time, value, reason)
puts "OMG"
end
end
puts 'testing . . .'
View read.rb
class ApiRead
require 'open-uri'
require 'json'
attr_reader :data
def initialize(url)
# this goes fine
@data = JSON.parse(open(url).read)["data"]
end
View scrabble.ex
defmodule Scrabble do
def score(l) when l in [nil, ""] do: 0
def score(l) when l in ["A", "E", "I", "O", "U"] do: 1
def score(word) do
word
|> String.upcase
|> String.split("")
|> Enum.map(&(score(&1)))
|> Enum.sum
View rubocop.rb
def if_statement
return a unless condition?
c(
1,
2,
3
)
end
View rubocop.rb
def if_statement
a
if condition?
c(
1,
2,
3
)
end
end
@radar
radar / test.rb
Last active Feb 7, 2017 — forked from anonymous/test.rb
does self do an inner join on i
View test.rb
class Parent < ActiveRecord::Base
has_many :children
#Question: Does method below perform a join in children and match only children belonging to a specific parent?
def has_active_children
children.exists?(status: "active")
end
@radar
radar / Routine wanted as Back Job
Created Feb 1, 2017 — forked from crova/Routine wanted as Back Job
Trying to get a Back Job working
View Routine wanted as Back Job
# Fetchs campaigns from SiB
class CampaignFetch
def get
def sib
@sib ||= Mailin.new("API_URL","API_KEY")
end
def shoot_criteria
{ "type"=>"classic", "status" => "sent", "page"=>10,"page_limit"=>1000 }