Skip to content

Instantly share code, notes, and snippets.

@EugenyB
EugenyB / java11-maven.xml
Created February 27, 2019 16:07
Java 11 support by maven-compiler-plugin
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
import java.io.File
import kotlin.math.sqrt
fun main(args: Array<String>) {
val (K, L) = File("rect.in").bufferedReader().readLine().split(" ").map(String::toInt)
val b = 2 * K - L
val d = 1.0*b * b - 4 * K
val x1 = ((-b - sqrt(d)) / 2).toInt()+1
@EugenyB
EugenyB / javafx.cfg
Created January 2, 2019 18:34
javafx for jdk11 VM options
--module-path "c:\Program files\Java\javafx-sdk-11\lib" --add-modules=javafx.controls,javafx.fxml
@EugenyB
EugenyB / CommonUtils.java
Created November 8, 2018 22:17
Redirect with get
package util;
import java.io.IOException;
import java.io.Serializable;
import javax.enterprise.context.ApplicationScoped;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.inject.Named;
@EugenyB
EugenyB / pom.xml
Last active September 24, 2018 20:45
Tomcat + Speedment
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.company</groupId>
<artifactId>tomcatspeedment</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
@EugenyB
EugenyB / context.xml
Created August 18, 2018 19:31
webapp-mysql maven (pom.xml) and context (webapp->META-INF->context.xml)
<Context>
<Resource name="jdbc/test1"
auth="Container"
type="javax.sql.DataSource"
username="username"
password="password"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/test1"
maxTotal="8"
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';
FLUSH PRIVILEGES;
@EugenyB
EugenyB / web.xml
Created March 26, 2018 18:48
Example of empty web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
</web-app>
#include <iostream>
using namespace std;
struct node {
int key;
node *left;
node *right;
};
void chooseSort(int a[], int size){
for(int i=0; i < size-1; i++){
int nmin = i;
for(int j=i+1; j<size; j++){
if(a[j]<a[nmin])nmin = j;
}
if(i != nmin){
int t = a[nmin];
a[nmin] = a[i];
a[i] = t;