Skip to content

Instantly share code, notes, and snippets.

View chemacortes's full-sized avatar

Chema Cortés chemacortes

View GitHub Profile
@Yarith
Yarith / Article - Animate removed DOM elements.md
Last active April 28, 2022 23:50
Elm: Animate the removal of DOM elements with CustomElement and MutationObserver

Elm: Animate the removal of DOM elements with CustomElement and MutationObserver

Desired result

You can see the end result in this ellie. It displays a smooth removal of the clicked items. You can also remove some items from the beginning or the end.

Version 1

https://ellie-app.com/cvCV93KgD56a1

Version 2

An updated ellie with improved performance. This gist was not yet updated with all changes made in this version. Only the article text is somewhat updated.

@markehammons
markehammons / build.sbt
Created December 19, 2018 04:22
Packaging your application with a minimized runtime courtesy of jlink
import java.io.{ByteArrayOutputStream, PrintWriter}
import java.util.spi.ToolProvider
enablePlugins(JavaAppPackaging)
//this allows us to run tools like jdeps and jlink from within the JVM
def runTool(name: String, arguments: Seq[String]): Either[String,String] = {
val maybeTool: Option[ToolProvider] = {
val _tool = ToolProvider.findFirst(name)
if(_tool.isPresent) {
@pchiusano
pchiusano / Interpreters.scala
Created September 21, 2017 20:51
Code for Scala World 2017 talk on eliminating interpreter overhead via partial evaluation
package scalaworld.interpreters
/*
This file shows a simple language, an interpreter, and two
partial evaluators for that language, along with a profiling suite.
*/
trait Expr // denotes a Vector[Double] => Vector[Double]
object Expr {
@georgexsh
georgexsh / goto.py
Created September 18, 2017 07:47
python goto with system trace function
import sys
def j(lineno):
frame = sys._getframe().f_back
called_from = frame
def hook(frame, event, arg):
if event == 'line' and frame == called_from:
try:
frame.f_lineno = lineno
@jdegoes
jdegoes / IO.scala
Created August 9, 2016 22:26
A pedagogical implementation of the IO monad in Scala in 14 LOC
case class IO[A](unsafePerformIO: () => A) {
def map[B](ab: A => B): IO[B] = IO(() => ab(unsafePerformIO()))
def flatMap[B](afb: A => IO[B]): IO[B] =IO(() => afb(unsafePerformIO()).unsafePerformIO())
def tryIO(ta: Throwable => A): IO[A] =
IO(() => IO.tryIO(unsafePerformIO()).unsafePerformIO() match {
case Left(t) => ta(t)
case Right(a) => a
})
}
object IO {
@costajob
costajob / fact.cr
Last active September 20, 2022 21:15
Factorial implementation using Big numbers in Ruby, GO and Crystal
require "big_int"
def fact(n)
return 1 if n == 0
n * fact(n - 1)
end
n = BigInt.new(ARGV[0])
puts fact(n)
@juancarlospaco
juancarlospaco / html2ebook.py
Last active May 10, 2018 19:18
HTML5 to eBook converter, with Table Of Contents, Compression, optional Metadata, optional output filename, Mobile Friendly, ePub v.3.0.1 compliant, runs as standalone, run as module, Python3, NO Dependencies just Python Standard Lib only.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""HTML2eBook a tiny function that converts HTML5 to eBook,Mobile Friendly."""
import os
import zipfile
from getpass import getuser
{
import javax.sound.midi._
val synth = MidiSystem.getSynthesizer()
synth.open()
def note(i: Int) = {
val channels = synth.getChannels()
channels(0).noteOn(i, 100)
Thread.sleep(250)
channels(0).noteOff(i)
}
@staltz
staltz / introrx.md
Last active May 3, 2024 13:00
The introduction to Reactive Programming you've been missing