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
[ | |
{ | |
"code": "EUR", | |
"symbol_native": "€", | |
"name": "Euro" | |
}, | |
{ | |
"code": "AED", | |
"symbol_native": "د.إ", | |
"name": "United Arab Emirates Dirham" |
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 main | |
import utils.oldFor | |
fun main(args: Array<String>) { | |
var n = 12 | |
oldFor({ 0 }, { it < n }, { it + 1 }) { | |
println(it) | |
n /= 2 | |
} |
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 utils | |
fun oldFor( | |
initialSetter: () -> Int, | |
limitingCondition: (Int) -> Boolean, | |
updater: (Int) -> Int, | |
codeBlock: (Int) -> Unit) { | |
var i = initialSetter() | |
while (limitingCondition(i)) { | |
codeBlock(i) |
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 | |
class FrequencyMap<K, Int>( | |
private val b: MutableMap<K, kotlin.Int>, | |
private val c: Map<K, kotlin.Int>) | |
: MutableMap<K, kotlin.Int> by b, Map<K, kotlin.Int> by c { | |
// Do something with b an c | |
} |
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 main | |
import utils.FrequencyMap | |
fun main(args: Array<String>) { | |
val mutableMapOne = mutableMapOf<Int, Int>() | |
val freqMapOne = FrequencyMap<Int, Int>(mutableMapOne) | |
freqMapOne.add(1, 3) | |
freqMapOne.add(1, 2) | |
freqMapOne.add(Pair(2, 2)) |
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 utils | |
class FrequencyMap<K, Int>(private val b: MutableMap<K, kotlin.Int>) | |
: MutableMap<K, kotlin.Int> by b { | |
fun add(key: K, freq: kotlin.Int = 1) { | |
b.computeIfPresent(key) { _, b -> b + freq } | |
b.putIfAbsent(key, freq) | |
} |
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
FROM php:7.0-apache | |
RUN apt update && \ | |
apt install -y wget && \ | |
cd /tmp && \ | |
wget https://www.dotdeb.org/dotdeb.gpg && \ | |
apt-key add dotdeb.gpg && \ | |
rm dotdeb.gpg && \ | |
echo "deb http://packages.dotdeb.org jessie all" >> /etc/apt/sources.list && \ | |
apt update && \ | |
apt install -y php7.0-mysql php7.0-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
// no error handling | |
// code not checked to be working - just to illustrate how to do it | |
const crypto = require("crypto"); | |
const mkdirp = require("mkdirp-promise"); | |
const io = require("socket.io")(); | |
const fs = require("fs"); | |
const Docker = require("dockerode"); | |
const byline = require("byline"); | |
const StringDecoder = require("string_decoder").StringDecoder; |
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, { PureComponent } from 'react'; | |
export default class SecondChild extends PureComponent { | |
render() { | |
console.log("Rendering!"); | |
return ( | |
<div> | |
{this.props.text} | |
</div> | |
); |
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, { Component } from 'react'; | |
import FirstChild from './FirstChild'; | |
import SecondChild from './SecondChild'; | |
export default class Parent extends Component { | |
constructor(props, context) { | |
super(props, context); | |
this.state = { | |
text: Math.random() | |
}; |
NewerOlder