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
| /* render a tweet using entities: for example | |
| * val e = Entity(10, 21, """<a href="https://twitter.com/search/?q=%23ScalaIntro">#ScalaIntro</a>""") | |
| * val entitites = Set(e) | |
| * render("I love my #ScalaIntro exercises!", entities) | |
| * should result in | |
| * """I love my <a href="https://twitter.com/search/?q=%23ScalaIntro">#ScalaIntro</a> exercises!""" | |
| * The "start" and "end" fields of an Entity refer to the indices in the | |
| * original string to be substituted with the html field; you may assume | |
| * that these indices are all non-overlapping. | |
| */ |
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
| // 2.1 Implement buildCar in parallel (orders in parallel) | |
| def buildCarPar(): Future[Car] = Future.join( | |
| Factory.newChassis(), | |
| Factory.newWheels(), | |
| Future.join( | |
| Factory.newCylinder(), | |
| Factory.newPiston() | |
| ) flatMap { case (cylinder, piston) => buildEngine(cylinder, piston) } | |
| ) map { case (chassis, wheels, engine) => Car(chassis, wheels, engine) } |
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
| steps = 5 | |
| (1..steps) | |
| .map { |x| (1..steps-1).map { |y| [x, y] } } | |
| .flatten(1) | |
| .select { |x, y| steps - x - y > 0 } | |
| .group_by { |x, y| x } | |
| .each do |x, sets| | |
| sets.each do |x, y| | |
| puts [x, y].inspect |
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'; | |
| import ReactDOM from 'react-dom'; | |
| import d3 from 'd3'; | |
| import styles from './styles.css'; | |
| function getDefaultRange(axis, props) { | |
| switch (axis) { | |
| case 'x': | |
| return [0, props.width]; |
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 * as React from "react"; | |
| import { useContext, useEffect, useState } from "react"; | |
| import { render } from "react-dom"; | |
| import { applyMiddleware, bindActionCreators, createStore } from "redux"; | |
| import ReduxThunk from "redux-thunk"; | |
| import { createSelector, createStructuredSelector } from "reselect"; | |
| import { action, getType } from "typesafe-actions"; | |
| interface Post { | |
| id: number; |
OlderNewer