Skip to content

Instantly share code, notes, and snippets.

View Astrac's full-sized avatar

Aldo Stracquadanio Astrac

View GitHub Profile
object DeriveFamily {
def minimal: Any = macro DeriveFamilyMacros.minimal
}
object DeriveFamilyMacros {
class body(tree: Any) extends StaticAnnotation
def bodyImpl(c: Context) = {
import c.universe._
import shapeless._
import shapeless.ops.coproduct.Inject
import shapeless.ops.record.Selector
trait Distinct[U <: Coproduct] extends DepFn1[U] {
type Out <: Coproduct
}
trait DistinctLowPriority {
implicit def take[U <: Coproduct, X](implicit rest: Distinct[U]): Distinct.Aux[X :+: U, X :+: rest.Out] =
@Astrac
Astrac / hot_threads
Created January 4, 2017 09:46
ES heap issue - hot threads
::: {Lunatik}{Y0JLJZ79TJWte1v8UcDeuw}{172.31.31.81}{172.31.31.81:9300}
Hot threads at 2017-01-04T08:52:28.643Z, interval=500ms, busiestThreads=3, ignoreIdleThreads=true:
::: {Ursa Major}{cFtE1408RBStaL2cnRE8eA}{172.31.19.204}{172.31.19.204:9300}
Hot threads at 2017-01-04T08:52:28.627Z, interval=500ms, busiestThreads=3, ignoreIdleThreads=true:
::: {Maxam}{KXphMUJITqu2J33NAWSsHA}{172.31.37.191}{172.31.37.191:9300}
Hot threads at 2017-01-04T08:52:28.626Z, interval=500ms, busiestThreads=3, ignoreIdleThreads=true:
::: {Gorilla Girl}{rAwO6sHyTta_0yFsCbHC3w}{172.31.19.202}{172.31.19.202:9300}
@Astrac
Astrac / nodes.json
Created January 4, 2017 09:45
ES heap issue - nodes
{
"cluster_name":"prod-elasticsearch",
"nodes":{
"Y0JLJZ79TJWte1v8UcDeuw":{
"name":"Lunatik",
"transport_address":"172.31.31.81:9300",
"host":"172.31.31.81",
"ip":"172.31.31.81",
"version":"2.4.1",
"build":"c67dc32",
@Astrac
Astrac / node_stats.json
Created January 4, 2017 09:43
ES heap issue - node stats
{
"cluster_name":"prod-elasticsearch",
"nodes":{
"Y0JLJZ79TJWte1v8UcDeuw":{
"timestamp":1483519938561,
"name":"Lunatik",
"transport_address":"172.31.31.81:9300",
"host":"172.31.31.81",
"ip":[
"172.31.31.81:9300",
@Astrac
Astrac / mk4.scala
Created November 25, 2015 11:09
A generic, typeclass-driven mk4 integrator
package astrac.engine
import cats._
import cats.syntax._
import scala.annotation.tailrec
object mk4 {
trait State[S, D, T] {
def semigroup: Semigroup[S]
def derivate: mk4.Derivate[D, T]
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
(defun ensure-package-installed (&rest packages)
"Assure every package is installed, ask for installation if it’s not.
Return a list of installed packages or nil for every skipped package."
(mapcar
@Astrac
Astrac / TypeMap.scala
Created September 24, 2015 09:42
A map from types to values of other types
import shapeless._
import shapeless.ops.hlist._
sealed trait SameSize[L1 <: HList, L2 <: HList]
object SameSize {
def apply[L1 <: HList, L2 <: HList] = new SameSize[L1, L2] {}
implicit def hnilHasSameLength = SameSize[HNil, HNil]
@Astrac
Astrac / RetryPattern
Created December 28, 2013 13:27
Akka utility to retry asking a message multiple times returning a Future for the whole tries
package kvstore
import akka.actor._
import akka.util.Timeout
import akka.pattern.ask
import scala.concurrent.duration._
object RetryingActor {
case class Start[T](target: ActorRef, message: T, rate: FiniteDuration, maxAttempts: Int)
case object Retry