Skip to content

Instantly share code, notes, and snippets.

@dohzya
dohzya / JsResult2Try.scala
Last active December 15, 2015 13:59
Full example of implicit transformation of JsResult into Try
package foo
import scala.util._
import play.api._
import play.api.data.validation.ValidationError
import play.api.libs.json._
object Foo {
anonymous
anonymous / rdf2csv
Created July 24, 2013 04:57
Code to generate a CSV file from RDF document. Each row represents an individual with all its property values in columns. The separator is ";"
import com.hp.hpl.jena.rdf.model.ModelFactory
import scala.collection.JavaConversions._
val m = ModelFactory.createOntologyModel
m.read("****INPUT****","N3")
val properties = (m.listDatatypeProperties.toList ++ m.listObjectProperties)
val individualRows = m.listIndividuals.toList.map(i =>
i.getURI + ";" + properties.
map(p => i.listPropertyValues(p).toList.mkString(",")).mkString(";")
@pomadchin
pomadchin / shapelessFuncFilter.scala
Last active December 29, 2015 06:19
shapeless custom type filter for functions
/**
* Type class supporting access to the all elements of this `HList` for functions from type `U` ~(`U => V`).
*
* author of original HList Filter Alois Cochard
*
* @author Grigory Pomadchin
*/
object am3 {
trait FuncFilter[L <: HList, U] extends DepFn1[L] { type Out <: HList }
@mathiasrw
mathiasrw / True Trello Printer
Last active February 27, 2024 21:21
Ever wanted to print your Trello board? Export as JSON and paste it into the code.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>True Trello Printer</title>
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">
<style>
body{margin:15%;}
.panel-body{
@EdCharbeneau
EdCharbeneau / Enable-Transformations.md
Last active May 6, 2024 11:44
How to enable transformations on build with Visual Studio

#Transform web.config on build

  1. Unload the project
  2. Edit .csproj
  3. Append figure 1 to the end of the file just before </Project>; v12.0 my change depending on your version of Visual Studio
  4. Save .csproj and reload
  5. Open configuration manager
  6. Add a new Configuration Name: Base. Copy settings from: Release
  7. Copy the contents of your web.config
  8. Right click Web.Config > Add Config Transformation
@mandubian
mandubian / gist:807961eb9a8911f45894
Created April 30, 2014 15:00
I can't create a type tree from this and typecheck it... it infers either Any or doesn't typecheck at all... Any workaround?
scala> case class F[M[_], T]()
scala> val tpe = typeOf[F[M, _] forSome { type M[_] }]
##### FIRST TRY
scala> val e = q"{ type Tata[T] = ({ type l[T] = $tpe[scala.concurrent.Future, T] })#l[T]; () }"
e: toolbox.u.Tree =
{
type Tata[T] = scala.AnyRef {
type l[T] = F[_[_] <: Any, _][scala.concurrent.Future, T]
/**
The Play (2.3) json combinator library is arguably the best in the scala world. However it doesnt
work with case classes with greater than 22 fields.
The following gist leverages the shapeless 'Automatic Typeclass Derivation' facility to work around this
limitation. Simply stick it in a common location in your code base, and use like so:
Note: ** Requires Play 2.3 and shapeless 2.0.0

Just some notes and references for myself.

  • In bash, you can access your C:\ drive via /mnt/c/
  • ~ = C:\Users\MLM\AppData\Local\lxss\home\mlm and is different from your Windows user directory C:\Users\MLM

How to google things

@henning
henning / create-kube-user.sh
Created September 27, 2017 12:25
create k8s user, certificate, permissions and client config
#!/bin/bash
CLUSTERNAME=mycluster.mydomain
NAMESPACE=default
USERNAME=myclusteruser
GROUPNAME=mygroup
openssl genrsa -out ${USERNAME}.key 2048
CSR_FILE=$USERNAME.csr