Skip to content

Instantly share code, notes, and snippets.

View wojciech-zurek's full-sized avatar
😎

Wojciech Żurek wojciech-zurek

😎
  • Rzeszów/Poland
View GitHub Profile
@wojciech-zurek
wojciech-zurek / color.go
Created April 24, 2020 10:04
Go lang and ANSI 256 colors
package main
import (
"fmt"
)
const Color = "\033[38;5;%dm%-4d\033[39;49m"
func main() {
for row := 0; row < 16; row++ {
@wojciech-zurek
wojciech-zurek / ArduinoAsciiConverter
Last active January 17, 2020 09:15
Arduino example demonstrates how to print ASCII values in decimal, hexadecimal, octal, and binary.
#include <Arduino.h>
int character = 0;
void setup()
{
Serial.begin(9600);
Serial.print("Echo start\r\n");
}
@wojciech-zurek
wojciech-zurek / ascii hex dec
Last active January 17, 2020 08:23
ASCII compact tables of character set
DEC:
30 40 50 60 70 80 90 100 110 120
----------------------------------
0: ( 2 < F P Z d n x
1: ) 3 = G Q [ e o y
2: * 4 > H R \ f p z
3: ! + 5 ? I S ] g q {
4: " , 6 @ J T ^ h r |
5: # - 7 A K U _ i s }
6: $ . 8 B L V ` j t ~
@wojciech-zurek
wojciech-zurek / EchoArduino
Created January 16, 2020 13:16
Serial I/O on Arduino + serial I/O on Linux
//Arduino:
#include <Arduino.h>
#define LF 0x0A
char buffer[11];
int idx = 0;
void setup()
{
Serial.begin(9600);
@wojciech-zurek
wojciech-zurek / CoroutineExampleApplication.kt
Last active April 2, 2020 05:29
kotlin coroutine plus spring functional endpoints and reactive repositories example
package eu.wojciechzurek.example
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.reactive.awaitFirstOrNull
import kotlinx.coroutines.runBlocking
import org.springframework.beans.factory.InitializingBean
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import org.springframework.context.annotation.Bean
import org.springframework.data.annotation.Id
@wojciech-zurek
wojciech-zurek / DelegatationPattern.kt
Created October 2, 2019 10:57
Example of Delegation with overriding in Kotlin
fun main() {
val car = Car("red", 200)
val derived = Derived(car)
println(derived.getColor())//red plus black
println(derived.getMaxSpeed())//200
}
interface Vehicle {
fun getColor(): String
fun getMaxSpeed(): Int
@wojciech-zurek
wojciech-zurek / DelegatedPropertiesExample.kt
Created October 2, 2019 10:03
Delegated Properties Example in Kotlin
import ExampleDelegates.accumulator
import ExampleDelegates.uppercase
import kotlin.properties.ReadWriteProperty
import kotlin.reflect.KProperty
fun main() {
val person = Person("ala1222", 12)
println(person.name)//ALA1222
println(person.balance) //12
@wojciech-zurek
wojciech-zurek / Main.kt
Created September 30, 2019 11:53
Simple conversion between meters and nautical miles and vice versa.
import kotlin.math.roundToInt
import kotlin.test.assertEquals
const val PI = 3.14
const val NAUTICAL_MILE_IN_METERS = 1852
const val MEAN_EARTH_RADIUS = 6371100
fun main(args: Array<String>): Unit {
assertEquals(NAUTICAL_MILE_IN_METERS, toMeters(1))
assertEquals(10 * NAUTICAL_MILE_IN_METERS, toMeters(10))
@wojciech-zurek
wojciech-zurek / build.gradle.kts
Created September 16, 2019 17:10
example of gradle, kotlin, shadow jar and application plugin
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
application
kotlin("jvm") version "1.3.50"
id("com.github.johnrengelman.shadow") version "5.1.0"
}
group = "eu.wojciechzurek"