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'; | |
const maxHeight = 200; | |
const height = 300; | |
const Styles = { | |
container: { | |
display: 'flex', | |
flexDirection: 'column', | |
border: 'solid 1px #f9c300', | |
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
// ---- index.js | |
import React, { NavigatorIOS, TabBarIOS } from 'react-native'; | |
import { styles } from './style'; | |
import { Reddit } from './reddit'; | |
export const redditnative = React.createClass({ | |
render() { | |
return ( | |
<NavigatorIOS style = {styles.navigatorios} |
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
package object enums { | |
trait Day extends Comparable[Day] { | |
def name(): String | |
def ordinal(): Int | |
override def compareTo(o: Day): Int = Integer.compare(this.ordinal(), o.ordinal()) | |
} | |
private[enums] class DayImpl(n: String, i: Int) extends Day { | |
def name(): String = 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
function Person(firstName: string, lastName: string, age: number) { | |
if (!this) return new Person(firstName, lastName, age); // if no new, then new to have type | |
return Object.freeze(Object.assign(this || {}, { // assign is use of enhance this, to have type | |
copy(obj) { | |
const values = { firstName, lastName, age, ...obj }; | |
return new Person(values.firstName, values.lastName, values.age); | |
}, | |
get firstName() { | |
return firstName; | |
}, |
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
var ws = new WebSocket('...'); | |
var timeout = setTimeout(function() { | |
console.log('fuuuuuuuu', ws.readyState); | |
ws.close(); | |
}, monSuperTimeout); | |
ws.onopen = function(event) { | |
clearTimeout(timeout); | |
... |
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'; | |
// creates an higher order component that can map parts of the context on subcomponent props | |
export default function enhance(mapper) { | |
return (Component) => { | |
return React.createClass({ | |
contextTypes: { | |
__providedContext: React.PropTypes.object, | |
}, | |
render() { |
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
function umd(name, api) { | |
if (typeof exports === "object" && typeof module !== "undefined") { | |
module.exports = api; | |
} else if (typeof define === "function" && define.amd) { | |
define([], function() { return api; }); | |
} else { | |
var globalScope; | |
if (typeof window !== "undefined") { | |
globalScope = window; | |
} else if (typeof global !== "undefined") { |
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 ReacDOM from 'react-dom'; | |
const Component = React.createClass({ | |
render() { | |
return ( | |
<h1>Hello World!</h1> | |
); | |
} | |
}); |
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
trait Document[T] {} | |
class JsonDocument extends Document[String] {} | |
class MyDocument extends Document[String] {} | |
def get[D <: Document[_]](id: String, timeout: Duration = Duration.Inf)(implicit classTag: ClassTag[D] = ClassTag(classOf[JsonDocument])): Option[D] = { | |
??? | |
} | |
val o: Option[JsonDocument] = get("key") | |
val o2: Option[MyDocument] = get[MyDocument]("key") |
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 Types = Object.freeze({ | |
Unit: Symbol('Unit') | |
}); | |
function uselessPromise() { | |
return new Promise(resolve => { | |
console.log('Doing stuff !!!'); | |
setTimeout(() => resolve(Types.Unit), 200) | |
}).then(res => { | |
if (res === Types.Unit && |