Skip to content

Instantly share code, notes, and snippets.

View heathermiller's full-sized avatar

Heather Miller heathermiller

View GitHub Profile
@heathermiller
heathermiller / try-transform.scala
Created June 27, 2012 15:46
Try.transform implementation
/** Completes this `Try` by applying the function `f` to this if this is of type `Failure`, or conversely, by applying
* `s` if this is a `Success`.
*/
def transform[U](f: Throwable => Try[U], s: T => Try[U]): Try[U] = this match {
case Success(v) => s(v)
case Failure(e) => f(e)
}

Scala Project & Developer Guidelines

These guidelines are meant to be a living document that should be changed and adapted as needed. We encourage changes that make it easier to achieve our goals in an efficient way.

General Workflow

This is the process for committing code to the Scala project. There are of course exceptions to these rules, for example minor changes to comments and documentation, fixing a broken build etc.

  1. Make sure you have signed the Scala CLA, if not, sign it.
  2. Before starting to work on a feature or a fix, it's good practice to ensure that:
@heathermiller
heathermiller / EdnPickleFormat.scala
Created June 11, 2013 20:09
A sample simplified edn PickleFormat for Scala Pickling. That's right, transfer data to a Clojure app! (Edn stands for "extensible data notation" and is Clojure's data transfer format.)
import scala.pickling._
import scala.reflect.runtime.universe._
import scala.util.parsing.json._
import scala.collection.mutable.{StringBuilder, Stack}
package object edn {
implicit val pickleFormat: EdnPickleFormat = new EdnPickleFormat
}
[info] Loading project definition from /grader/project
[info] Set current project to grader (in build file:/grader/)
[info] Updating {file:/grader/}parprog1...
[info] Resolving org.scala-lang#scala-library;2.11.7 ...

[info] Resolving ch.epfl.lamp#scala-grading-runtime_2.11;0.3 ...

[info] Resolving org.scala-lang.modules#scala-pickling_2.11;0.10.0 ...

[info] Resolving org.scala-lang#scala-compiler;2.11.4 ...
⌘ ~/Dropbox/git-shared/moocs (master) sbt
[info] Loading project definition from /Users/hmiller/Dropbox/git-shared/moocs/project
[info] Set current project to root (in build file:/Users/hmiller/Dropbox/git-shared/moocs/)
>
>
> parprog1/gradeLocal scalashop
[error] Expected configuration
[error] Expected ':' (if selecting a configuration)
[error] Expected key
[error] Expected '::'
@heathermiller
heathermiller / gist:61882184ffdd6433cc23
Created February 22, 2016 18:15
createHandout issue
⌘ ~/Dropbox/git-shared/moocs/courses/progfun1/target/patmat (master) sbt
[info] Loading project definition from /Users/hmiller/Dropbox/git-shared/moocs/courses/progfun1/target/patmat/project
[info] Set current project to progfun1-patmat (in build file:/Users/hmiller/Dropbox/git-shared/moocs/courses/progfun1/target/patmat/)
> compile
[info] Compiling 2 Scala sources to /Users/hmiller/Dropbox/git-shared/moocs/courses/progfun1/target/patmat/target/scala-2.11/classes...
[error] /Users/hmiller/Dropbox/git-shared/moocs/courses/progfun1/target/patmat/src/main/scala/patmat/Huffman.scala:117: not found: type ???
[error] def until(xxx: ???, yyy: ???)(zzz: ???): ??? = ???
[error] ^
[error] /Users/hmiller/Dropbox/git-shared/moocs/courses/progfun1/target/patmat/src/main/scala/patmat/Huffman.scala:117: not found: type ???
[error] def until(xxx: ???, yyy: ???)(zzz: ???): ??? = ???
@heathermiller
heathermiller / broked.txt
Created February 25, 2016 12:57
courseraprogramming broked
⌘ ~/Desktop courseraprogramming grade local "mah-image.tar" submission
WARNING:py.warnings:/Library/Python/2.7/site-packages/docker/utils/utils.py:591: UserWarning: docker.utils.create_host_config() is deprecated. Please use Client.create_host_config() instead.
'docker.utils.create_host_config() is deprecated. Please use '
WARNING:py.warnings:/Library/Python/2.7/site-packages/requests/packages/urllib3/util/ssl_.py:315: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#snimissingwarning.
SNIMissingWarning
WARNING:py.warnings:/Library/Python/2.7/site-packages/requests/packages/urllib3/util/ssl_.py:120: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may
@heathermiller
heathermiller / fiddle-error.scala
Last active February 29, 2016 09:53
Scala Fiddle error
ScalaFiddle.scala:13: error: constructor cannot be instantiated to expected type;
found : (T1, T2)
required: String
else for (((color, func), i) <- graphs) {
^
ScalaFiddle.scala:14: error: Any does not take parameters
val y = func(x/w * 75) * h/40 + h/count * (i+0.5)
^
ScalaFiddle.scala:14: error: type mismatch;
found : Double(0.5)
@heathermiller
heathermiller / url-disaster
Created March 1, 2016 21:32
url-disaster
--------------------------------------------------------------------------------
Grader output:
================================================================================
{
"fractionalScore": 0.06,
"feedback": "Your overall score for this assignment is 0.65 out of 10.00\n\n\nThe code you submitted did not pass all of our tests: your submission achieved a score of\n0.65 out of 10.00 in our tests.\n\nIn order to find bugs in your code, we advise to perform the following steps:\n - Take a close look at the test output that you can find below: it should point you to\n the part of your code that has bugs.\n - Run the tests that we provide with the handout on your code.\n - The tests we provide do not test your code in depth: they are very incomplete. In order\n to test more aspects of your code, write your own unit tests.\n - Take another very careful look at the assignment description. Try to find out if you\n misunderstood parts of it. While reading through the assignment, write more tests.\n\nBe
@heathermiller
heathermiller / romains-stdout
Created March 3, 2016 15:11
Romain's stdout
{
"fractionalScore": 0.00,
"feedback": "Your overall score for this assignment is 0.00 out of 10.00\n\n\nThe code you submitted did not pass all of our tests: your submission achieved a score of\n0.00 out of 10.00 in our tests.\n\nIn order to find bugs in your code, we advise to perform the following steps:\n - Take a close look at the test output that you can find below: it should point you to\n the part of your code that has bugs.\n - Run the tests that we provide with the handout on your code.\n - The tests we provide do not test your code in depth: they are very incomplete. In order\n to test more aspects of your code, write your own unit tests.\n - Take another very careful look at the assignment description. Try to find out if you\n misunderstood parts of it. While reading through the assignment, write more tests.\n\nBelow you can find a short feedback for every individual test that failed.\n\n======== LOG OF FAILED TESTS ========\nYour solution achieved a testing score of 0 out of 150.\n\nBel