Skip to content

Instantly share code, notes, and snippets.

View asm0dey's full-sized avatar

Pasha Finkelshteyn asm0dey

View GitHub Profile
@JvmField
val ENCODERS = mapOf<KClass<out Any>, Encoder<out Any>>(
Boolean::class to Encoders.BOOLEAN(),
Byte::class to Encoders.BYTE(),
Short::class to Encoders.SHORT(),
Int::class to Encoders.INT(),
Long::class to Encoders.LONG(),
Float::class to Encoders.FLOAT(),
Double::class to Encoders.DOUBLE(),
String::class to Encoders.STRING(),
import os
from time import sleep
import skein
from skein.model import ApplicationState
mem_sz_gb = os.environ["LMD_PO_MEM_SIZE_GB"]
cores_number = os.environ["LMD_PO_NUM_CORES"]
spec = skein.ApplicationSpec(
@asm0dey
asm0dey / DBAuthKTest.kt
Created December 6, 2019 05:18
Tests for Kotlintest demo
package org.ort.school.app.service
import com.winterbe.expekt.should
import io.kotlintest.shouldThrow
import io.kotlintest.specs.ShouldSpec
import io.mockk.every
import io.mockk.mockk
import org.ort.school.app.repo.UserRepo
import org.pac4j.core.credentials.UsernamePasswordCredentials
import org.pac4j.core.exception.CredentialsException
@asm0dey
asm0dey / main.rs
Last active January 4, 2020 18:57
use core::fmt;
use std::fmt::{Error, Formatter};
use std::option::Iter;
use crate::DeltaType::{CHANGE, DELETE, INSERT};
fn main() {
for x in create_patch("abc", "def") {
println!("{}", x.to_string())
}
<!DOCTYPE html><html lang="en-US"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,height=device-height,initial-scale=1.0"><meta name="apple-mobile-web-app-capable" content="yes"><meta http-equiv="X-UA-Compatible" content="ie=edge"><meta property="og:type" content="website"><meta name="twitter:card" content="summary"><style>.bespoke-marp-note,.bespoke-marp-osc,.bespoke-progress-parent{display:none;-webkit-transition:none;transition:none}@media screen{body[data-bespoke-view=""] .bespoke-marp-parent>.bespoke-marp-osc>button,body[data-bespoke-view=next] .bespoke-marp-parent>.bespoke-marp-osc>button,body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-info-container button{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:transparent;border:0;color:inherit;cursor:pointer;font-size:inherit;opacity:.8;outline:none;padding:0;-webkit-transition:opacity .2s linear;transition:opacity .2s linear;-webkit-tap-highlight-color:tr
<!DOCTYPE html><html lang="en-US"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,height=device-height,initial-scale=1.0"><meta name="apple-mobile-web-app-capable" content="yes"><meta http-equiv="X-UA-Compatible" content="ie=edge"><meta property="og:type" content="website"><meta name="twitter:card" content="summary"><style>.bespoke-marp-note,.bespoke-marp-osc,.bespoke-progress-parent{display:none;-webkit-transition:none;transition:none}@media screen{body[data-bespoke-view=""] .bespoke-marp-parent>.bespoke-marp-osc>button,body[data-bespoke-view=next] .bespoke-marp-parent>.bespoke-marp-osc>button,body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-info-container button{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:transparent;border:0;color:inherit;cursor:pointer;font-size:inherit;opacity:.8;outline:none;padding:0;-webkit-transition:opacity .2s linear;transition:opacity .2s linear;-webkit-tap-highlight-color:tr
/**
* Returns an expression that can be used to deserialize a Spark SQL representation to an object
* of java bean `T` with a compatible schema. The Spark SQL representation is located at ordinal
* 0 of a row, i.e., `GetColumnByOrdinal(0, _)`. Nested classes will have their fields accessed
* using `UnresolvedExtractValue`.
*/
def deserializerForDataType(beanClass: Class[_], dt: KDataTypeWrapper): Expression = {
val typeToken = TypeToken.of(beanClass)
val walkedTypePath = new WalkedTypePath().recordRoot(beanClass.getCanonicalName)
val (dataType, nullable) = inferDataType(typeToken)
@asm0dey
asm0dey / Main.kt
Created March 30, 2020 09:47
Reading ORC data not from files, but from input streams
import org.apache.orc.CompressionKind
import org.apache.orc.OrcProto
import org.apache.orc.OrcProto.*
import org.apache.orc.OrcUtils
import org.apache.orc.impl.BufferChunk
import org.apache.orc.impl.InStream
import org.apache.orc.impl.InStream.StreamOptions
import org.apache.orc.impl.OrcCodecPool
import java.io.FileInputStream
import java.io.InputStream
@asm0dey
asm0dey / Arity.kt
Last active April 3, 2020 21:14
Variable arity data classes for Kotlin
fun <A> c(a: A) = Arity1(a)
fun <A, B> c(a: A, b: B) = Arity2(a, b)
fun <A, B, C> c(a: A, b: B, c: C) = Arity3(a, b, c)
fun <A, B, C, D> c(a: A, b: B, c: C, d: D) = Arity4(a, b, c, d)
fun <A, B, C, D, E> c(a: A, b: B, c: C, d: D, e: E) = Arity5(a, b, c, d, e)
fun <A, B, C, D, E, F> c(a: A, b: B, c: C, d: D, e: E, f: F) = Arity6(a, b, c, d, e, f)
fun <A, B, C, D, E, F, G> c(a: A, b: B, c: C, d: D, e: E, f: F, g: G) = Arity7(a, b, c, d, e, f, g)
fun <A, B, C, D, E, F, G, H> c(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H) = Arity8(a, b, c, d, e, f, g, h)
fun <A, B, C, D, E, F, G, H, I> c(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I) = Arity9(a, b, c, d, e, f, g, h, i)
fun <A, B, C, D, E, F, G, H, I, J> c(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j: J) = Arity10(a, b, c, d, e, f, g, h, i, j)
This file has been truncated, but you can view the full file.
[2020-04-22 14:59:11] NeoMutt-20200417 debugging at level 6
[2020-04-22 14:59:11]<M> log_file_open() Debugging at level 6 to file '/home/finkel/.neomuttdebug0'
WARNING:
Logging at this level can reveal personal information.
Review the log carefully before posting in bug reports.
[2020-04-22 14:59:11]<2> mutt_window_reflow() entering
[2020-04-22 14:59:11]<3> mutt_path_tidy_dotdot() Collapse path: /tmp/finkel
[2020-04-22 14:59:11]<3> mutt_path_tidy_dotdot() Collapsed to: /tmp/finkel