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 * 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; |
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, { 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 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 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 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 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
#!/bin/sh | |
wget -O xml/top_albums.xml http://itunes.apple.com/tw/rss/topalbums/limit=300/explicit=true/xml | |
wget -O xml/new_releases.xml http://itunes.apple.com/WebObjects/MZStore.woa/wpa/MRSS/newreleases/sf=143470/limit=300/rss.xml | |
wget -O xml/just_added.xml http://itunes.apple.com/WebObjects/MZStore.woa/wpa/MRSS/justadded/sf=143470/limit=300/rss.xml | |
wget -O xml/featured_albums.xml http://itunes.apple.com/WebObjects/MZStore.woa/wpa/MRSS/featuredalbums/sf=143470/limit=300/rss.xml |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> | |
<title>Keyboard</title> | |
<style type="text/css"> | |
#keyboard { | |
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(0%, #9199A4), color-stop(50%, #7D8591), color-stop(100%, #535C69)); | |
border-radius: 10px; | |
background-color: #9199A4; |
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
old_gem = "gem" | |
new_gem = "/opt/ruby-enterprise/bin/gem" | |
oldgems = `#{old_gem} list` | |
# oldgems.each block written by spiceee. | |
# http://snippets.dzone.com/posts/show/6372 | |
oldgems.each do |line| | |
newgems = `#{new_gem} list` | |
matches = line.match(/([A-Z].+) \(([0-9\., ]+)\)/i) | |
if matches |
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
/* ../public_src/BookChooserController.j */ | |
"封面" = "封面" | |
"標題" = "標題" | |
"修改時間" = "修改時間" | |
"繼續編輯" = "繼續編輯" | |
"取消" = "取消" | |
"選擇書本" = "選擇書本" | |
"載入中..." = "載入中..." |
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
rvm install 1.9.1 # 不要用 1.9.2,會有很多問題 :P | |
wget http://sourceforge.net/projects/rubycocoa/files/RubyCocoa/1.0.1/RubyCocoa-1.0.1.tar.gz/download | |
tar zxvf RubyCocoa-1.0.1.tar.gz | |
cd RubyCocoa-1.0.1 | |
ruby install.rb config | |
ruby install.rb setup | |
sudo ruby install.rb install # 會安裝像 Xcode Template 等東西,需要 root 權限 |
NewerOlder