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 State { | |
public static boolean someState; | |
} | |
class GoodTest { | |
@Test | |
public void checkState() { | |
assertFalse(State.someState); | |
} |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Label</key> | |
<string>com.judepereira.keyremapping</string> | |
<key>ProgramArguments</key> | |
<array> | |
<string>/usr/bin/hidutil</string> | |
<string>property</string> |
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 String escapeString(Object o) { | |
if (o == null) { | |
return null; | |
} | |
String str = o.toString(); | |
if (str.contains("\\")) { | |
str = str.replace("\\", "\\\\"); | |
} | |
if (str.contains("\"")) { | |
str = str.replace("\"", "\\\""); |
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
private static final ObjectMapper OM = new ObjectMapper(); | |
public static String escapeString(Object o) { | |
if (o == null) { | |
return null; | |
} | |
try { | |
// The string is automatically quoted. Therefore, return a new string that | |
// doesn't contain those quotes (since the caller appends quotes themselves). | |
val bytes = OM.writeValueAsBytes(o.toString()); |
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
private static final ObjectMapper OM = new ObjectMapper(); | |
private static final String STR = "hello world - the quick brown fox jumps over " | |
+ "the lazy dog\r\n\r\nand here's " | |
+ "a random slash\\, and some \"s"; | |
@Benchmark | |
public void jsonStringSerialization(final Blackhole blackhole) throws Exception { | |
byte[] obj = OM.writeValueAsBytes(STR); | |
blackhole.consume(new String(obj, 1, obj.length - 2, StandardCharsets.UTF_8)); | |
} |
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
private static final ObjectMapper OM = new ObjectMapper(); | |
@Benchmark | |
public void jsonStringSerialization(final Blackhole blackhole) throws Exception { | |
byte[] obj = OM.writeValueAsBytes(randomString()); | |
blackhole.consume(new String(obj, 1, obj.length - 2, StandardCharsets.UTF_8)); | |
} | |
@Benchmark | |
public void jsonStringManual(final Blackhole blackhole) { |
OlderNewer