Skip to content

Instantly share code, notes, and snippets.

Jules Ivanic guizmaii

Block or report user

Report or block guizmaii

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
View multi thread cache-stuff.scala
import cats.effect.ExitCode
import monix.eval.{Task, TaskApp}
import monix.execution.atomic.Atomic
class MtCache[A](ref: Atomic[Map[String, Task[A]]]) {
def cache(key: String)(task: () => A): Task[A] = {
ref.transformAndExtract { current =>
current.get(key) match {
View multi thread cache-stuff.scala
import cats.effect.ExitCode
import monix.eval.{Task, TaskApp}
import monix.execution.atomic.Atomic
class MtCache[A](ref: Atomic[Map[String, Task[A]]]) {
def cache(key: String)(task: () => A): Task[A] = {
ref.transformAndExtract { current =>
current.get(key) match {
View log.singletons.verbose.txt
2019-04-24T08:32:52.164Z [Ruby-0-Thread-16@puma 014: /usr/src/app/vendor/bundle/jruby/2.5.0/gems/puma-3.12.1-java/lib/puma/thread_pool.rb:57] INFO MetaClass :
java.lang.Exception: singleton creation stack trace
at org.jruby.dist/org.jruby.MetaClass.logSingleton(MetaClass.java:67)
at org.jruby.dist/org.jruby.MetaClass.<init>(MetaClass.java:56)
at org.jruby.dist/org.jruby.RubyBasicObject.makeMetaClass(RubyBasicObject.java:553)
at org.jruby.dist/org.jruby.RubyClass.toSingletonClass(RubyClass.java:479)
at org.jruby.dist/org.jruby.RubyBasicObject.getSingletonClass(RubyBasicObject.java:538)
at org.jruby.dist/org.jruby.RubyBasicObject.instance_exec(RubyBasicObject.java:2678)
at usr.src.app.vendor.bundle.jruby.$2_dot_5_dot_0.gems.activesupport_minus_4_dot_2_dot_11_dot_1.lib.active_support.callbacks.RUBY$block$make_lambda$3(/usr/src/app/vendor/bundle/jruby/2.5.0/gems/activesupport-4.2.11.1/lib/active_support/callbacks.rb:441)
at org.jruby.dist/org.jruby.runtime.CompiledIRBlockBody.callDirect(CompiledIRBlockBo
@guizmaii
guizmaii / ZioExecSemantic.scala
Created Apr 22, 2019 — forked from fanf/ZioExecSemantic.scala
Show how ZIO behave with/without fiber fork.
View ZioExecSemantic.scala
/*
* This test shows that without a fork, execution is purely mono-fiber and sequential.
*/
object TestZioExecSemantic {
val rt = new DefaultRuntime {}
trait LOG {
def apply(s: String): UIO[Unit]
}
def makeLog = UIO(new LOG {
val zero = System.currentTimeMillis()
@guizmaii
guizmaii / GroupableOps.scala
Created Apr 16, 2019 — forked from fernandomora/GroupableOps.scala
Scala groupMap from 2.13 for scala 2.12
View GroupableOps.scala
import scala.collection.{immutable, mutable, GenTraversableOnce}
import scala.collection.generic.CanBuildFrom
object GroupableOps {
implicit class ToGroupable[A, Coll[X] <: GenTraversableOnce[X]](coll: Coll[A]) {
// https://github.com/scala/scala/blob/v2.13.0-M5/src/library/scala/collection/Iterable.scala#L578
def groupMap[K, B, To](key: A => K)(f: A => B)
(implicit bf: CanBuildFrom[Coll[A], B, To]): immutable.Map[K, To] = {
View mvn_package_pbootstrap.java
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.torquebox.mojo.mavengem.wagon.MavenGemWagon.rubygemsFactory(MavenGemWagon.java:88)
at org.torquebox.mojo.mavengem.wagon.MavenGemWagon.newConnection(MavenGemWagon.java:102)
at org.torquebox.mojo.mavengem.wagon.MavenGemWagon.fillInputData(MavenGemWagon.java:64)
at org.apache.maven.wagon.StreamWagon.getInputStream(StreamWagon.java:126)
at org.apache.maven.wagon.StreamWagon.getIfNewer(StreamWagon.java:88)
at org.apache.maven.wagon.StreamWagon.get(StreamWagon.java:61)
at org.eclipse.aether.transport.wagon.WagonTransporter$GetTaskRunner.run(WagonTransporter.java:567)
at org.eclipse.aether.transport.wagon.WagonTransporter.execute(WagonTransporter.java:435)
at org.eclipse.aether.transport.wagon.WagonTransporter.get(WagonTransporter.java:412)
View Ruby-0-Fiber-25
2019-03-29 17:33:39
"Ruby-0-Fiber-25" - Thread t@1172
java.lang.Thread.State: WAITING
at java.base@11.0.2/jdk.internal.misc.Unsafe.park(Native Method)
- parking to wait for <4e7da9fc> (a java.util.concurrent.SynchronousQueue$TransferStack)
at java.base@11.0.2/java.util.concurrent.locks.LockSupport.park(LockSupport.java:194)
at java.base@11.0.2/java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill(SynchronousQueue.java:460)
at java.base@11.0.2/java.util.concurrent.SynchronousQueue$TransferStack.transfer(SynchronousQueue.java:361)
View Ruby-0-Fiber-286
2019-03-29 16:46:51
"Ruby-0-Fiber-286" - Thread t@363
java.lang.Thread.State: WAITING
at java.base@11.0.2/jdk.internal.misc.Unsafe.park(Native Method)
- parking to wait for <69439394> (a java.util.concurrent.SynchronousQueue$TransferStack)
at java.base@11.0.2/java.util.concurrent.locks.LockSupport.park(LockSupport.java:194)
at java.base@11.0.2/java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill(SynchronousQueue.java:460)
at java.base@11.0.2/java.util.concurrent.SynchronousQueue$TransferStack.transfer(SynchronousQueue.java:361)
at java.base@11.0.2/java.util.concurrent.SynchronousQueue.put(SynchronousQueue.java:873)
View One_concept_to_explain_them_all_and_in_the_theory_bind_them.scala
/*
This piece of commented code aims to clarify some
misconceptions between several advanced concepts
in pure functional programming/category theory:
free monads, finally tagless approach, algebraic
effects.
These concepts are actually very close. They rely
on similar concepts and even represent the "same"
object (up to isomorphism!) from the theoretical
@guizmaii
guizmaii / latency.markdown
Created Jan 16, 2019 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know
View latency.markdown

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs
Read 1 MB sequentially from memory ..... 250,000 ns  = 250 µs
You can’t perform that action at this time.