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
| var elements = document.getElementsByClassName('o-activity'); | |
| var elementsArr = []; | |
| for(var i = 0; i < elements.length; i++) | |
| { | |
| elementsArr.push(elements.item(i).text); | |
| } | |
| var uniqueCount = {}; | |
| elementsArr.forEach(function(i) { | |
| uniqueCount[i] = (uniqueCount[i]||0)+1; | |
| }); |
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
| import React, {PropTypes} from 'react'; | |
| export const Tab = (props) => { | |
| return ( | |
| <li className="tab"> | |
| <a className={`tab-link ${props.linkClassName} ${props.isActive ? 'active' : ''}`} | |
| onClick={(event) => { | |
| event.preventDefault(); | |
| props.onClick(props.tabIndex); | |
| }}> |
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 Karatsuba | |
| # Multiply two numbers using the Karatsuba | |
| # multiplication algorithm | |
| def multiply(num_1, num_2) | |
| if num_1 < 10 || num_2 < 10 | |
| return num_1 * num_2 | |
| end | |
| m_2 = [num_1.to_s.length, num_2.to_s.length].max/2 | |
| # Split the digit sequences about the middle | |
| high_1, low_1 = num_1.divmod(10**m_2) |
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 'minitest/autorun' | |
| require './karatsuba' | |
| describe Karatsuba do | |
| before do | |
| @karatsuba = Karatsuba.new | |
| end | |
| describe "#multiply" do | |
| it "should multiply small numbers of equal size" do |
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
| <Tabs> | |
| <Tab iconClassName={'icon-class-0'} linkClassName={'link-class-0'}> | |
| <p>content 0</p> | |
| </Tab> | |
| <Tab iconClassName={'icon-class-1'} linkClassName={'link-class-1'}> | |
| <CustomComponent propA={'foo'} propB={this.handleSomething}/> | |
| </Tab> | |
| </Tabs> |
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
| export class Tabs extends Component { | |
| constructor(props, context) { | |
| super(props, context); | |
| this.state = { | |
| activeTabIndex: this.props.defaultActiveTabIndex | |
| }; | |
| this.handleTabClick = this.handleTabClick.bind(this); | |
| } | |
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
| export const Tab = (props) => { | |
| return ( | |
| <li className="tab"> | |
| <a className={`tab-link ${props.linkClassName} ${props.isActive ? 'active' : ''}`} | |
| onClick={(event) => { | |
| event.preventDefault(); | |
| props.onClick(props.tabIndex); | |
| }}> | |
| <i className={`tab-icon ${props.iconClassName}`}/> | |
| </a> |
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 'minitest/autorun' | |
| require './merge_sort' | |
| describe MergeSort do | |
| before do | |
| @merge_sort = MergeSort.new | |
| end | |
| describe "#sort" do | |
| it "should sort an array of 1 element" do |
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 MergeSort | |
| # Sorts an array using the merge sort algorithm | |
| def sort(arr) | |
| length = arr.length | |
| if length > 1 | |
| mid = (length/2).floor | |
| return merge(sort(arr[0..(mid - 1)]), sort(arr[mid..length])) | |
| else | |
| return arr | |
| 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 Provider extends React.Component { | |
| getChildContext() { | |
| return {appData: this.props.appData}; | |
| } | |
| render() { | |
| return( | |
| <div> | |
| {this.props.children} | |
| </div> |