This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import xml._ | |
| trait Rect[+T]{ | |
| def x: T | |
| def y: T | |
| def fun(name: String) = name+"("+x+","+y+")" | |
| } | |
| final case class OrientedRect[+T](vertical: T, horizontal: T) extends Rect[T]{ | |
| def width = horizontal | |
| def height = vertical |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Copyright (C) 2012 Vít Šesták <v6ak.com> | |
| # This program is free software. It comes without any warranty, to | |
| # the extent permitted by applicable law. You can redistribute it | |
| # and/or modify it under the terms of the Do What The Fuck You Want | |
| # To Public License, Version 2, as published by Sam Hocevar. See | |
| # http://www.wtfpl.net/ for more details. | |
| # This utility notifies about completed messages of Task spooler (see http://viric.name/soft/ts/). | |
| # Just add the path to this utility to $TS_ONFINISH. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.v6ak; | |
| public class HelloWorld{ | |
| public static void main(String[] args) throws InterruptedException, ClassNotFoundException{ | |
| System.out.println("Hello world"); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| io.Source.fromFile("/tmp/text").mkString.split("""[\?\.\!",\- \s]+""").sliding(3).toSeq.groupBy(_.toSeq).toSeq.map{x=>x._2.size->x._1.mkString(" ")}.sorted.reverse |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| case object BoolType extends Type with StandardType{ | |
| def getCommonSuperType(other: Type) = other match { | |
| case BoolType => BoolType | |
| case _ => combineWith(other) | |
| } | |
| def getSimpleStringRepresentation = "Boolean" | |
| def getClasses = Nil | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Copyright © 2013 Vít Šesták <http://contact.v6ak.com> | |
| # This work is free. It comes without any warranty, to the extent | |
| # permitted by applicable law. You can redistribute it and/or modify it | |
| # under the terms of the Do What The Fuck You Want To Public License, | |
| # Version 2, as published by Sam Hocevar. See http://www.wtfpl.net/ for | |
| # more details. | |
| ######################################################################## | |
| # Looks for bad usage of tab characters. | |
| # |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Prakticky neupravená verze. (Stejná logika jako původní Javový kód, proto imperativní.) | |
| def partitionBy[T, K](inputList: Iterable[T], partitionFunc: T=>K) = { | |
| val multimap = HashMultimap[K, T]() | |
| for (t <- inputList) { | |
| multimap(partitionFunc(t)) = t | |
| } | |
| multimap | |
| } | |
| // Funkcionální verze |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public OrderableService GetById(int id) | |
| { | |
| return ( | |
| from service in SourceSet | |
| where service.ID == id | |
| select service | |
| ).FirstOrDefault(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| trait ICalculatingStrategy { | |
| def calculate(a: Int, b: Int): Int | |
| } | |
| object AdderStrategy extends ICalculatingStrategy{ | |
| override def calculate(a: Int, b: Int) = a + b | |
| } | |
| object MultiplierStrategy extends ICalculatingStrategy{ | |
| override def calculate(a: Int, b: Int) = a * b |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val CalculatingOperations = Map[String, (Int, Int)=>Int]( | |
| "add" -> (_+_), | |
| "multiply" -> (_*_) | |
| ) | |
| CalculatingOperations("multiply")(3, 2) |