Skip to content

Instantly share code, notes, and snippets.

To make all future files world-readable by default, add this line to ~/.bashrc:

umask 022

Then, to make everything under ~/foo world-readable:

source ~/.bashrc
abstract class Maybe<A> {
Maybe() { }
abstract A toNullableReference();
}
final class Just<A> extends Maybe<A> {
private final A value;
import com.typesafe.config.ConfigParseOptions;
import com.typesafe.config.ConfigResolveOptions;
public class ConfigFactoryParameters
{
public static ConfigFactoryParameters defaultConfigFactoryParameters()
{
return new ConfigFactoryParameters(
Thread.currentThread().getContextClassLoader(),
ConfigParseOptions.defaults(),

Scala operator precedence rules

The precedence of an operator is determined by its first character.

Characters in increasing order of priority precedence

  • All letters
  • |
  • ^
  • &amp;
final class EqualsEquivalence<A>
implements Equivalence<A>
{
@Override
public boolean equals(A a, A b)
{
return a.equals(b);
}
@Override
chris@esteban:~$ ping t-square.gatech.edu
PING t-square.gatech.edu (74.125.21.138) 56(84) bytes of data.
64 bytes from clients6.google.com (74.125.21.138): icmp_req=1 ttl=44 time=74.2 ms
64 bytes from clients6.google.com (74.125.21.138): icmp_req=2 ttl=44 time=77.1 ms
64 bytes from clients6.google.com (74.125.21.138): icmp_req=3 ttl=44 time=75.6 ms
64 bytes from clients6.google.com (74.125.21.138): icmp_req=4 ttl=44 time=144 ms
^C
--- t-square.gatech.edu ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 74.261/92.864/144.420/29.783 ms
trait Correctness {
// Let's talk about programs.
type P
// A specification is a predicate on a program.
trait S { def apply (p: P): Boolean }
// We say "p implements s" when a program meets a specification.
def `p implements s` (p: P, s: S) = s (p)
@chris-martin
chris-martin / comments-on-scala-syntax-by-ruud-vlaming.md
Last active December 26, 2015 17:49
Post by Ruud Vlaming, on October 20, 2013, on the Coursera discussion forums for Martin Odersky's "Functional Programming Principles in Scala" class. Copied with permission.

Questions on the syntax (style) of Scala

With a new language, a new syntax comes along. Personally, i find the syntax often harder to learn then methodology. Now, i know syntax is to large extend a matter of taste, about which you cannot really discuss. But it is possible to ask (preferably the language designer) why certain choices were made, and if not alternatives would be better. So here i go, (in random order):

  1. Pattern matching: the casing of the variable determines its meaning. Ever since (the early days of) Fortran (yes, i am that old) we know this is a

Where do the little libraries belong?

 

There is a program we ask of Java programmers in interviews sometimes, just as an initial sanity check to make sure the candidate really knows the language:

“Write a method that accepts a List and returns a copy of the list with duplicate elements removed.”

It’s mostly just a test of whether they know how to use a hash set. Ignoring order, all we’re looking for is: