This file contains hidden or 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
new HashMap<Integer, Integer>().put(value, Optional.fromNullable(actual.get(value)).or(0) + 1); |
This file contains hidden or 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
package javax.jmdns.test; | |
import java.net.DatagramPacket; | |
import java.net.InetAddress; | |
import java.util.Enumeration; | |
import java.util.logging.ConsoleHandler; | |
import java.util.logging.Level; | |
import java.util.logging.LogManager; | |
import java.util.logging.Logger; |
This file contains hidden or 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 static <T> void jsonRoundTripTest(final T instance) throws Exception { | |
final String clazz = instance.getClass().getName(); | |
final String fixtureName = instance.getClass().getSimpleName().toLowerCase(); | |
final String fixture = jsonFixture("fixtures/" + fixtureName + ".json"); | |
assertThat(clazz + " bad json,", | |
asJson(instance), | |
is(fixture)); | |
T deserialized; | |
try { | |
deserialized = fromJson(fixture, (Class<T>)instance.getClass()); |
This file contains hidden or 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
-module(gol). | |
-include_lib("eunit/include/eunit.hrl"). | |
next(World) -> | |
sets:fold(fun(Member, Result) -> | |
Count = sets:size(live_neighbours(Member, World)), | |
case Count of | |
2 -> | |
sets:add_element(Member, Result); | |
_ -> |
This file contains hidden or 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
if(leftImage != null) | |
{ | |
leftImage = leftImage.toLowerCase(); | |
} | |
if(leftImage.equals("null")) | |
{ | |
leftImage = null; | |
} | |
// ... repeated for 5 different string variables |
This file contains hidden or 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
System.err.println(new PriorityQueue<Integer>(Arrays.asList(3, 1, 2))); | |
// Prints: [1, 3, 2] | |
System.err.println(new TreeSet<Integer>(Arrays.asList(3, 1, 2))); | |
// Prints: [1, 2, 3] | |
/* | |
This is due to PriorityQueue's Iterator. From the javadoc: | |
"...Iterator provided in method iterator() is not guaranteed to | |
traverse the elements of the priority queue in any particular order...". |
This file contains hidden or 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 riak { | |
$configbase = "/etc/riaksearch" | |
$riak_dir = "/var/lib/riaksearch" | |
$username = "riak" | |
package { "riak-search": ensure => latest, } | |
user { $username: | |
shell => '/bin/bash', | |
comment => 'Basho Riak', |
This file contains hidden or 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
#set($path=$param0.replace("::", "=")) | |
#set($space=$renderContext.getOriginalContext().getSpaceKey()) | |
#if($space.equals("PRIVATE")) | |
#set($domain="http://your.internal.url") | |
#else | |
#set($domain="http://your.public.url") | |
#end | |
#set($url="${domain}${path}") |
This file contains hidden or 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
-module(a). | |
-export([tgif/0]). | |
-define(MUSIC_ASSOCIATIONS, [{ellnestam, "Love Gun"}, {jockeholm, "Family Affair"}, {mahnve, "My name is (Slim Shady)"}]). | |
tgif() -> tgif(?MUSIC_ASSOCIATIONS). | |
tgif([{Person, Track}|Others]) -> | |
io:format("@~w plays '~s'~n", [Person, Track]), | |
tgif(Others); | |
tgif([]) -> "Hey! It's friday, have a beer!". |
This file contains hidden or 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
# Copy the accept header to a variable | |
set $acceptHeader $http_accept; | |
# Does the request end in xml or json? | |
if ($uri ~ ^(.*)\.(xml|json)$) { | |
# Create a new accept header... | |
set $acceptHeader "application/$2"; | |
# ...and remove the extension from the path | |
rewrite ^(.*)\.(xml|json)$ $1 last; | |
} |