This file contains 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
def get_prerequisites(requirement_type, course, requirement_collection) | |
course.send(requirement_type).each do |pre| | |
requirement_collection << pre.prerequisites | |
get_prerequisites(requirement_type, pre, requirement_collection) | |
end | |
end | |
def requirement_graph(requirement_type) | |
course_map = [self.send(requirement_type)] | |
get_prerequisites(requirement_type, self, course_map) |
This file contains 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
# Make sure you gem install http | |
require 'http' | |
class Committer | |
attr_reader :name, :email | |
def initialize(params) | |
@name = params["name"] | |
@email = params["email"] |
This file contains 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
# Located at app/controllers/application_controller.rb | |
class ApplicationController < ActionController::API | |
before_action do | |
@token = Token.new(request.env['auth.token']) | |
end | |
def require_token! | |
error_json = {message: 'No token in HTTP_AUTHORIZATION header'} | |
render json: error_json, status: 401 unless @token.present? |
This file contains 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
import React from 'react' | |
import ReactCSSTransitionGroup from 'react-addons-css-transition-group' | |
import Drawer from 'drawer/components/drawer' | |
const DrawerSelector = (Display, Content) => React.createClass({ | |
propTypes: { | |
name: React.PropTypes.string.isRequired | |
}, |
This file contains 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
.container { | |
font-size: 0; | |
> * { | |
display: inline-block; | |
font-size: medium; | |
vertical-align: top; | |
width: 100%; | |
} |
This file contains 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
const updateLocation = (state, action) => { | |
return Object.assign({}, state, ...) | |
} | |
const actionHandlers = { | |
'UPDATE_LOCATION': updateLocation | |
} | |
const reducer = (state = initialState, action) => { | |
const handler = actionHandlers[action.type] |
This file contains 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
import { createStore, combineReducers } from 'redux' | |
import { reducer as education } from 'reducers/education' | |
import { reducer as skills } from 'reducers/skills' | |
const buildResumeBuilderStore = () => { | |
return createStore(combineReducers({ education, skills }) | |
} | |
document.addEventListener('DOMContentLoaded', () => { |
This file contains 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
const hashFunc = (str) => { | |
let hash = 0; | |
if (str.length === 0) return hash | |
for (let i = 0; i < str.length; i++) { | |
const char = str.charCodeAt(i) | |
hash = ((hash<<5)-hash)+char | |
hash = hash & hash | |
} | |
return hash | |
} |
This file contains 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
const compose = (...funcs) => { | |
if (funcs.length === 0) { | |
return (arg) => arg | |
} | |
if (funcs.length === 1) { | |
return funcs[0] | |
} | |
const last = funcs[funcs.length - 1] |
This file contains 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
const compose = (...funcs) => { | |
if (funcs.length === 0) { | |
return (arg) => arg | |
} | |
if (funcs.length === 1) { | |
return funcs[0] | |
} | |
} |