Skip to content

Instantly share code, notes, and snippets.

View fkirc's full-sized avatar

fk fkirc

  • Austria
View GitHub Profile
@fkirc
fkirc / git_repo_to_zip.sh
Created September 23, 2019 14:09
git repo to zip
#!/usr/bin/env bash
set -x
set -e
usage() {
echo "Usage: $0 <output name> <git repo path>"
exit 1
}
[[ $# -eq 2 ]] || {
@fkirc
fkirc / InputStreamToString.java
Last active July 3, 2019 11:15
Java (JDK only): Efficiently convert InputStream to String
private static String inputStreamToString(final InputStream is) throws IOException {
final InputStreamReader ir = new InputStreamReader(is, "UTF-8");
final StringBuilder sb = new StringBuilder();
final char[] buf = new char[1024];
int n;
while ((n = ir.read(buf)) != -1) {
sb.append(buf, 0, n);
}
return sb.toString();
}