$ rails g model User
belongs_to
has_one
| #! /usr/bin/env python | |
| """ Convert values between RGB hex codes and xterm-256 color codes. | |
| Nice long listing of all 256 colors and their codes. Useful for | |
| developing console color themes, or even script output schemes. | |
| Resources: | |
| * http://en.wikipedia.org/wiki/8-bit_color | |
| * http://en.wikipedia.org/wiki/ANSI_escape_code |
| #!/bin/sh | |
| ### | |
| # SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer) | |
| # For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos | |
| ### | |
| # Alot of these configs have been taken from the various places | |
| # on the web, most from here | |
| # https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx |
After scouring the internet and piece-mealing together the correct way to do this, here is a step-by-step, all-in-one-place guide to making logback STFU when running your unit tests.
Save the following as logback-test.xml under src/test/resources:
<configuration>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%msg%n</pattern>| import java.security.MessageDigest | |
| import java.util | |
| import javax.crypto.Cipher | |
| import javax.crypto.spec.SecretKeySpec | |
| import org.apache.commons.codec.binary.Base64 | |
| /** | |
| * Sample: | |
| * {{{ | |
| * scala> val key = "My very own, very private key here!" |
| (function(d) { | |
| d.open(); | |
| d.write('<textarea id="input" spellcheck="false" style="flex:1;height:100%;resize:none;outline:none;font:15px monospace;color:#fff;background:#111;padding:10px;"><html>\n<head></head>\n<body>\nClick here to render\n</body>\n</html></textarea>'); | |
| d.write('<iframe id="iframe" style="flex:1;height:100%;"></iframe>'); | |
| d.close(); | |
| var s = d.body.style; | |
| s.display = 'flex'; | |
| s.margin = 0; | |
| var i = d.getElementById('input'); |
Miles Sabin recently opened a pull request fixing the infamous SI-2712. First off, this is remarkable and, if merged, will make everyone's life enormously easier. This is a bug that a lot of people hit often without even realizing it, and they just assume that either they did something wrong or the compiler is broken in some weird way. It is especially common for users of scalaz or cats.
But that's not what I wanted to write about. What I want to write about is the exact semantics of Miles's fix, because it does impose some very specific assumptions about the way that type constructors work, and understanding those assumptions is the key to getting the most of it his fix.
For starters, here is the sort of thing that SI-2712 affects:
def foo[F[_], A](fa: F[A]): String = fa.toStringThis is a bash script, as an example, on how to do click-testing GUI based on finding components based on how they look.
| import monix.eval.Task | |
| import monix.execution.Scheduler | |
| import scala.util.control.NonFatal | |
| /** Evaluates the given non-strict value on a given | |
| * `Scheduler`, meant for expensive I/O. | |
| * | |
| * NOTE: the returned task is not cancelable. In this | |
| * instance you wouldn't gain anything by it. | |
| */ |
Copyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.
A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.
val square : Int => Int = x => x * x