Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

/**
* Given the following file, create a simple Scala programming example
* that would parse and then randomly output a quote.
* (http://www.coverfire.com/files/quotes.txt)
*/
import scala.io.Source
import scala.util.Random
case class QuotesForgery(quotes: List[String] = List(), val workspace: List[String] = List()) {
@EncodePanda
EncodePanda / gist:1fdfda27931aa687710b
Last active August 29, 2015 14:22
How to combine functionalities?
A:
trait DoValidator {
def validate(input:String): Validation = ...
}
trait Doer extends DoValidator {
def do(input: String) = validate(input) match
case Success => ....
case Failuer => ....
@EncodePanda
EncodePanda / gist:1ff12f58c475ed176bb1
Created June 16, 2015 22:07
Remembers credentials for 1 hour (in git)
git config --global credential.helper 'cache --timeout=3600'
@EncodePanda
EncodePanda / gist:39ba1d60397aa39a7757
Created July 7, 2015 15:31
Pretty graph logs stolen from stack over flow
[alias]
lg1 = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
lg2 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all
lg = !"git lg1"
@EncodePanda
EncodePanda / Talks I Love.md
Last active April 2, 2017 00:09
Talks I Love.md
@EncodePanda
EncodePanda / Scala and Emacs with Ensime. Guide for frustrated IDEA users.md
Last active June 13, 2018 08:04
Scala and Emacs with Ensime. Guide for frustrated IDEA users.
# Not Connector related
flattenArrayWithUnflattened.test - never terminates
caseVariations.test - see #1700
caseWithGroup.test - works only for CO, according to Emrys "Nightmarish QScript (just enormous)"
doubleFlattenWithIntervening - same as marklogic "doesn't preserve the fact that the first element doesn't have the req field, so missing NA in result"
null/nullTestExprs - same as marklogic, JVM OOM error
null/nullTestExprsWithMissing - same as marklogic, JVM OOM error
symmetricNonJsJoinCondition - same as marklogic, QScript never finishes
temporal/datePartsConverted.test - never terminates
@EncodePanda
EncodePanda / rs.scala
Created February 15, 2017 13:29
Very simple &not generic implementation of cata, ana & hylo for Fix
package rss
import scalaz._, Scalaz._
case class Fix[F[_]](unfix: F[Fix[F]])
object Fix {
type Algebra[F[_], A] = F[A] => A
import scalaz.{Free => _, _}, Scalaz._
object Attempt1 {
sealed trait Free[S[_], A]
case class Done[S[_], A](a: A) extends Free[S, A]
case class Roll[S[_], A](k: S[Free[S, A]]) extends Free[S, A]
object Free {