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
class Foo: NSObject{ func foo() -> String{return "foo"}} | |
class Bar {func bar() -> String{return "bar"}} | |
let b: AnyObject = Bar() | |
//fail b.bar() | |
let f: AnyObject = Foo() | |
f.foo() //it works! |
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
### Keybase proof | |
I hereby claim: | |
* I am uberto on github. | |
* I am ramtop (https://keybase.io/ramtop) on keybase. | |
* I have a public key ASCOtE1ezv_CxcrGjuvY-_rrNCzrddbsNzrwPPFho6dORQo | |
To claim this, I am signing this object: |
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 org.aeonbits.owner.Config; | |
import org.aeonbits.owner.Config.Sources; | |
import java.util.List; | |
/** | |
* Keeps the configuration values for the server | |
*/ | |
@Sources({ "file:config.properties" }) | |
public interface ServerConfig extends Config { |
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 static void main(String[] args){ | |
ServerConfig config = ConfigFactory.create(ServerConfig.class); | |
List<Calculation> routes = Calculations.getAllCalculations(config.users()); | |
WebServer.start(config.port(), routes); | |
} |
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
Python | |
def remove_string(self, string): | |
for point in string.stones: | |
# Removing a string can create liberties for other strings. | |
for neighbor in self.neighbor_table[point]: | |
neighbor_string = self._grid.get(neighbor) | |
if neighbor_string is None: | |
continue | |
if neighbor_string is not string: |
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
fun placeStone(player: Player, point: Point) { | |
assert(isOnTheGrid(point)) | |
assert(isFree(point)) | |
//0. Examine the adjacent points. | |
val adjacentSameColor = mutableSetOf<GoString>() | |
val adjacentOppositeColor = mutableSetOf<GoString>() | |
val liberties = mutableSetOf<Point>() | |
for (neighbor in point.neighbors()) { |
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
def place_stone(self, player, point): | |
assert self.is_on_grid(point) | |
assert self._grid.get(point) is None | |
adjacent_same_color = [] | |
adjacent_opposite_color = [] | |
liberties = [] | |
# First, we examine direct neighbors of this point. | |
for neighbor in point.neighbors(): | |
if not self.is_on_grid(neighbor): |
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 com.gamasoft.memoryReferences; | |
import java.util.Observable; | |
public class Factory { | |
public Runnable createRunnable() { | |
return new Runnable() { | |
@Override |
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 com.gamasoft.delegation | |
import assertk.assert | |
import assertk.assertions.isEqualTo | |
import org.junit.Test | |
//https://kotlinlang.org/docs/reference/delegation.html | |
interface Printer { | |
fun print(msg: String) |
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 java.lang.Math.round as jround | |
import kotlin.math.round | |
fun main() { | |
val r = round(4.5) + round(9.5) | |
println("kotlin round 4.5+9.5 $r") | |
val r2 = round(5.5) + round(9.5) |
OlderNewer