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
| --[[ | |
| detect.lua — distinguish UTF-8 from Shift-JIS | |
| Strategy (three layers): | |
| 1. Grammar validation | |
| Parse the byte stream under each encoding's formal rules. | |
| A single invalid byte or sequence is decisive: the string | |
| cannot belong to that encoding. |
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
| #!/bin/sh | |
| # Put in gitconfig: | |
| # [alias] | |
| # bvd = difftool -d -x bettervimdiff | |
| dirA="$1" | |
| dirB="$2" | |
| if ! [ -d "$dirA" -a -d "$dirB" ]; then | |
| echo 'Usage: bettervimdiff DIR1 DIR2' >&2 | |
| exit 1 | |
| fi |
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
| import java.net.*; | |
| import java.io.*; | |
| import org.java_websocket.server.*; | |
| import org.java_websocket.*; | |
| import org.java_websocket.handshake.*; | |
| public class Main extends WebSocketServer { | |
| public static final int PORT = Integer.getInteger("port", 3141); |
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
| import java.lang.reflect.Field; | |
| import java.nio.ByteBuffer; | |
| public class Main { | |
| private static final int N = 1_000_000; | |
| private static Field stringBytes; | |
| private static String testString; | |
| static { | |
| // setup test string: |