Skip to content

Instantly share code, notes, and snippets.

View uberto's full-sized avatar

Uberto Barbini uberto

View GitHub Profile

Keybase proof

I hereby claim:

  • I am uberto on github.
  • I am ramtop (https://keybase.io/ramtop) on keybase.
  • I have a public key ASCJlFfUeGLy4B_A_nG22PQVS_HGmwdlFftKuJCycbZAmgo

To claim this, I am signing this object:

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)
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)
@uberto
uberto / delegation.kt
Created May 12, 2018 19:38
Multiple Inheritance via Delegation in Kotlin
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)
@uberto
uberto / Factory.java
Created December 2, 2018 21:59
Create and export anonymous classes
package com.gamasoft.memoryReferences;
import java.util.Observable;
public class Factory {
public Runnable createRunnable() {
return new Runnable() {
@Override
@uberto
uberto / board.py
Created March 28, 2018 19:27
python go
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):
@uberto
uberto / Board.kt
Created March 28, 2018 19:16
kotlin go
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()) {
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:
@uberto
uberto / Main.java
Created August 13, 2017 16:37
Use of Owner property
public static void main(String[] args){
ServerConfig config = ConfigFactory.create(ServerConfig.class);
List<Calculation> routes = Calculations.getAllCalculations(config.users());
WebServer.start(config.port(), routes);
}
@uberto
uberto / ServerConfig.java
Created August 13, 2017 16:35
Owner configuration interface
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 {