Skip to content

Instantly share code, notes, and snippets.

View tomaszpolanski's full-sized avatar
πŸ’­
Fluttering

Tomek PolaΕ„ski tomaszpolanski

πŸ’­
Fluttering
View GitHub Profile
@tomaszpolanski
tomaszpolanski / None.java
Last active August 29, 2015 14:14
Implementation of optionan value from functional languages
package com.tomaszpolanski.androidsandbox.utils.option;
import com.android.internal.util.Predicate;
import rx.functions.Action0;
import rx.functions.Action1;
import rx.functions.Func0;
import rx.functions.Func1;
public final class None<A> extends Option<A> {
package com.tomaszpolanski.androidsandbox.models;
import com.tomaszpolanski.androidsandbox.utils.option.Option;
public class Person {
public final String Name;
private Person(String name) {
Name = name;
@tomaszpolanski
tomaszpolanski / GeoCoordinate.java
Last active August 29, 2015 14:14
Simple declarative implementation of geocoordinate
package com.tomaszpolanski.androidsandbox.models;
import com.tomaszpolanski.androidsandbox.utils.MathUtils;
import com.tomaszpolanski.androidsandbox.utils.option.Option;
import com.tomaszpolanski.androidsandbox.utils.result.Result;
import com.tomaszpolanski.androidsandbox.utils.result.ResultTuple;
import java.text.DecimalFormat;
import java.text.NumberFormat;
module Basics =
let xValue = 2
let yValue = xValue + 3
let add x y = x + y
let additionResult = add 2 3
let addTwo arg = add arg 2
addTwo 10
let getTwo() = 2
@tomaszpolanski
tomaszpolanski / Option.cs
Last active August 29, 2015 14:23
Implementation of optional for C#
using System;
using System.Collections.Generic;
using System.Linq;
namespace Common
{
public abstract class Option<T>
{
public static readonly None<T> None = new None<T>();
@tomaszpolanski
tomaszpolanski / DataStreamNotification.java
Last active October 6, 2016 17:27
Reark refactoring example
public final class DataStreamNotification<T> {
private enum Type {
FETCHING_START,
FETCHING_COMPLETED,
FETCHING_ERROR,
ON_NEXT
}
@NonNull
// Tool to nicely validate your regex: http://www.regexpal.com/
// Empty java regex
//g
// Single letter
/T/g
// Testing
/T/g.test('T')
# Other presentation file
@tomaszpolanski
tomaszpolanski / Comparison.txt
Last active August 12, 2024 07:35
Kotlin Standard comparison
╔══════════╦═════════════════╦═══════════════╦═══════════════╗
β•‘ Function β•‘ Receiver (this) β•‘ Argument (it) β•‘ Result β•‘
╠══════════╬═════════════════╬═══════════════╬═══════════════╣
β•‘ let β•‘ this@MyClass β•‘ String("...") β•‘ Int(42) β•‘
β•‘ run β•‘ String("...") β•‘ N\A β•‘ Int(42) β•‘
β•‘ run* β•‘ this@MyClass β•‘ N\A β•‘ Int(42) β•‘
β•‘ with* β•‘ String("...") β•‘ N\A β•‘ Int(42) β•‘
β•‘ apply β•‘ String("...") β•‘ N\A β•‘ String("...") β•‘
β•‘ also β•‘ this@MyClass β•‘ String("...") β•‘ String("...") β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•©β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•©β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•©β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
@tomaszpolanski
tomaszpolanski / GistComparison.txt
Last active June 2, 2017 12:16
Gist of comparison
╔══════════╦═════════════════╦═══════════════╦═══════════════╗
β•‘ Function β•‘ Receiver (this) β•‘ Argument (it) β•‘ Result β•‘
╠══════════╬═════════════════╬═══════════════╬═══════════════╣
β•‘ let β•‘ this@MyClass β•‘ String("...") β•‘ Int(42) β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•©β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•©β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•©β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•