Skip to content

Instantly share code, notes, and snippets.

View varnerac's full-sized avatar

Andrew Varner varnerac

View GitHub Profile
@varnerac
varnerac / sample.txt
Created May 16, 2017 23:12
Sample Text for ColaSec RegEx Class
Hello World. I hope you are okay. What in the world is going on with you?
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras blandit sed leo eget efficitur. Sed vitae lectus dolor. Sed eget elit in ipsum mattis posuere sed ut ex. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Sed hendrerit tortor risus, sed congue justo dapibus at. Suspendisse ullamcorper id lacus ut viverra. Quisque quis lacinia mauris, a suscipit velit. In hac habitasse platea dictumst. Vestibulum porttitor mollis lectus, non vulputate magna condimentum quis. Maecenas vitae iaculis velit, et elementum leo.
This is some information about Jesse:
Name: Jesse Cornelius James
Email: [email protected]
Phone #: 803-555-1212
Phone #: (803) 555-1212
@varnerac
varnerac / ProtoReflection.scala
Created October 19, 2016 16:18
Attempt to Instantiate Protobuf Companion Object from Name (String)
def getProtoCompanionClass(protoName: String): Option[GeneratedMessageCompanion[_]] = {
try {
val protoClassSymbol = currentMirror.staticClass(protoName)
val protoCompanionObjectSymbol = protoClassSymbol.companion.asModule
Some(currentMirror.reflectModule(protoCompanionObjectSymbol).instance.asInstanceOf[GeneratedMessageCompanion[_]])
} catch {
case _: ScalaReflectionException => None
}
}
-module(mailinglist).
-export([test/0]).
handle([Head | _] = _List) when is_list(Head) ->
list_of_lists;
handle(_List) ->
not_a_list_of_lists.
test() ->
list_of_lists = handle([[1,2,3], [a, b, c]]),
%% Map keys known at compile-time
%% No boilerplate code or parse transform for record -> JSON
%% Matching on map keys in function signatures, not possible with proplists
%% JSONFrags = [#{...}, #{...}, #{...},
process_layers(JSONFrags) -> process_layers(JSONFrags, #{}).
process_layers([], Result) ->
jsx:encode(Result).
process_layers([#{<<"key">> := <<"value">>} | Rest], Result) ->