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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| %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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!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"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class FetchingProgressInstance | |
| attr_reader :enrollment, :roadmap | |
| def initialize(enrollment, roadmap) | |
| @enrollment = enrollment | |
| @roadmap = roadmap | |
| assign_progress_fetcher(@enrollment) | |
| end | |
| def fetch_progress |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Account < ActiveRecord::Base | |
| def transfer_to(destination, amount) | |
| self.balance -= amount | |
| destination.balance += amount | |
| destination.save | |
| self.save | |
| end | |
| end | |
| class TransfersController < ApplicationController |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 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) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |