Skip to content

Instantly share code, notes, and snippets.

View ziggystar's full-sized avatar

ziggystar

  • Bavaria, Germany
  • 20:30 (UTC +02:00)
View GitHub Profile
// Start writing your ScalaFiddle code here
import monix.reactive._
import monix.eval._
import cats.effect._
import cats.effect.syntax._
import monix.execution.Scheduler.Implicits.global
import scala.concurrent.duration._
require(ggplot2)
library(ggplot2)
df <- read.table(header=T, text=' x y
1 -1
2 -1.5
3 -1.6
4 -1.7
5 -1')
@ziggystar
ziggystar / tetris-benchmark.scala
Created March 30, 2015 20:06
Benchmark script to measure performance of different ways to compute the profile of a tetris stack.
import java.lang.management.ManagementFactory
/**
* Benchmark to measure performance of computing profile of Tetris stack.
* http://stackoverflow.com/questions/29309942/how-to-compute-the-height-profile-of-a-tetris-stack-most-efficiently
*
* This code may be used under MIT license.
*/
val width = 10
@ziggystar
ziggystar / platinum-rift.hs
Created December 23, 2014 22:25
Haskell Code Template for Platinum Rift game at condingame.com
import System.IO
import Control.Monad
import Control.Applicative
import Data.Graph
import Data.Array
type Player = Int
data ZoneState = ZoneState { zoneOwner :: Player, zonePODs :: [Int] } deriving (Show, Eq)
@ziggystar
ziggystar / gs_bibtex_download.user.js
Created June 25, 2014 08:32
Greasemonkey script for changing BibTex links to download links on Google Scholar
// ==UserScript==
// @name Google Scholar Download BibTex
// @namespace https://gist.github.com/ziggystar
// @description Changes the links to BibTex citations such that they are opened/downloaded instead of displayed inside the browser. This allows automatic importing of entries into external programs.
// @include http://scholar.google.de/*
// @include https://scholar.google.de/*
// @version 1
// @grant none
// ==/UserScript==
// ==UserScript==
// @namespace http://tgeier.de/user.js
// @name Amboss Inline
// @version 0.2
// @description Inlines the tool-tips on amboss pages for better printing.
// @include https://amboss.miamed.de/*
// @run-at document-end
// ==/UserScript==
var column = document.getElementsByClassName("Column")[0];
@ziggystar
ziggystar / benchmark_23737147.scala
Created May 19, 2014 16:33
Benchmark anonymous function creation in Scala
/**
Benchmark for the question "For comprehension and number of function creation" on SO. (http://stackoverflow.com/q/23737147/108915)
Answer: http://stackoverflow.com/a/23742289/108915
*/
object M {
def useIt(): Unit = {
println(variantA())
@ziggystar
ziggystar / index.html
Last active December 31, 2015 20:09 — forked from darwin/index.html
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="stylesheet" href="http://cmx.io/v/0.1/cmx.css"/>
<script src="http://cmx.io/v/0.1/cmx.js"></script>
<body>
<scene id="scene1">
<label t="translate(0,346)">
<tspan x="0" y="0em">One winter morning</tspan>
</label>
<actor t="translate(138,34)" pose="-70,12|-72,125|-70,102|-70,92|-70,82|-70,62|-75,37|-80,12|-65,37|-60,12|-77,82|-76,64|-65,82|-60,62">
#include <vector>
#include <set>
#include <iostream>
#include <functional>
#include <algorithm>
#include <assert.h>
using namespace std;
template<class Container>
/** Find the minimum amount of smoke (second) and resulting color (first)
by splitting the sequence at every possible position,
given `lookup` contains the best mix for subsequence. */
def minSmokeMixtureSingle(s: Seq[Int], lookup: Map[Seq[Int],(Int,Int)]): (Int,Int) =
if(s.size == 1)
(s(0),0)
else if(s.size == 2)
mix(s(0),s(1))
else {
val splits = (1 to (s.size - 1)).map(s.splitAt)