Skip to content

Instantly share code, notes, and snippets.

@tomasherman
tomasherman / keybase.md
Last active January 20, 2021 10:59
keybase.md

Keybase proof

I hereby claim:

  • I am tomasherman on github.
  • I am tomasherman (https://keybase.io/tomasherman) on keybase.
  • I have a public key ASAZyziR-Ex8X0kdHztFnDjYBIDJJR5Foi0j-njqevn55wo

To claim this, I am signing this object:

@tomasherman
tomasherman / run.scala
Last active November 19, 2018 16:25
paralellism cats
import java.util.concurrent.Executors
import cats.effect.{Effect, IO}
import monix.eval.Task
import scala.concurrent.Await
import scala.concurrent.duration._
import scala.language.{higherKinds, postfixOps}
object Paralellism extends App {
@tomasherman
tomasherman / keybase.md
Created August 28, 2018 12:44
keybase.md

Keybase proof

I hereby claim:

  • I am tomasherman on github.
  • I am tomasherman (https://keybase.io/tomasherman) on keybase.
  • I have a public key ASDEgOsqfuKc4jt87CJNjRgLtYWlabUCILVrMCaGNDRgMwo

To claim this, I am signing this object:

import org.eclipse.jetty.server.Server
import org.eclipse.jetty.webapp.WebAppContext
import org.eclipse.jetty.server.nio._
object RunWebApp extends App {
val server = new Server
val scc = new SelectChannelConnector
scc.setPort(8080)
server.setConnectors(Array(scc))
//E 3.3.4
def init[A](l: List[A]): List[A] = {
l match {
case Nil => Nil
case Cons(x,Nil) => Nil
case Cons(x,xs) => Cons(x,init(xs))
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package auiproject.alg;
import auiproject.AbstractOptAlgInstance;
import auiproject.DoubleVectorIndividual;
import auiproject.util.RandomNumber;
@tomasherman
tomasherman / gist:1730782
Created February 3, 2012 15:39
Got 99 problems, but unit testing ain't one of them!
package net.tomasherman.replayvault.server.util
import org.scalacheck._
import Gen._
import Prop._
import cc.spray.json._
import com.mongodb.casbah.Imports._
import mongo._
trait JsonGen extends DefaultJsonProtocol{
@tomasherman
tomasherman / gist:1596598
Created January 11, 2012 20:28
sumofdigits
def sumOfDigits(x: BigInt, sum: BigInt):BigInt = { //funkce se menuje sumOfDigits, bere dva argumenty, x kterej ma typ BigInt a sum, taky BigInt a vraci BigInt
x match { //tohle rika ze se ma porovnavat x s nasledujicim:
case xx if xx == 0 => sum //pokud x, ktery prejmenuju na xx == 0, tak to znamena ze sme vsechno secetli a v promenny sum je suma vsech cisel
case xx => sumOfDigits(xx / 10, sum + (xx % 10)) //pokud to neni 0, tak tam jeste nejaky cislice zbyvaj...zavolame znova sumOfDigits, ale s upravenejma parametrama tak, ze z x zahodime posledni cislo a k sume to posledni cislo pricteme
}
}
@tomasherman
tomasherman / gist:1340196
Created November 4, 2011 19:05
Scala swing
package net.tomasherman.replayvault.client.gui
import swing._
import event.{EditDone, ButtonClicked}
import net.miginfocom.swing.MigLayout
import javax.swing.BorderFactory
import java.awt.Color
import java.util.Arrays
import akka.actor.Actor
@tomasherman
tomasherman / Herewegogo.scala
Created October 24, 2011 14:40
Dispatch, Https and self signed certificate
/**
* Sorry about the mess in imports but i figured this in REPL and i didn't want to refactor it because i'm sure i would eff it up.
* First of all you need to import certificate into a keystore like so:
/opt/java/bin/keytool -import -alias ca -file ~/Desktop/www.ondrej.vostal.net -keystore cacerts
* This should create file castore. I'm not sure about the details of this but i'm sure it's fine ^_^
* This code is basically a ripoff of the http://stackoverflow.com/questions/5206010/using-apache-httpclient-for-https
*/
import dispatch._
import java.security._