Skip to content

Instantly share code, notes, and snippets.

@rsuniev
rsuniev / coreos-docker-update.sh
Created May 4, 2018 12:01 — forked from dm0-/coreos-docker-update.sh
Update Docker on CoreOS using torcx
#!/bin/bash -e
# Select which Docker version to use on CoreOS with torcx.
# Specify the available Docker version to enable.
version=17.09
# Create modifiable torcx paths if they don't exist already.
mkdir -p /etc/torcx/profiles /var/lib/torcx/store
# Download the torcx manifest file for the currently running OS version.
def authorize_key_for_root(config, *key_paths)
[*key_paths, nil].each do |key_path|
if key_path.nil?
fail "Public key not found at following paths: #{key_paths.join(', ')}"
end
full_key_path = File.expand_path(key_path)
if File.exists?(full_key_path)
config.vm.provision 'file',
@rsuniev
rsuniev / gist:0e1c50af4a892b68f903
Created January 6, 2016 15:26 — forked from debasishg/gist:8172796
A collection of links for streaming algorithms and data structures
  1. General Background and Overview
@rsuniev
rsuniev / SCC.scala
Created October 16, 2011 08:25 — forked from mads-hartmann/SCC.scala
Strongly Connected Components algorithm implemented in Scala
/*
This is implemented following the instructions in "The Design and Analysis of
Computer Algorithms, AHO Hopcroft Ullman, 1974".
The implementation uses a DFS to find the strongly connected components (SCCs)
of a graph. During the DFS the vertices are placed on a stack in the order
they are visited. Whenever a root is found, all vertices of the corresponding
SSC are on the top of the stack and are popped.
@rsuniev
rsuniev / SCC-scalaz.scala
Created October 16, 2011 08:24 — forked from mads-hartmann/SCC-scalaz.scala
Strongly Connected Components algorithm implemented in Scala using ScalaZ
/*
This is implemented following the instructions in "The Design and Analysis of
Computer Algorithms, AHO Hopcroft Ullman, 1974".
The implementation uses a DFS to find the strongly connected components (SCCs)
of a graph. During the DFS the vertices are placed on a stack in the order
they are visited. Whenever a root is found, all vertices of the corresponding
SSC are on the top of the stack and are popped.
@rsuniev
rsuniev / lensed.scala
Created September 25, 2011 10:55 — forked from gseitz/lensed.scala
Lensed
// see https://github.com/gseitz/Lensed
object Lensed {
import scalaz._
import Scalaz._
case class Address(street: String, number: Int)
case class Person(name: String, address: Address)
@rsuniev
rsuniev / gist:1166584
Created August 23, 2011 21:21 — forked from milessabin/gist:1164885
Boxed lazy values
// Is this even faintly novel? The closest I've seen is
//
// http://stackoverflow.com/questions/2618891/using-lazy-evaluation-functions-in-varargs
//
// which is a bit clunky by comparison. But this is so trivial someone must have
// done it this way before.
// UPDATE:
// Thanks to the Twittersphere (@etorreborre, @pchiusano and @loverdos) for a few sightings of related things,
//
@rsuniev
rsuniev / ApplicativeMagic.scala
Created August 4, 2011 19:19 — forked from jsuereth/ApplicativeMagic.scala
reason #37 Why macros against Function1->22 would be useful..
trait ApplicativeMagic[F[_]] {
def apply[C](f: ApplicativeMagicFunctionHolder[FunctionArg => C]): F[C]
type FunctionArg
}
class ApplicativeMagicFunctionHolder[F](val f: F)
object ApplicativeMagicFunctionHolder {
implicit def fix2[A,B,C](f: (A,B) => C): ApplicativeMagicFunctionHolder[Tuple2[A,B] => C] =
new ApplicativeMagicFunctionHolder({ case (a,b) => f(a,b) })
implicit def fix3[A,B,C,D](f: (A,B,C) => D): ApplicativeMagicFunctionHolder[Tuple2[Tuple2[A,B],C] => D] =
new ApplicativeMagicFunctionHolder({ case ((a,b),c) => f(a,b,c) })
@rsuniev
rsuniev / gist:1120957
Created August 2, 2011 19:18 — forked from dcsobral/gist:1120811
Existential _ vs Higher-kind _
scala> def f[A[_] <: Seq[_]](f: A[Int]) = f.head
f: [A[_] <: Seq[_]](f: A[Int])A
scala> def f[A[_] <: Seq[t] forSome { type t }](f: A[Int]) = f.head
f: [A[_] <: Seq[_]](f: A[Int])A
scala> def f[A[t] <: Seq[_] forSome { type t}](f: A[Int]) = f.head
f: [A[t] <: Seq[_] forSome { type t }](f: A[Int])A
@rsuniev
rsuniev / accounts.clj
Created July 13, 2011 16:18 — forked from stuartsierra/accounts.clj
Accounts concurrency example in Clojure
;; An example of the "accounts" program for Venkat Subramaniam's
;; Programming Concurrency Workshop, part 1
;;
;; Original Java code by Venkat Subramaniam (@venkat_s)
;; available at http://www.agiledeveloper.com/downloads.html
;; under "Workshop: Programming Concurrency"
;;
;; This code example by Stuart Sierra (@stuartsierra)
;;
;; Überconf 2011, Denver, Colorado