Skip to content

Instantly share code, notes, and snippets.

@nafg
nafg / some.scala
Last active September 9, 2019 14:21 — forked from suni-masuno/some.scala
class SomeClass {
private def get(url: String): Future[Option[String]] =
for {
serviceResponse <- sendGetRequest(url)
} yield maybeBody(url, serviceResponse)
private def maybeBody(url: String, response: HttpResponse[String]): String =
if (response.is2xx) Some(response.body)
else None
@nafg
nafg / install.sh
Last active October 20, 2016 23:32 — forked from wdullaer/install.sh
Install latest docker-compose on Ubuntu
# Install docker-compose
COMPOSE_VERSION=`git ls-remote https://github.com/docker/compose | grep refs/tags | grep -oP "[0-9]+\.[0-9]+\.[0-9]+$" | tail -n 1`
sudo sh -c "curl -L https://github.com/docker/compose/releases/download/${COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose"
sudo chmod +x /usr/local/bin/docker-compose
sudo sh -c "curl -L https://raw.githubusercontent.com/docker/compose/${COMPOSE_VERSION}/contrib/completion/bash/docker-compose > /etc/bash_completion.d/docker-compose"
@nafg
nafg / ClassWithDependency.csx
Last active August 29, 2015 14:27 — forked from mikehadlow/ClassWithDependency.csx
C#: Only Use Static Methods
public class Thing : IThing
{
public Thing(IDependency dependency) { }
public void Do(string arg) { }
}
@nafg
nafg / MintByDate.html
Created April 9, 2014 20:22 — forked from anonymous/MintByDate.html
View Mint transactions within a date range
<!DOCTYPE html>
<html><body>
<h1>Show Mint transactions within date range</h1>
<form action="https://wwws.mint.com/transaction.event" target="_blank" method="get">
<input type="date" id="s" onchange="document.getElementById('sd').value=this.value.replace(/(\d+)-(\d+)-(\d+)/,'$2/$3/$1')"/>
to
<input type="date" id="e" onchange="document.getElementById('ed').value=this.value.replace(/(\d+)-(\d+)-(\d+)/,'$2/$3/$1')"/>
<input type="hidden" name="startDate" id="sd"/><input type="hidden" name="endDate" id="ed"/>
<input type="submit"/>
</form>
class Config
abstract class Foo(implicit val config: Config)
class Bar(config: Config) extends Foo()(config) {
def doxxx = Obj.doStuff(1)
}
object Obj {
def doStuff(i: Int)(implicit config: Config) {}
abstract class Foo(config: Config) {
}
class Bar(config: Config) extends Foo(config) {
def doStuff = {
Obj.doStuff(1)
}
}
object Obj {