Skip to content

Instantly share code, notes, and snippets.

View vteial's full-sized avatar

Eialarasu vteial

View GitHub Profile
[Unit]
Description=Apache Tomcat Web Application Container
After=network.target
[Service]
Type=forking
Environment=JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid
Environment=CATALINA_HOME=/opt/tomcat
Unit]
Description=H2 Service
[Service]
User=root
WorkingDirectory=/root
ExecStart=/bin/bash /root/h2.sh
SuccessExitStatus=143
@vteial
vteial / h2-start.sh
Last active February 15, 2020 08:29
#!/bin/sh
/usr/bin/java -Xms64m -Xmx128m -cp /root/h2/bin/h2*.jar org.h2.tools.Server -webAllowOthers -tcpAllowOthers -ifNotExists
#!/usr/bin/env groovy
if (!args) {
println 'Usage: stacktraces.groovy <path/to/logfile>'
System.exit 0
}
class LogFile extends File {
String entryStartPattern
def regex = ~/\G(?:^|,)(?:"([^"]*+)"|([^",]*+))/
new File('path/to/file.csv').eachLine { line ->
def columns = []
def matcher = regex.matcher(line)
while (matcher.find()) {
columns << (matcher.group(1) ?: matcher.group(2))
}
println columns
}
def props = [:]
new File('path/to/some.properties').eachLine { line ->
if ((matcher = line =~ /^([^#=].*?)=(.+)$/)) {
props[matcher[0][1]] = matcher[0][2]
}
}
println props
@vteial
vteial / DReverseString.dart
Last active December 16, 2015 15:08
Reverse the content of the string using Java, Groovy JavaScript and Dart
// To live run use online dart console from here http://try.dartlang.org/
String reverseStringV0(String word) {
List<String> tokens = new List<String>();
tokens.addAll(word.split('').reversed);
return tokens.join('');
}
String reverseStringV1(String word) {
if(word.length == 0) {
@vteial
vteial / DReverseArrayTest.dart
Last active December 15, 2015 21:59
Reverse the contents of array using Java, Groovy, JavaScript and Dart
// To live run use online dart console from here http://try.dartlang.org/
List<int> reverseArray0(List<int> items) {
List<int> ritems = new List<int>();
ritems.addAll(items.reversed);
return ritems;
}
List<int> reverseArray1(List<int> items) {
List<int> ritems = new List<int>(items.length);
@vteial
vteial / StreamToString.java
Last active December 11, 2015 14:58
Code snippet to convert InputStream to String
import java.io.InputStream;
import java.net.URL;
import java.util.Scanner;
public class StreamToString {
public static void main(String[] args) throws Exception {
URL url = new URL("http://localhost:8080/learning-java/ping.java");
InputStream is = url.openStream();
String s = StreamToString.streamToString(is);