Skip to content

Instantly share code, notes, and snippets.

View raderj89's full-sized avatar

Jared Rader raderj89

View GitHub Profile
%h2 New Project
= form_for(@project) do |f|
%div{ id: "error_explanation" }
- if @project.errors.any?
%h2= pluralize(@project.errors.count, "error")
Prohibited this project from being saved:
%ul
- @project.errors.full_messages.each do |msg|
%li= msg
%p
@raderj89
raderj89 / jquery_example.html
Last active August 29, 2015 13:57 — forked from dbc-challenges/jquery_example.html
Intro to jQuery for Phase 0
<!DOCTYPE html>
<html>
<head>
<title>DOM manipulation with jQuery</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="jquery_example.js"></script>
</head>
<body>
<h1> Hello. Welcome to the jQuery DOM Manipulation Challenge! </h1>
<div class="mascot">
@raderj89
raderj89 / 0_reuse_code.js
Created April 30, 2014 15:05
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

This JavaScript code represents some functionality to dynamically add links to employee goals and company grades added in past meetings on the Taqeela app. Grades and goals are added under one meeting, but the UI requirements we were given called for displaying different sections where these data could be accessed. Had I not taken an object oriented approach, I'd have had to duplicate the same jQuery code for each call.

# spec/controllers/properties_controller_spec.rb
require 'spec_helper'
describe PropertiesController do
let(:manager_invitation) { create(:manager_invitation) }
describe 'GET #new' do
context 'with invalid invitation token' do
it "redirects to root path" do
get :new, invitation_token: 'asdfsae'
require 'spec_helper'
describe Referral do
let(:company) { FactoryGirl.create(:company) }
before do
@referral = company.referrals.build(details: "Lorem ipsum", link: "http://example.com")
@referrals = Referral.all
end
class FetchingProgressInstance
attr_reader :enrollment, :roadmap
def initialize(enrollment, roadmap)
@enrollment = enrollment
@roadmap = roadmap
assign_progress_fetcher(@enrollment)
end
def fetch_progress
@raderj89
raderj89 / money_transfer.rb
Last active September 10, 2015 20:43
DCI example
class Account < ActiveRecord::Base
def transfer_to(destination, amount)
self.balance -= amount
destination.balance += amount
destination.save
self.save
end
end
class TransfersController < ApplicationController
@raderj89
raderj89 / sums_consecutive_position.js
Last active March 15, 2016 06:28
Sums of consecutive integers
/**
* Given the number of consecutive integers and the total of the integers,
* return the consecutive integer at the requested position.
*
* @param {int} x number of consecutive integers
* @param {int} y sum of consecutive integers
* @param {int} n position of requested integer
* @return {int} consecutive integer at requested position
*/
function position(x, y, n) {
@raderj89
raderj89 / sum.exs
Created April 7, 2016 17:33
write a sum function without an accumulator
# Write a sum function without an accumulator
defmodule MyList do
def sum([]), do: 0
def sum([x]), do: x
def sum([ head | tail ]), do: head + sum(tail)
end