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
diff --git a/src/OnboardingWebTests/ControllerTests/CompanyControllerTest.cs b/src/OnboardingWebTests/ControllerTests/CompanyControllerTest.cs | |
index e52a78a..01d9055 100644 | |
--- a/src/OnboardingWebTests/ControllerTests/CompanyControllerTest.cs | |
+++ b/src/OnboardingWebTests/ControllerTests/CompanyControllerTest.cs | |
@@ -1,6 +1,7 @@ | |
using System.IO; | |
using System.Linq; | |
using System.Web.Mvc; | |
+using Moq; | |
using NUnit.Framework; |
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
def lastModifiedDate(app: ApplicationInfo) = (new File(app.sourceDir)).lastModified() | |
val sortedApps = repository.all.sortWith(lastModifiedDate(_) > lastModifiedDate(_)) | |
VS | |
private List<ApplicationInfo> getApplicationsSortedByDate(List<ApplicationInfo> apps) { | |
Comparator<ApplicationInfo> dateComparator = new Comparator<ApplicationInfo>() { | |
public int compare(ApplicationInfo appInfo1, ApplicationInfo appInfo2) { | |
long date1 = new File(appInfo1.sourceDir).lastModified(); |
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
def createRemoteViews(): RemoteViews = { | |
val views = new RemoteViews(context.getPackageName(), R.layout.latest_apps) | |
views.removeAllViews(R.id.buttons) | |
dao.latestApps.take(4) foreach (appInfo => views.addView(R.id.buttons, createAppRemoteView(appInfo))) | |
views.setViewVisibility(R.id.buttons, android.view.View.VISIBLE) | |
return views | |
} |
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
package com.nevercertain.pro.latestapps | |
import android.content._ | |
import android.app._ | |
import android.appwidget._ | |
import android.util.Log | |
import java.util.Calendar | |
import java.text.SimpleDateFormat | |
import collection.JavaConversions._ |
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
package com.nevercertain.wifipasswords | |
import scala.collection.JavaConversions._ | |
object NetworkParser { | |
def parse(networksString: String): Seq[WifiNetwork]= { | |
val networkSections = networksString.split("network=").filter(_.trim.size > 0) | |
networkSections.map((networkSection: String) => { | |
val name = parseToken(networkSection, "ssid") |
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
val nums = List(10,21,23,35,40) | |
//signature of filter: def filter (p: (A) ⇒ Boolean) : Seq[A] | |
nums.filter(_ > 25) //List(35, 40) | |
nums.filter((x: Int) => (x % 5) == 0) //List(10,35,40) | |
def even(x: Int) = (x % 2) == 0 | |
nums.filter(even) //List(10,40) |
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
package com.nevercertain.wifipasswords | |
import org.scalatest.matchers.ShouldMatchers | |
import org.scalatest.Spec | |
class NetworkParserSpecs extends Spec with ShouldMatchers { | |
val singleNetwork = """ | |
network={ | |
ssid="Futurama" | |
psk="Bite my shiny metal ass" |
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
package com.nevercertain.wifipasswords | |
import org.scalatest.matchers.ShouldMatchers | |
import org.scalatest.Spec | |
class WifiNetworkSpecs extends Spec with ShouldMatchers { | |
describe("comparing a network") { | |
it("should be equal to a network whose name differs only in case") { | |
val network1 = new WifiNetwork("R", "111", NetworkType.OPEN) | |
val network2 = new WifiNetwork("r", "111", NetworkType.OPEN) |
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
package com.nevercertain.wifipasswords | |
import org.scalatest.matchers.ShouldMatchers | |
import org.scalatest.Spec | |
class NetworkParserSpecs extends Spec with ShouldMatchers { | |
it("should create a WEP network with the expected password") { | |
val wepNetwork = """ | |
network={ | |
ssid="joes wifi" |
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
trait Ordered[A] { | |
def compare(that: A): Int | |
def < (that: A): Boolean = (this compare that) < 0 | |
def > (that: A): Boolean = (this compare that) > 0 | |
def <= (that: A): Boolean = (this compare that) <= 0 | |
def >= (that: A): Boolean = (this compare that) >= 0 | |
} | |
} | |
class Person(val name: String) extends Ordered[Person] { |