Skip to content

Instantly share code, notes, and snippets.

View Leonti's full-sized avatar

Leonti Bielski Leonti

View GitHub Profile
{"event":{"generic":{"message":"Ir sensor message"}},"time":1580108867703}
{"event":{"generic":{"message":"Gyro sensor message"}},"time":1580108867703}
{"event":{"lidar":{"scan_points":[{"angle_z_q14":59869,"dist_mm_q2":5992,"quality":188,"flag":1},{"angle_z_q14":49675,"dist_mm_q2":5976,"quality":188,"flag":0},{"angle_z_q14":40777,"dist_mm_q2":0,"quality":0,"flag":0},{"angle_z_q14":30583,"dist_mm_q2":0,"quality":0,"flag":0},{"angle_z_q14":19091,"dist_mm_q2":6368,"quality":188,"flag":0},{"angle_z_q14":8897,"dist_mm_q2":6400,"quality":188,"flag":0},{"angle_z_q14":64238,"dist_mm_q2":6100,"quality":188,"flag":0},{"angle_z_q14":54044,"dist_mm_q2":6212,"quality":188,"flag":0},{"angle_z_q14":43849,"dist_mm_q2":6388,"quality":188,"flag":0},{"angle_z_q14":33655,"dist_mm_q2":6324,"quality":188,"flag":0},{"angle_z_q14":23460,"dist_mm_q2":5916,"quality":188,"flag":0},{"angle_z_q14":13289,"dist_mm_q2":5856,"quality":188,"flag":0},{"angle_z_q14":3094,"dist_mm_q2":5896,"quality":188,"flag":0},{"angle_z_q14":59710,"dist_mm_q
@Leonti
Leonti / SchemaToCaseClass
Last active April 2, 2019 22:29
Generate case classes for Spark DataFrame from a schema
object SchemaToCaseClass {
import org.apache.spark.sql.types._
trait Field
case class FlatField(name: String, t: String, isNullable: Boolean) extends Field
case class CaseClass(name: String, fields: List[Field], isNullable: Boolean) extends Field
case class ArrayClass(name: String, field: Field, isNullable: Boolean) extends Field
case class PrintField(name: String, typeName: String, isOptional: Boolean)
case class PrintClass(name: String, fields: List[PrintField])
@Leonti
Leonti / CaseClassPrinting.scala
Created April 1, 2019 08:01
Print case classes from a nested structure
object Printing extends App {
trait Test {
val name: String
}
case class TestSingle(name: String, t: String, isOptional: Boolean) extends Test
case class NestedTest(name: String, fields: List[Test], isOptional: Boolean) extends Test
val testData = NestedTest("main", List(
@Leonti
Leonti / Fs2Zip.scala
Last active February 9, 2019 01:05
Attempt to write Stream[F, (String, Stream[F, Byte])] to zipped Stream[F, Byte]
package backup
import java.io.OutputStream
import cats.effect._
import cats.effect.implicits._
import cats.implicits._
import fs2.{Chunk, Pipe, Stream, io}
import java.util.zip.{ZipEntry, ZipOutputStream}
import fs2.concurrent.Queue
@Leonti
Leonti / main.rs
Created October 29, 2018 12:24
Can't move out of borrowed context
//! A chat server that broadcasts a message to all connections.
//!
//! This example is explicitly more verbose than it has to be. This is to
//! illustrate more concepts.
//!
//! A chat server for telnet clients. After a telnet client connects, the first
//! line should contain the client's name. After that, all lines sent by a
//! client are broadcasted to all other connected clients.
//!
//! Because the client is telnet, lines are delimited by "\r\n".
//! A chat server that broadcasts a message to all connections.
//!
//! This example is explicitly more verbose than it has to be. This is to
//! illustrate more concepts.
//!
//! A chat server for telnet clients. After a telnet client connects, the first
//! line should contain the client's name. After that, all lines sent by a
//! client are broadcasted to all other connected clients.
//!
//! Because the client is telnet, lines are delimited by "\r\n".
#![allow(unused)]
#[macro_use]
extern crate crossbeam_channel;
use crossbeam_channel as channel;
use std::io::Write;
use std::io;
use std::net::{TcpListener, TcpStream};
use std::thread;
use std::time;
@Leonti
Leonti / main.rs
Created October 19, 2018 02:38
Use of moved value
#![allow(unused)]
#[macro_use]
extern crate crossbeam_channel;
use crossbeam_channel as channel;
use std::io::Write;
use std::io;
use std::net::{TcpListener, TcpStream};
use std::thread;
#![allow(unused)]
use std::io::Write;
use std::io;
use std::net::{TcpListener, TcpStream};
use std::thread;
use std::time;
use std::sync::{Arc,RwLock};
// https://github.com/Nervengift/chat-server-example/blob/master/src/main.rs
haskell-lsp:Starting up server ...
2018-05-09 12:06:07.689664 [ThreadId 4] - ---> {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":36474,"rootPath":"/Users/leonti.bielski/myob/property-testing-demo/payslip-property-testing-haskell/","rootUri":"file:///Users/leonti.bielski/myob/property-testing-demo/payslip-property-testing-haskell/","capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true},"didChangeConfiguration":{"dynamicRegistration":false},"didChangeWatchedFiles":{"dynamicRegistration":false},"symbol":{"dynamicRegistration":false},"executeCommand":{"dynamicRegistration":false}},"textDocument":{"synchronization":{"dynamicRegistration":false,"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"dynamicRegistration":false,"completionItem":{"snippetSupport":true,"commitCharactersSupport":false},"contextSupport":true},"hover":{"dynamicRegistration":false},"signatureHelp":{"dynamicRegistration":false},"references":{"dynamicRegistration":false},"d