Skip to content

Instantly share code, notes, and snippets.

marko asplund marko-asplund

Block or report user

Report or block marko-asplund

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@marko-asplund
marko-asplund / Fs2SampleCode.scala
Created Aug 1, 2019
fs2 example code from underscore ported to fs2 v1.0.5 and cats-effect 1.4.0
View Fs2SampleCode.scala
import cats.implicits._
import cats.effect.{ConcurrentEffect, Effect, ExitCode, IO, IOApp, Timer}
import fs2._
import fs2.concurrent.Queue
import scala.concurrent.duration._
import scala.concurrent.duration.MILLISECONDS
//
// fs2 example code from
// https://underscore.io/blog/posts/2018/03/20/fs2.html
@marko-asplund
marko-asplund / AeadHelper.scala
Created Nov 27, 2018
Implement AEAD with AES + GCM
View AeadHelper.scala
package com.practicingtechie
// implement AEAD with AES + GCM
object AeadHelper {
import javax.crypto._
import javax.crypto.spec.{GCMParameterSpec, SecretKeySpec}
import java.security._
import java.util.Base64
val AesKeySize = 256
View FutureLift.scala
/*
adapted from:
https://github.com/monix/monix/blob/4f1862c4bcad7d111aa8cf64510c2fc5dcee6b77/monix-catnap/shared/src/main/scala/monix/catnap/FutureLift.scala
Monix dependency removed.
*/
package async {
import cats.effect.Async
import scala.concurrent.Future
import scala.language.higherKinds
View FutureTranslation.scala
package object effect {
import cats.effect.IO
import scala.concurrent.Future
import language.implicitConversions
import language.higherKinds
import scala.util.{Success, Failure}
import scala.concurrent.Promise
import cats.effect.Effect
@marko-asplund
marko-asplund / circe-subtyping.scala
Last active Sep 23, 2018
Subtype codecs with Circe
View circe-subtyping.scala
// ========== approach 1 ==========
sealed abstract class FooBase {
def subType: String = this.getClass.getSimpleName
}
case class Foo(a: Int, b: String) extends FooBase
case class Bar(c: Float, d: Int) extends FooBase
val fooName = getClassName(Foo.getClass)
val barName = getClassName(Bar.getClass)
View tf-keras-model.py
import numpy as np
import tensorflow as tf
from tensorflow import keras
from keras.models import Sequential
import h5py
from keras.utils.io_utils import HDF5Matrix
data_dir = '...'
train_fn = data_dir + '/dataset_train.h5'
test_fn = data_dir + '/dataset_test.h5'
@marko-asplund
marko-asplund / ArtemisClient.scala
Created Aug 23, 2017
Produce & consume messages using Apache Artemis v2.2.0 core API
View ArtemisClient.scala
package com.practicingtechie
import org.apache.activemq.artemis.api.core.TransportConfiguration
import org.apache.activemq.artemis.api.core.SimpleString
import org.apache.activemq.artemis.api.core.client.{ActiveMQClient, ClientMessage, MessageHandler}
import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants._
import scala.collection.JavaConversions._
// produce & consume messages using Apache Artemis v2.2.0 core API
object ArtemisClient {
@marko-asplund
marko-asplund / d3v4-labeled-force-layout.html
Last active Jul 12, 2017
d3v4 force layout with labels
View d3v4-labeled-force-layout.html
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.link {
stroke: #aaa;
}
.node {
pointer-events: all;
@marko-asplund
marko-asplund / Extending LVM based filesystem
Last active Nov 23, 2016
Extending LVM based filesystem
View Extending LVM based filesystem
# initialize physical device to be used as a physical volume with LVM
# (below we assume the newly added block device was "/dev/sdb")
pvcreate /dev/sdb
# add physical volume to volume group
vgextend ubuntu-vg /dev/sdb
# extend logical volume and file system
lvextend -r /dev/ubuntu-vg/root /dev/sdb
View issue_certificate.sh
#!/bin/bash
#
# requires CA.pl from OpenSSL: https://github.com/openssl/openssl/blob/master/apps/CA.pl.in
#
# generating CA.pl from OpenSSL source:
# /usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
# "-oMakefile" apps/CA.pl.in > "apps/CA.pl"
# sudo cp apps/CA.pl /usr/local/bin
#
You can’t perform that action at this time.