Skip to content

Instantly share code, notes, and snippets.

View milenkovicm's full-sized avatar

Marko Milenković milenkovicm

View GitHub Profile
@milenkovicm
milenkovicm / newstack-01-file-descriptors.c
Created February 26, 2021 16:50 — forked from PeterCorless/newstack-01-file-descriptors.c
newstack-io_uring-ebpf-examples
ssize_t read(int fd, void *buf, size_t count);
ssize_t write(int fd, const void *buf, size_t count);
@milenkovicm
milenkovicm / API.md
Created January 14, 2021 09:08 — forked from iros/API.md
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

@milenkovicm
milenkovicm / FlowControlSample.scala
Created May 10, 2018 13:42 — forked from patriknw/FlowControlSample.scala
Illustrates Actor message flow control with "work pulling pattern". This code is licensed under the Apache 2 license.
package flowcontrol
import scala.concurrent.duration._
import akka.actor.typed.ActorRef
import akka.actor.typed.ActorSystem
import akka.actor.typed.Behavior
import akka.actor.typed.scaladsl.Behaviors
/**

Keybase proof

I hereby claim:

  • I am milenkovicm on github.
  • I am milenkovicm (https://keybase.io/milenkovicm) on keybase.
  • I have a public key ASC4CdDn5SfSi5l8SKVKrPsz2AX9Qw2UbGDRT4rHxNdtdgo

To claim this, I am signing this object:

// Spawn your futures
val fs = (1 to 100).map { i =>
Future { Thread.sleep(i); i }
}
// Wrap all of the work up into a single
// Future
val f = Future.sequence(fs)
// Wait on it forever - i.e. until it's done

Advanced Functional Programming with Scala - Notes

Copyright © 2017 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x
@milenkovicm
milenkovicm / CdiExtension.java
Created May 31, 2012 12:04
Cdi Extension quick start
package com.example
import javax.enterprise.event.Observes;
import javax.enterprise.inject.spi.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class CdiExtension implements Extension {
@milenkovicm
milenkovicm / bean.xml
Created May 17, 2012 10:48
how to register infinispan CDI interceptor
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
<!-- Enable JCACHE interceptors -->
<interceptors>
<class>org.infinispan.cdi.interceptor.CacheResultInterceptor</class>
<class>org.infinispan.cdi.interceptor.CacheRemoveEntryInterceptor</class>
<class>org.infinispan.cdi.interceptor.CacheRemoveAllInterceptor</class>
@milenkovicm
milenkovicm / JBoss7TransactionManagerLookup.java
Created May 17, 2012 10:47
JBoss7 Transaction Manager Lookup
public class JBoss7TransactionManagerLookup implements TransactionManagerLookup {
public TransactionManager getTransactionManager() throws Exception {
InitialContext ic = new InitialContext();
TransactionManager tm = (TransactionManager) ic.lookup("java:jboss/TransactionManager");
if (tm == null) throw new IllegalStateException("Couldn't find the transaction mamager in JNDI");
return tm;
}
}
@milenkovicm
milenkovicm / LocateTM.java
Created May 14, 2012 08:30
TransactionManager locateTM
/** The Resource adapter can't depend on any provider's specific library. Because of that we use reflection to locate the
* transaction manager during startup.
*
*
* TODO: https://jira.jboss.org/browse/HORNETQ-417
* We should use a proper SPI instead of reflection
* We would need to define a proper SPI package for this.
* */
public static TransactionManager locateTM(final String locatorClass, final String locatorMethod)
{