Skip to content

Instantly share code, notes, and snippets.

@laughedelic
laughedelic / go-model.json
Last active August 29, 2015 14:03
Json representation of the GO Bio4j module
{
"label" : "go",
"properties" : [
{
"label" : "id",
"type" : "java.lang.String"
},
{
"label" : "name",
"type" : "java.lang.String"
@laughedelic
laughedelic / gist:8538472
Last active January 3, 2016 23:59
TitanDB: checking, that multi-value property doesn't add duplicates
> import com.thinkaurelius.titan.core._
> import com.tinkerpop.blueprints.Vertex
> val g = TitanFactory.open(".")
> g.makeKey("k").dataType(classOf[String]).list().unique().indexed(classOf[Vertex]).make()
// is there any nicer way of creating TitanVertex?
> val v = g.addVertex(null).asInstanceOf[TitanVertex]
> v.addProperty("k", "foo")
@laughedelic
laughedelic / taglistSettings.scala
Created November 11, 2013 11:47
sbt-taglist plugin settings
lazy val tagListSettings: Seq[Setting[_]] =
TagListPlugin.tagListSettings ++ Seq(
TagListKeys.tags := Set(
TagListPlugin.Tag("todo", TagListPlugin.Warn)
, TagListPlugin.Tag("fixme", TagListPlugin.Error)
)
)
@laughedelic
laughedelic / HListSubtract.scala
Created October 4, 2013 08:32
Using union for subtracting HLists (i.e. filtering first one using second as the reference of unwanted types). See also https://gist.github.com/laughedelic/6808000 for the union construction.
object HListSubtract {
// We use here this construction: https://gist.github.com/laughedelic/6808000
import UnionHList._
// Filters an HList `L`, trowing away any elements, that are in the given union `U`
trait Filter[L <: HList, U] {
type Out <: HList
def apply(l: L): Out
}
@laughedelic
laughedelic / UnionHList.scala
Created October 3, 2013 10:55
Constructing union type from an HList
trait UnionOf[L <: HList] {
type Mix
type Out = not[Mix]
type is[O] = UnionAux[L, O]
}
/* Implicits for constructing union: */
object UnionOf {
implicit val nil =
new UnionOf[HNil] { type Mix = not[Nothing] }
@laughedelic
laughedelic / gist:5444351
Created April 23, 2013 15:06
Workaround for using scala 2.10 in conscript app
[app]
...
name: foo_2.10
cross-versioned: false
[scala]
version: 2.10.0
@laughedelic
laughedelic / symbol-list-tester.cs
Created January 28, 2013 00:20
file that I used to test C# Sublime plugin indentation in Symbol List: https://github.com/laughedelic/SublimeCSharp
namespace FooNamespace
{
class Class
{
static void Method1(){}
static void Method2(){}
class InnerClass
{
static void InnerMethod1(){}
@laughedelic
laughedelic / g8test.sh
Last active December 11, 2015 09:58
Simple script for testing g8 templates without giter8 sbt-plugin (because it's weird). See instructions in comments.
# assuming that this script lies in g8test/ folder of the root directory of a g8-template
cd g8test
g8 file://.. --name=template > /dev/null
echo "Template applied in g8test/template/"
cd template
echo "sbt test:" && sbt test
cd ../..
@laughedelic
laughedelic / DecemberFair.hs
Created December 2, 2011 19:05
Solution for december FP fair
module DecemberFair where
import Data.Maybe (listToMaybe)
import Data.List (permutations, nubBy)
-- only non-symetric permutations
permute :: (Eq a) => [a] -> [[a]]
permute = nubBy (\ys zs -> ys == (reverse zs)) . permutations
-- binary operators
@laughedelic
laughedelic / Prolog.hs
Created December 1, 2011 15:32 — forked from hodzanassredin/Prolog.hs
simple type level predicates in haskell (with functional dependencies)
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, UndecidableInstances #-}
module Prolog (Petja, Vasja, Serg, Father, Son, GrandFather) where
data Petja = Petja
data Vasja = Vasja
data Serg = Serg