import scala.{PartialFunction => =/>}
val mapper: String =/> String = {
case Header(s) => s
}
val totalMapper = mapper orElse (identity[String] _): String =/> String
val totalMapper2 = mapper orElse PartialFunction.fromFunction(identity[String] _)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Case class tuple codec": { | |
"prefix": "scircetuple", | |
"body": [ | |
"import io.circe._", | |
"case class ${1:MyCaseClass}(${2:_1}: ${3:Double}, ${4:_2}: ${5:String})", | |
"object ${1} {", | |
" implicit val codec: Codec[${1}] = Codec.from(", | |
" implicitly[Decoder[(${3}, ${5})]].map((${1}.apply _).tupled),", | |
" implicitly[Encoder[(${3}, ${5})]].contramap(r => (r.${2}, r.${4}))", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"Case class tuple codec": { | |
"prefix": "scircetuple", | |
"body": [ | |
"import io.circe._", | |
"case class ${1:MyCaseClass}(${2:_1}: ${3:Double}, ${4:_2}: ${5:String})", | |
"object ${1} {", | |
" implicit val codec: Codec[${1}] = Codec.from(", | |
" implicitly[Decoder[(${3}, ${5})]].map((${1}.apply _).tupled),", | |
" implicitly[Encoder[(${3}, ${5})]].contramap(r => (r.${2}, r.${4}))", | |
" )", |
import io.circe.generic.extras.JsonKey
import sttp.client3._
import sttp.client3.circe._
import shapeless._
import io.circe._
import io.circe.generic.semiauto._
import io.circe.generic.auto._
import io.circe.generic.extras._, io.circe.syntax._
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# encoding: utf-8 | |
$stdout.sync = true | |
print "Scanning for FIXMEs. Generating diff…" | |
diff_bad = `HGRCPATH="" hg diff -r "default:$HG_NODE" --exclude 'glob:**.xml' --ignore-space-change --nodates --noprefix` | |
print "\rParsing and preparing output… " | |
diff = diff_bad.encode('utf-8', 'binary', :invalid => :replace, :undef => :replace) # because .properties files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val allSvgElements: SortedSet[String] = svg11Elements ++ svg12TinyElementsWithAttributes.keySet | |
val svgFactories = for { | |
elementName <- allSvgElements.toSeq.sorted // <- | |
} yield q""" | |
object ${Term.Name(elementName)} extends ElementFactory[${Type.Name("SVGElement")}] { | |
@inline protected def tagName = $elementName | |
} | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env amm | |
// This script converts Maven dependencies from a pom.xml to sbt dependencies. | |
// It is based on the answers of George Pligor and Mike Slinn on http://stackoverflow.com/questions/15430346/ | |
// - install https://github.com/lihaoyi/Ammonite | |
// - make this script executable: chmod +x PomDependenciesToSbt | |
// - run it with from your shell (e.g bash): | |
// $ ./PomDependenciesToSbt /path/to/pom.xml | |
import scala.xml._ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::io::{self, Write}; | |
use std::process::{exit, Command, Stdio}; | |
fn main() { | |
main_guarded().unwrap_or_else(|e| { | |
eprintln!("{}", e); | |
exit(1); | |
}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ config, pkgs, lib, ... }: | |
let | |
python = pkgs.python3Packages.python; | |
in | |
{ | |
systemd.services.thermonitor = { | |
description = "Thermonitor Daemon"; | |
serviceConfig = { | |
ExecStart = "/home/phi/thermonitor.py"; |