View Example.cs
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 Example | |
{ | |
public enum States { One, Two } | |
public interface IExampleMessage | |
{ | |
} | |
public class OneMessage : IExampleMessage | |
{ |
View GoogleStyle.xml
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
<code_scheme name="GoogleStyle"> | |
<option name="USE_SAME_INDENTS" value="true" /> | |
<option name="IGNORE_SAME_INDENTS_FOR_LANGUAGES" value="true" /> | |
<option name="OTHER_INDENT_OPTIONS"> | |
<value> | |
<option name="INDENT_SIZE" value="2" /> | |
<option name="CONTINUATION_INDENT_SIZE" value="4" /> | |
<option name="TAB_SIZE" value="2" /> | |
<option name="USE_TAB_CHARACTER" value="false" /> | |
<option name="SMART_TABS" value="false" /> |
View regex
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
integer: | |
-?\+?(\d+(\d*_\d*)*\d+|\d+) | |
float: | |
-?\+?((\d+(\d*_\d*)*\d+|\d+)(\.(\d+(\d*_\d*)*\d+|\d+))?(([eE]-?\+?(\d+(\d*_\d*)*\d+|\d+))?)) |
View Examples.java
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 static GuavaOptionalPattern.caseNone; | |
import static GuavaOptionalPattern.caseSome; | |
import static IntegerPattern.caseOf; | |
import static OrRelsePattern.orElse; | |
import static PatternMatching.match; | |
import com.google.common.base.Optional; | |
public class Examples { | |
public String matchInteger(int x) { |
View Injectable Mixins
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
class MyInjectable() { | |
val myString = "my String" | |
} | |
trait MyTrait { | |
@Inject | |
val myInjectable: MyInjectable = null // Initialize to null so that it isn't abstract and will be injected by guice. Is there a better way to do this though? | |
} | |
class MyObject extends Controller with MyTrait {} |
View gist:7493793
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 getNearby(avatarId: UUID, radius: Double) = Action.async { | |
Avatar.getById(avatarId).flatMap { | |
case Some(avatar) => avatar.location match { | |
case Some(location) => AvatarService.findAvatarsNearLocation(location, radius).map {nearby => Ok(Json.toJson(nearby))} | |
case None => Future.successful(NotFound) | |
} | |
case None => Future.successful(NotFound) | |
} | |
} |
View gist:7362881
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
it("should deserialize a List of a case class") { | |
case class InListCaseClass(id: Long) | |
val paramTypes = Array(objectMapper.getTypeFactory().constructSimpleType(classOf[InListCaseClass], | |
Array.empty[JavaType])) | |
val listType = objectMapper.getTypeFactory.constructSimpleType(classOf[List[InListCaseClass]], paramTypes) | |
val value = List(InListCaseClass(2), InListCaseClass(5)) | |
val json = """"[{"id":2},{"id":5"}]"""" |
View ApacheLogParser.java
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 java.io.BufferedReader; | |
import java.io.FileReader; | |
import java.io.IOException; | |
import java.text.ParseException; | |
import java.text.SimpleDateFormat; | |
import java.util.HashMap; | |
import java.util.regex.Matcher; | |
import java.util.regex.Pattern; | |
public class ApacheLogParser { |
View Preconditions.cs
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 Preconditions | |
{ | |
/// <summary> | |
/// Ensures that an object reference passed as a parameter to the calling method is not null. | |
/// </summary> | |
/// <param name="reference">an object reference</param> | |
/// <param name="errorMessage">the exception message to use if the check fails</param> | |
/// <returns>the non-null reference that was validated</returns> | |
/// <exception cref="NullReferenceException">if reference is null</exception> | |
public static T CheckNotNull<T>(T reference, string errorMessage) |