View gist:268add01dc4287553820
// is there a way to make this an awesome for comprehension or whatever? | |
// or maybe a built in Map method to do what I want? ;p | |
val codes: List[String] = ... | |
val configs: Map[String, Configuration] = ... | |
val defaultConfig: Configuration = ... | |
val config: Configuration = codes | |
.find(configs.contains) // find the first code that the configs map contains | |
.flatMap(configs.get) // grab the config for that first code |
View controller.js
angular.module('ymusica').controller('AlbumSearch', ['$scope', 'Albums', 'Artists', '$q', function($scope, albums, artists, $q) { | |
$scope.albums = []; | |
$scope.artists = []; | |
var terms = new Rx.Subject(); | |
$scope.searchMusic = terms.onNext.bind(terms); | |
terms.sample(250) |
View gist:4997793
## env.rb ## | |
PageObject.javascript_framework = :jquery | |
## login.rb ## | |
class LoginPage | |
include PageObject | |
## stuff for every page ## |
View gist:4956444
Imports System.Data.Entity | |
Imports System.ComponentModel.DataAnnotations | |
Imports System.ComponentModel.DataAnnotations.Schema | |
Public Class PartContext | |
Inherits DbContext | |
Public Sub New() | |
MyBase.New("Data Source=(local);Initial Catalog=TestDB;Trusted_Connection=True;") | |
End Sub |
View gist:2296834
var db = new PortalContext(); | |
var profile = new Profile() | |
{ | |
Id = 20, | |
FirstName = "Tyler", | |
LastName = "Durden" | |
}; | |
db.Entry(profile).State = EntityState.Modified; |
View gist:2011848
// scala | |
// adding interfaces to classes | |
trait Greetable { | |
def Greeting: String | |
} | |
def greet(g: Greetable): Unit = { | |
println(g.Greeting) | |
} |
View gist:1701339
var account = (function(startingBalance) { | |
var balance = startingBalance; | |
function getBalance() { | |
return balance; | |
} | |
function deposit(amount) { | |
balance += amount; |
View gist:1651135
[3,5].map { |n| n.step(max, n).to_a }.reduce(:|).reduce(0,:+) |
View gist:1276743
type Greeting = () => String | |
def greet(g: Greeting) = { | |
println(g()) | |
} | |
def hello() = { "hello from Huey" } | |
greet(hello) // >> "hello from Huey" |
View gist:1257990
EXPR="$(cat | sed 's/\\/\\\\/g' | sed 's/\"/\\\"/g')" | |
export SHELL_NAME=${SHELL_NAME:="FSharp Interactive"} | |
export SHELL_INTERPRETER=${SHELL_INTERPRETER:="fsi"} | |
osascript << END | |
tell application "Terminal" | |
activate | |
set _foundTab to false |