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 options {:a ["a" "b" "c"] :b "thingy" :c {"x" [1 2 3]}}) | |
(defn option-template | |
[options] | |
(for [[k v] options] | |
(case v | |
vector? (select-field k v) | |
map? (option-template v) | |
[:label v))) | |
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
// form.Make och form.Models är IEnumerable<string> | |
// one-liner vs flera | |
if (make != null) { | |
form.Makes = new List<string>(form.Makes ?? new List<string>()) { make }; | |
} | |
if (model != null) { | |
if (form.Models == null) { | |
form.Models = new List<string>(); | |
} |
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
import deck from Deck | |
from mock import Mock | |
# deck.Deck typ: | |
# from card import Card | |
# class Deck: | |
# | |
# def __init__(self): | |
# self.cards = [Card(x) for x in range(0, 52)] | |
# |
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
public interface IEmediateAd { | |
int ContentUnit { get; } | |
string Url { get; } | |
int Height { get; } | |
int Width { get; } | |
} | |
public class Loader { | |
public string Load(IEmediateAd ad) { |
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 test_game_kills_cell_if_not_two_or_three_neighbours: | |
c = Cell(neighbours=1) | |
c2 = Cell(neighbours=4) | |
game = GameOfLife() | |
game.decide_fate(c) | |
game.decide_fate(c2) | |
assert c.dead | |
assert c2.dead |
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
[HttpPost] | |
public ActionResult Login(LoginModel model) { | |
if (!ModelState.IsValid) { | |
return View(model); | |
} | |
if (UserValidator.IsValid(model)) { // USES REPOSITORY | |
FormsAuthentication.SetAuthCookie(model.Email, false); | |
var user = this.UserRepository.Get(model.Email); // USES IT AGAIN | |
BankIdValidator = new BankIdValidator(user, this.UserRepository); |
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
[Authorize] | |
[OutputCache(NoStore = false, Duration = 0, Location = OutputCacheLocation.None)] | |
public ActionResult AuthorizeBankId(string returnUrl) | |
{ | |
BankIdValidator = new BankIdValidator(this.CurrentUser, this.UserRepository); | |
var url = !String.IsNullOrEmpty(returnUrl) ? returnUrl : Url.Action("Index", "Home"); | |
if (this.CurrentUser.IsBankIDAuthorized) | |
{ | |
return Redirect(url); | |
} |
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
public interface IResult<T> { | |
bool Success { get; } | |
T Data { get; } | |
string Error { get; } | |
} | |
public class ErrorResult<T> : Result<T> { | |
public ErrorResult(string error) : base(null, false, error) { | |
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
public class AsdController : BaseController { | |
private IReader<Encrypted, SalesObject> Reader { get; private set; } | |
public AsdController(IReader<Encrypted, SalesObject> reader) { | |
Reader = reader; | |
if (base.UseCaching) { | |
Reader = new CachedReader<Encrypted, SalesObject>(Reader); | |
} | |
} |
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
GET /company/1 | |
{ | |
"Id": 1, | |
"Name": "Företaget", | |
"Resources": { | |
"Notes": "http://host/company/1/notes", | |
"Users": "http://host/company/1/users", | |
"Facilities": "http://host/company/1/facilities" | |
} |
NewerOlder