Skip to content

Instantly share code, notes, and snippets.

Robin Green greenrd

Block or report user

Report or block greenrd

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@olejon
olejon / Install Spotify 0.9 on Fedora 64-bit
Last active Mar 7, 2019
Install Spotify 0.9 on Fedora 64-bit
View Install Spotify 0.9 on Fedora 64-bit
# NOTES
# Spotify 0.9 vs 1.0 is stable, uses less resources overall and works well with Spotify Connect, SpotCommander, Local Files etc
# Tested and works on Fedora 29 64-bit with GNOME, but should work on previous versions as well
# The sources of the Dropbox files, which are hosted by me and the latest and greatest available, are listed above each one
# No system files will be overwritten by these or used by other programs since they depend on the later Fedora versions
# Make sure you copy the whole lines into Terminal
# Each command is on one line and might be long
# START GUIDE
View gist:9f1057e1a96095d4cc6a
# Put this in your .gitconfig file under the alias section
orphank = !gitk --all `git reflog | cut -d " " -f 1`&
# Then run it by typing 'git orphank' on the command line.
# A text version of the same is
orphanl = !git log --pretty=oneline --abbrev-commit --graph --decorate `git reflog | cut -d " " -f 1`
@odersky
odersky / A simpler way to returning the "current" type in Scala.
Last active Dec 15, 2018
A simpler way to returning the "current" type in Scala.
View A simpler way to returning the "current" type in Scala.
/** This is in reference to @tploecat's blog http://tpolecat.github.io/2015/04/29/f-bounds.html
* where he compares F-bounded polymorphism and type classes for implementing "MyType".
*
* Curiously, the in my mind obvious solution is missing: Use abstract types.
*
* A lot of this material, including an argument against F-bounded for the use-case
* is discussed in:
*
* Kim B. Bruce, Martin Odersky, Philip Wadler:
* A Statically Safe Alternative to Virtual Types. ECOOP 1998: 523-549
@djspiewak
djspiewak / streams-tutorial.md
Created Mar 22, 2015
Introduction to scalaz-stream
View streams-tutorial.md

Introduction to scalaz-stream

Every application ever written can be viewed as some sort of transformation on data. Data can come from different sources, such as a network or a file or user input or the Large Hadron Collider. It can come from many sources all at once to be merged and aggregated in interesting ways, and it can be produced into many different output sinks, such as a network or files or graphical user interfaces. You might produce your output all at once, as a big data dump at the end of the world (right before your program shuts down), or you might produce it more incrementally. Every application fits into this model.

The scalaz-stream project is an attempt to make it easy to construct, test and scale programs that fit within this model (which is to say, everything). It does this by providing an abstraction around a "stream" of data, which is really just this notion of some number of data being sequentially pulled out of some unspecified data source. On top of this abstraction, sca

@zygm0nt
zygm0nt / spray-route.scala
Created Mar 11, 2014
scala spray route debugging
View spray-route.scala
trait AbcService with UnhandledRouteDebug {
override def receive: Actor.Receive = runRoute(logRequestResponse(myLog _) {
staticRoute ~ internalRoutes ~ routes
})
}
trait UnhandledRouteDebug {
def myLog(request: HttpRequest): Any => Option[LogEntry] = {
case x: HttpResponse => {
println (s"Normal: $request")
View ummutable.scala
import scala.collection.mutable.ListBuffer
class Ummutable[T] private (buf: ListBuffer[T]) {
def this(xs: T*) = this(ListBuffer() ++= xs)
def append(ys: T*): this.type = { buf ++= ys ; this }
final val xs: List[T] = buf.toIterable match { case xs: List[T] => xs }
override def toString = s"Ummutable(xs = ${xs mkString ", "})"
}
View gist:9081797
scala> val buf = ListBuffer(1)
buf: scala.collection.mutable.ListBuffer[Int] = ListBuffer(1)
scala> val xs = buf.toIterable match { case xs: List[Int] => xs }
xs: List[Int] = List(1)
scala> buf ++= 1 to 100
res11: buf.type = ListBuffer(1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100)
scala> xs
@uarun
uarun / logback.xml
Last active Oct 6, 2015
Slick 2.0 - Enabling SQL Statement Logging
View logback.xml
<logger name="scala.slick.jdbc.JdbcBackend.statement" level="DEBUG" />
@joechrysler
joechrysler / who_is_my_mummy.sh
Last active Aug 19, 2019
Find the nearest parent branch of the current git branch
View who_is_my_mummy.sh
#!/usr/bin/env zsh
git show-branch -a \
| grep '\*' \
| grep -v `git rev-parse --abbrev-ref HEAD` \
| head -n1 \
| sed 's/.*\[\(.*\)\].*/\1/' \
| sed 's/[\^~].*//'
# How it works:
@larsrh
larsrh / set.scala
Created May 2, 2013
Sets are not Functors
View set.scala
scala> :paste
// Entering paste mode (ctrl-D to finish)
case class A(x: Int)(y: Int) { def toB = B(x, y) }
case class B(x: Int, y: Int) { def toA = A(x)(y) }
// Exiting paste mode, now interpreting.
defined class A
defined class B
You can’t perform that action at this time.