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
| final private static CharSequenceTranslator quotes = buildAggregateTranslator(Mode.ENT_QUOTES); | |
| final private static CharSequenceTranslator noquotes = buildAggregateTranslator(Mode.ENT_NOQUOTES); | |
| private static AggregateTranslator buildAggregateTranslator(Mode mode) { | |
| Map<CharSequence, CharSequence> map = new HashMap<>(); | |
| if (mode == Mode.ENT_QUOTES) { | |
| map.put("\"", """); // " - double-quote | |
| map.put("'", "'"); // ' - apostrophe | |
| } |
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
| #!/usr/bin/env bash | |
| set -e | |
| # Java process ID | |
| PID="$(pgrep java)" | |
| # convert `ps -o etime` output format to second | |
| function psetime_converter() { | |
| echo "$(cat -)" | awk ' |
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
| #!/usr/bin/awk -f | |
| BEGIN { FS = ":" } | |
| { | |
| if (NF == 2) { | |
| print $1*60 + $2 | |
| } else if (NF == 3) { | |
| split($1, a, "-"); | |
| if (a[2] != "" ) { | |
| print ((a[1]*24+a[2])*60 + $2) * 60 + $3; | |
| } else { |
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 sax; | |
| import org.xml.sax.Attributes; | |
| import org.xml.sax.ErrorHandler; | |
| import org.xml.sax.SAXException; | |
| import org.xml.sax.SAXParseException; | |
| import org.xml.sax.XMLReader; | |
| import org.xml.sax.helpers.DefaultHandler; | |
| import java.io.File; |
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
| const tunes = document.querySelectorAll('audio'); | |
| tunes.forEach((e, i) => e.onended = () => tunes[i + 1].play()); |
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
| document.body.querySelectorAll('h1, h2, h3, h4, h5, h6').forEach((e) => { | |
| e.innerHTML = `<a href="#${e.getAttribute("id")}">${e.innerHTML}<a>`; | |
| }); |
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
| const socketio = require('socket.io-client') | |
| const socket = socketio('http://localhost:8888'); | |
| socket.on('update', d => console.log(d)); | |
| socket.on('dynamo', d => console.log(d)); | |
| // socket.on('connect', function(){}); | |
| // socket.on('event', d => console.log(d)); | |
| // socket.on('disconnect', function(){}); |
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.io.File | |
| object TrainSampleWithScala extends App { | |
| def train() { | |
| val parameter: Parameter = new Parameter(SolverType.AVERAGE, 10) | |
| val model: PerceptronModel = PerceptronModel.train(docs, parameter) | |
| return model | |
| } |
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
| #include <sys/types.h> | |
| #include <sys/stat.h> | |
| #include <stdio.h> | |
| #include <unistd.h> | |
| #include <fcntl.h> | |
| int main() { | |
| int fd; | |
| char buf[2]; | |
| fd = open("filename.txt", 2); |
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
| #include <stdio.h> | |
| #include <ctype.h> | |
| #include <stdarg.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| static char *p; | |
| static char func[26][100]; | |
| __attribute__((noreturn)) static void error(char *fmt, ...) { |