Skip to content

Instantly share code, notes, and snippets.

View huitseeker's full-sized avatar

François Garillot huitseeker

View GitHub Profile
@huitseeker
huitseeker / Point.scala
Last active December 19, 2015 05:08
Triggering Implicit search by emulating double dispatch using simple dispatch
object Point {
trait PointAdder[P2] {
def add(p2: P2): Point3D
}
case class Point2D(x: Int, y: Int)
case class Point3D(x: Int, y: Int, z: Int)
implicit class Point2Adder(p1:Point2D) extends PointAdder[Point2D] {
@huitseeker
huitseeker / Point.scala
Created July 1, 2013 15:40
Sans SIP-13
import scala.language.implicitConversions
object Point {
trait PointAdder[P2] {
def add(p2: P2): Point3D
}
case class Point2D(x: Int, y: Int)
case class Point3D(x: Int, y: Int, z: Int)
@huitseeker
huitseeker / gist:8336663
Created January 9, 2014 16:05
Mapping an Int to a triple and vice versa. Or, how to serialize a Scala Version to an Int.
class VersionInt(val self: Int) extends AnyVal {
/**
* This defines one of Cantor's polynomials to define a bijection from N² to N,
* see e.g. http://jm.davalan.org/divers/bij/bij_Nn2N-en.html
*
*/
private def coupleToSingle(x: Int, y: Int) = ((x + y) * (x + y + 1))/ 2 + x
private def arithmeticSeries(n: Int) = n * (n + 1) / 2
private def n(z: Int) = ((-1 + math.sqrt(1 + 8 * z)) / 2).toInt
@huitseeker
huitseeker / gist:8438240
Created January 15, 2014 15:27
Diff to make sbt depend on sbinary 2.10.3
diff --git a/project/Util.scala b/project/Util.scala
index d11e866..d5ed57c 100644
--- a/project/Util.scala
+++ b/project/Util.scala
@@ -170,7 +170,7 @@ object Common
lazy val ivy = lib("org.apache.ivy" % "ivy" % "2.3.0-rc1")
lazy val httpclient = lib("commons-httpclient" % "commons-httpclient" %
lazy val jsch = lib("com.jcraft" % "jsch" % "0.1.46" intransitive() )
- lazy val sbinary = libraryDependencies <+= Util.nightly211(n => "org.sca
+ lazy val sbinary = libraryDependencies <+= Util.nightly211(n => "org.sca
@huitseeker
huitseeker / sbinarybuild-2.10.sh
Created January 15, 2014 15:29
sbinary build, invoked with sh ../sbinarybuild-2.10.sh 806b6e4
sbt "reboot full" clean \
"set every crossScalaVersions := Seq(\"2.10.4-$1-SNAPSHOT\")"\
"set every scalaBinaryVersion := \"2.10.4-$1-SNAPSHOT\" "\
'set (libraryDependencies in core) ~= { ld => ld flatMap { case dep if (dep.configurations.map(_ contains "test") getOrElse false) => None; case dep => Some(dep) } }' \
'set every publishMavenStyle := true' \
'set every resolvers := Seq("Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots", "Typesafe IDE" at "https://typesafe.artifactoryonline.com/typesafe/ide-2.11", "Local maven" at Path.userHome.asFile.toURI.toURL + "/.m2/repository")' \
'set every credentials := Seq(Credentials(Path.userHome / ".credentials"))' \
'set every publishTo := Some(Resolver.file("file", new File(Path.userHome.absolutePath+"/.m2/repository")))' \
+core/publish +core/publish-local
@huitseeker
huitseeker / sbtbuild-2.10.sh
Created January 15, 2014 15:30
sbt build script, invoked with ../sbtbuild-2.10.sh 806b6e4
sbt "reboot full" clean
sbt -v "set every crossScalaVersions := Seq(\"2.10.4-$1-SNAPSHOT\")"\
"set every scalaVersion := \"2.10.4-$1-SNAPSHOT\""\
'set every Util.includeTestDependencies := false' \
"set every scalaBinaryVersion := \"2.10.4-$1-SNAPSHOT\"" \
'set every publishMavenStyle := true' \
'set overrideBuildResolvers :=true'\
'set every resolvers := Seq("Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots", "Typesafe IDE" at "https://typesafe.artifactoryonline.com/typesafe/ide-2.11", "Local maven" at Path.userHome.asFile.toURI.toURL + "/Scala/m2repo")' \
'set artifact in (compileInterfaceSub, packageBin) := Artifact("compiler-interface")' \
import scala.reflect.macros.Context
import scala.language.experimental.macros
object Impls {
def impl[A](c: reflect.macros.Context) = c.universe.reify(())
}
object Macros {
def decl[A] = macro Impls.impl[A]
}
mate-desktop-environment mate-system-monitor libgnome-bluetooth7 libwine-gl wine-bin libwine-bin xchat pidgin libperl5.18 printer-driver-postscript-hp hplip printer-driver-hpcups kate libkateinterfaces4 kde-runtime libdbd-mysql-perl libdbd-sqlite3-perl libapache-dbi-perl libdbd-pg-perl libdbi-perl libplrpc-perl lintian libemail-valid-perl libnet-dns-perl libapache2-reload-perl libapache2-mod-perl2 libsoap-lite-perl ocsinventory-agent libarchive-zip-perl libdevel-partialdump-perl libhtml-format-perl perl-doc alacarte alien apache2-mpm-worker mate-user-share libapache2-mod-dnssd apache2.2-bin mint-meta-common command-not-found apt-file mintwelcome apturl atril banshee-extension-soundmenu banshee bioperl-run bioperl brasero r-base-dev build-essential bwa ffmpegthumbnailer-caja mate-core caja-gksu caja-open-terminal camorama cinnamon-screensaver mdm nemo-fileroller nemo mate-power-manager cinnamon caribou cheese tomboy libgmime2.6-cil libgdata1.7-cil gnome-control-center colord compiz compiz-fusion-plugins-extra
apache2 aptdaemon apt-file banshee brasero camorama caribou cinnamon cinnamon-screensaver colord colord command-not-found console-setup console-setup-linux cups cups-filters desktop-base docbook-xml docbook-xsl dpkg-dev emboss-lib engrampa eom fancontrol fancontrol file-roller fonts-cantarell fusion-icon gimp git gksu gnome-bluetooth gnome-colors-common gnome-control-center gnome-keyring gnome-media gnome-menus gnome-mplayer gnome-power-manager gnome-ppp gnome-settings-daemon gnome-system-monitor gnome-terminal gnome-themes gnome-wise-icon-theme gnupg-agent gnustep-base-common gnustep-base-runtime gnustep-common google-chrome-stable gparted graphviz gthumb gucharmap gufw hardinfo hplip jalview kate kate-data kdelibs5-data kde-runtime kde-runtime-data keyboard-configuration latex-beamer latex-xcolor libapache2-mod-dnssd libapache2-mod-perl2 libatril libatspi1.0-0 libbonoboui2-0 libboo2.0.9-cil libboost-system1.53.0 libbrasero-media3-1 libcaja-extension libclutter-gtk-0.10-0 libedata-book-1.2-13 libedataserveru
@huitseeker
huitseeker / PKGBUILD
Last active August 29, 2015 14:02
PKGBUILD for cudpp
# Contributor: Jan Stępień <jstepien@users.sourceforge.net>
pkgname=cudpp
pkgver=2.0
pkgrel=2
pkgdesc="The CUDA Data Parallel Primitives Library"
arch=('i686' 'x86_64')
url="http://code.google.com/p/cudpp"
license=('BSD')
depends=('cuda')