Skip to content

Instantly share code, notes, and snippets.

View igstan's full-sized avatar

Ionuț G. Stan igstan

View GitHub Profile
package com.example.http4splayground.services
import java.util.Date
import java.util.concurrent.TimeUnit
import cats._
import cats.data.StateT
import cats.effect.{ExitCode, IO, IOApp}
import cats.implicits._
import cats.mtl.MonadState
@igstan
igstan / kind-polymorphism.scala
Last active May 16, 2018 13:59 — forked from szeiger/gist:3a2e7e65b641bac9764a9c02de233ab9
Kind-polymorphic Any and Nothing
scala> import scala.language.higherKinds
import scala.language.higherKinds
scala> def f[C[_], E]: List[C[E]] = Nil
f: [C[_], E]=> List[C[E]]
scala> f[List, Int]
res0: List[List[Int]] = List()
scala> f[Any, Int]
@igstan
igstan / visitor.py
Last active November 20, 2015 09:36 — forked from danoneata/visitor.py
Visitor pattern in Python
class Expr(object):
def accept(self, visitor):
method_name = 'visit_{}'.format(self.__class__.__name__.lower())
visit = getattr(visitor, method_name)
return visit(self)
class Int(Expr):
def __init__(self, value):
self.value = value
---
# ^^^ YAML documents must begin with the document separator "---"
#
#### Example docblock, I like to put a descriptive comment at the top of my
#### playbooks.
#
# Overview: Playbook to bootstrap a new host for configuration management.
# Applies to: production
# Description:
# Ensures that a host is configured for management with Ansible.
@igstan
igstan / wasps.md
Last active December 25, 2015 21:39 — forked from aphyr/gist:7044081

schema

It's actually more like a figure-eight cycle, though--depending on species. Wasps start out in the syconium full of male flowers, called a caprifig. The male wasps mate with the females immediately after pupation, and fertilize still incomplete female wasps. They dig a tunnel out of the caprifig then die; the female wasps escape via the tunnel, carrying male-flower pollen with them.

Female wasps then enter either caprifigs or figs--male or female syconia. If they enter a male syconium, they get to lay their eggs in the male flowers and the process starts anew. If they enter a female syconium, they can't lay eggs in the female flowers because they're shaped wrong, and die alone--but not before coating the female flowers in the male pollen from their birthplace.

The female syconium, if fertilized by wasps, develops seeds, is eaten, and gives rise to the next generation of fig trees. The syconium secretes digestive enzymes

package deiko
import scala.concurrent.Future
import scala.concurrent.duration.Duration
import scalaz.concurrent.Task
import scalaz.stream._
import play.api.libs.iteratee._
import Process._
object Conversion {
@igstan
igstan / curried.rkt
Created December 25, 2012 00:13 — forked from anonymous/curried.rkt
Shorthand notation for curried functions in Racket.
#lang racket
(define ((add x) y)
(+ x y))
;; ((add 1) 2) -> 3
;; (add 1 2) -> arity mismatch error
@igstan
igstan / DateUtils.scala
Created December 4, 2012 08:50 — forked from fcroiseaux/DateUtils.scala
Utils class to calculate and work with holidays in a country (here in Luxembourg)
package utils
import org.joda.time.{Period, LocalDate}
object DateUtils {
def dateRange(from: LocalDate, to: LocalDate, step: Period): Iterator[LocalDate] =
Iterator.iterate(from) {
dt => dt.plus(step)
}.takeWhile(!_.isAfter(to))
@igstan
igstan / hack.sh
Created August 22, 2012 20:08 — forked from DAddYE/hack.sh
OSX For Hackers
#!/bin/sh
##
# This is a script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# Run in interactive mode with:
# $ sh -c "$(curl -sL https://raw.github.com/gist/2108403/hack.sh)"
#
# or run it without prompt questions:
@igstan
igstan / centered_triangle.html
Created May 3, 2011 13:47 — forked from romannurik/centered_triangle.html
A simple CSS trick to create a horizontally- or vertically-centered 'selected' callout triangle using zero images.
<!DOCTYPE html>
<html>
<head>
<style>
body {
margin: 40px;
}
a {
display: inline-block;