Skip to content

Instantly share code, notes, and snippets.

darsen

Block or report user

Report or block darsen

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@darsen
darsen / TestController.cs
Created Mar 25, 2016
Send complex objects to .Net Web Api through URL using FromUri attribute
View TestController.cs
namespace FromUri.Controllers
{
using System;
using System.Web.Http;
/// <summary>
/// Url sample call:
/// http://localhost:50872/api/test?key.org=abc&key.dest=123&key.when=2010-01-01T00:00:00&foo=1&bar=bbbrr&foobar.foo=2&foobar.bar=xyz
/// </summary>
View AsyncTest.swift
import XCTest
class AsyncTests: XCTestCase {
func testExample() {
//set expectaton
let expectation = expectationWithDescription("Swift Expectations")
let url = NSURL(string: "http://www.stackoverflow.com")
let request = NSURLRequest(URL: url!)
NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.mainQueue()) {
@darsen
darsen / CustomTextField.swift
Created Aug 6, 2015
Custom TextField in swift
View CustomTextField.swift
import Foundation
import UIKit
class CustomTextField: UITextField, UITextFieldDelegate{
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.delegate = self
}
@darsen
darsen / SampleJavKoan.java
Created Jul 13, 2015
Sample Java Code Koan
View SampleJavKoan.java
@Koan
public void localTime () {
LocalTime t1 = LocalTime.of(7,30);
assertEquals(t1, LocalTime.parse(__));
}
@darsen
darsen / SimpleJava8Lambda.java
Last active Dec 16, 2017
Java Simple Lambda Koan
View SimpleJava8Lambda.java
interface Caps {
public String capitalize(String name);
}
@Koan
public void simpleLambda() {
Caps caps = (String n) -> {
return n.toUpperCase();
};
String capitalized = caps.capitalize("James");
@darsen
darsen / Money.js
Last active Dec 17, 2015
Using Jasmine and custom matchers to check object equality.
View Money.js
function Money(amount, currency){
this.amount = amount;
this.currency = currency;
this.sum = function (money){
return new Money(200, "CLP");
}
}
@darsen
darsen / AddtionTest.java
Last active Dec 14, 2015
Parameterized tests in JUnit Parameterized tests in JUnit can be very useful when writing tests based on tabular data. These type of tests can save you from writing a lot of duplicate or boilerplate code. While there is a fair amount of articles on the subject on the Internet, I wasn’t able to find a code sample that you can simply copy into you…
View AddtionTest.java
package com.empoweragile;
import static org.junit.Assert.assertEquals;
import java.util.Arrays;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
You can’t perform that action at this time.