aspe:keyoxide.org:O6EPBCN4MXZQBGKHCP5QA3S53Q
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
#!/bin/bash | |
[ $# != 1 ] && echo "expects exactly one arg" && exit 1 | |
if branch_name=$(git symbolic-ref --short -q HEAD) ; then | |
new_end="$1" | |
branch_name="${branch_name%/*}/$new_end" | |
git checkout -b "$branch_name" | |
else | |
echo "not on any branch" && 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
#!/usr/bin/env amm | |
import $ivy.`com.lihaoyi::ammonite-ops:2.4.0` | |
import ammonite.ops._ | |
import scala.collection.immutable.ArraySeq | |
import scala.util.control.NoStackTrace | |
object Abort extends Throwable("unable to process inputs") with NoStackTrace |
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
import scala.util.matching.Regex | |
object Impl { | |
sealed trait WConfAnyFilterable { | |
type Result = WConfFilterable with WConfCompletable | |
@annotation.inline | |
private[this] def quote(literal: String): String = Regex.quote(literal) | |
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
_rwhich_1() { | |
readlink -e "$(command -v "$1")" | |
} | |
_rwhich_comp() { | |
mapfile -t COMPREPLY < <(compgen -c "${COMP_WORDS[COMP_CWORD]}") | |
return 0 | |
} | |
# recursively resolve commands ("recursive `which`") | |
rwhich() { |
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
private final class SingleUse[R](resource: => R) { | |
private val used = new AtomicBoolean(false) | |
def useWith[A](f: R => A)(implicit r: Using.Resource[R]): A = | |
if (used.getAndSet(true)) throw new IllegalStateException("resource has already been used") | |
else Using.resource(resource)(f) | |
} | |
final class Using[R, A] private[Using](resource: SingleUse[R], op: R => A) { | |
private def use0()(implicit r: Resource[R]): A = resource.useWith(op) |
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
scala> class Foo { | |
| def p1[A, B](t: (A, B)): (Option[A], Option[B]) = { | |
| val (e1, e2) = t | |
| (Some(e1), Some(e2)) | |
| } | |
| def p2[A, B](t: (A, B)): (Option[A], Option[B]) = { | |
| (Some(t._1), Some(t._2)) | |
| } | |
| } | |
defined class Foo |
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 User(id: User.Id, firstName: User.FirstName, lastName: User.LastName, email: User.Email) | |
object User { | |
opaque type Id = Long | |
object Id { | |
def apply(value: Long): Id = value | |
implicit class Ops(val self: Id) extends AnyVal { | |
def value: Long = self | |
} |
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
ProxyRequests Off | |
ProxyPreserveHost On | |
<VirtualHost *:80> | |
ServerName example.com | |
RedirectPermanent / https://example.com/ | |
</VirtualHost> | |
<VirtualHost *:443> | |
SSLEngine on |
Regarding Project Euler problem 59
The problem contains one correct statement, which is that
For unbreakable encryption, the key is the same length as the plain text message, and the key is made up of random bytes.
Assuming that the bytes are actually random, there is said to be 'perfect secrecy' - the ciphertext reveals no information (other than length, obviously) about the plaintext. However, this approach has several problems, which will be covered below.
The problem goes on to say that, "[u]nfortunately, this method is impractical for most users," (yup) "so the modified method is to use a password as a key." (NO. BAD. VERY BAD. NONONONO)
NewerOlder