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
// requires | |
var fs = require ('fs'); | |
var prompt = require('prompt'); | |
var erisC = require('eris-contracts'); | |
var conv = require('binstring'); | |
// NOTE. On Windows/OSX do not use localhost. find the | |
// url of your chain with: | |
// docer-machine ls | |
// and find the docker machine name you are using (usually default or eris). |
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
val newspaper = List("a1", "a2", "b11", "a2", "aa", "a2", "aa", "a2", "aa") | |
val note = List("a1", "a2", "b11", "a2", "aa") | |
val mw = for { // using for comprehension | |
n <- newspaper | |
r <- note | |
if r == n | |
} yield r -> 1 // mapped words - getting a List[(String, Int)] | |
val mw2 = newspaper.flatMap(n => |
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
# recursive sum | |
### Haskell | |
mysum [] = 0 | |
mysum (x:xs) = x + mysum xs | |
Usage: | |
mysum [1..10] // 55 | |
### Scala |
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
myqs [] = [] | |
myqs (x:xs) = myqs lessthan ++ [x] ++ myqs greaterthan | |
where | |
lessthan = [a | a <- xs, a <= x ] | |
greaterthan = [b | b <- xs, b > x] | |
### Scala implementation | |
def mysq (l : List[Int]) : List[Int] = | |
l match { |
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
//Greeting.js | |
import React from 'react'; | |
// use export to let other files access this component | |
export class Greeting extends React.Component { | |
render() { | |
return <h1>Hi there, {this.props.name}!</h1>; | |
} | |
} | |
// App.js |
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 ReactDOM from 'react-dom'; | |
class Button extends React.Component { | |
render() { | |
return ( | |
<button> | |
{this.props.text} | |
</button> | |
); |
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 ReactDOM from 'react-dom'; | |
const green = '#39D1B4'; | |
const yellow = '#FFD712'; | |
class Toggle extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { color: green }; |
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
// | |
// Child.jsx | |
// | |
import React from 'react'; | |
export class Child extends React.Component { | |
constructor(props) { | |
super(props); | |
this.handleChange = this.handleChange.bind(this); | |
} |
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
// AKA React Patterns | |
// A stateful component class defines a function that calls this.setState. (Parent, lines 15-19) | |
//The stateful component passes that function down to a stateless component. (Parent, line 24) | |
// That stateless component class defines a function that calls the passed-down function, and that can take an event object as an argument. (Child, lines 10-13) | |
// The stateless component class uses this new function as an event handler. (Child, line 20) | |
// When an event is detected, the parent's state updates. (A user selects a new dropdown menu item) | |
//The stateful component class passes down its state, distinct from the ability to change its state, to a different stateless component. (Parent, line 25) | |
//That stateless component class receives the state and displays it. (Sibling, lines 5-10) | |
//An instance of the stateful component class is rendered. One stateless child component displays the state, and a different stateless child component displays a way to change the (Parent, lines 23-26) |
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
Verifying that "stefanop.id" is my Blockstack ID. https://onename.com/stefanop |
OlderNewer