Skip to content

Instantly share code, notes, and snippets.

View radar's full-sized avatar

Ryan Bigg radar

View GitHub Profile
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 June 15, 2018 05:26
Problematic code
<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>
@radar
radar / part 2?
Created February 5, 2018 04:02 — forked from anonymous/part 2?
totalprice=0
totalitemcount=0
laborcharge=0
discount= 0
totalgccount=0
require 'concurrent'
class Test
def update(time, value, reason)
puts "OMG"
end
end
puts 'testing . . .'
@radar
radar / read.rb
Last active November 13, 2017 05:53 — forked from basicavisual/json-sample.json
class ApiRead
require 'open-uri'
require 'json'
attr_reader :data
def initialize(url)
# this goes fine
@data = JSON.parse(open(url).read)["data"]
end
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
def if_statement
return a unless condition?
c(
1,
2,
3
)
end
def if_statement
a
if condition?
c(
1,
2,
3
)
end
end
@radar
radar / test.rb
Last active February 7, 2017 02:40 — forked from anonymous/test.rb
does self do an inner join on i
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 February 1, 2017 04:12 — forked from crova/Routine wanted as Back Job
Trying to get a Back Job working
# 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 }