Skip to content

Instantly share code, notes, and snippets.

View sjednac's full-sized avatar

Szymon Jednac sjednac

View GitHub Profile
@sjednac
sjednac / BusyApp.java
Last active May 11, 2021 07:03
JVM monitoring in a Docker environment
public final class BusyApp {
public static void main(String []args) throws Exception {
final java.util.Random generator = new java.util.Random();
while (true) {
generator.ints(1000000, 0, 100).sorted();
Thread.sleep(5000L);
}
}
}
@sjednac
sjednac / SbtAmazonEcr.scala
Last active July 4, 2021 07:12
Pushing Docker images to Amazon ECR using an SBT plugin
object SbtAmazonEcr extends App {
while(true) {
println("Hello Docker.")
Thread.sleep(3000)
}
}
@sjednac
sjednac / EmojiMeal.scala
Created October 4, 2016 06:43
Map, filter and foldLeft using an Emoji example in Scala
object EmojiMeal extends App {
type Ingredient = String
type Meal = String
type Person = String
type Poop = String
def cook(item: Ingredient): Meal = item match {
case "🐮" => "🍔"
case "🍠" => "🍟"
case "🐔" => "🍗"
@sjednac
sjednac / schema-versions.py
Created January 25, 2017 14:21
A Kafka consumer for listing available schema versions
#
# A Kafka consumer, that will print schema version information for
# all available subjects.
#
# Use the RESTful API to query SchemaRegistry directly. For example:
# curl http://schema-registry:8081/subjects/{subject}/versions
#
from kafka import KafkaConsumer
from random import randint
@sjednac
sjednac / build.sbt
Created September 14, 2017 08:11
Override a task setting in an SBT command
lazy val person = settingKey[String]("Person to greet")
lazy val hello = taskKey[Unit]("Greet person")
// https://stackoverflow.com/q/14262798/1535738
def greetEveryone = Command.command("greetEveryone") { state =>
Seq("John", "Alice", "Bob").foreach { name =>
val extracted = Project extract state
val newState = extracted.append(Seq(person := name), state)
Project.extract(newState).runTask(hello, newState)
@sjednac
sjednac / KNN.cs
Last active August 8, 2019 13:21
K-nearest neighbours in C# (k-NN classification)
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
namespace knn
{
class MainClass
{
public struct Record
@sjednac
sjednac / CheckboxInNavDropdown.js
Created April 16, 2018 16:36
Workaround for event propagation issue in NavDropdown (react-bootstrap)
import React from 'react'
import {
Navbar,
Nav,
NavDropdown,
MenuItem,
Checkbox
} from 'react-bootstrap'
class CheckboxInNavDropdown extends React.Component {
@sjednac
sjednac / FillMissingValues1.scala
Last active June 4, 2018 15:22
Fill missing value with the latest known element
import Double.NaN
object FillMissingValues1 extends App {
val data = List(1.0, NaN, 2.0, NaN, NaN, 3.0, 4.0, NaN, 5.0, NaN)
val res = data.scanLeft(0.0)( (current, item) => if (item.isNaN) current else item)
println(res)
}
@sjednac
sjednac / DelayedList.js
Created July 3, 2018 12:21
A React component which renders it's children sequentially with a fixed period (PoC)
import React from 'react'
import PropTypes from 'prop-types'
import {
isEqual,
includes
} from 'lodash'
class DelayedList extends React.Component {
constructor(props) {
@sjednac
sjednac / README.md
Created August 13, 2018 15:15
Submit a Spark job to an existing Amazon EMR cluster

Submit a Spark job to an existing Amazon EMR cluster

Creates a step in Amazon EMR for a given cluster_id and monitors it's progress using a sensor. A more complex example, that involves cluster creation/termination can be found here.