Skip to content

Instantly share code, notes, and snippets.

View sjednac's full-sized avatar

Szymon Jednac sjednac

View GitHub Profile
@sjednac
sjednac / react-ts.code-snippets
Last active December 9, 2022 16:25
React/Typescript snippets for Visual Studio Code
{
// Place your frlncr workspace snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
// Placeholders with the same ids are connected.
// Example:
"Component Typescript": {
"scope": "typescript,typescriptreact",
@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.

@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 / 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 / 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 / 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 / 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 / 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 / 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 / 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)
}
}