Skip to content

Instantly share code, notes, and snippets.

View banterCZ's full-sized avatar

Luboš Račanský banterCZ

View GitHub Profile
@banterCZ
banterCZ / CustomUIServlet.java
Created August 2, 2016 08:48
Vaadin Servlet
import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.cdi.server.VaadinCDIServlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
/**
* PM custom Vaadin servlet.
* <p>Vaading config <code>productionMode</code> is set by default to <code>true</code>.
import java.time.Clock;
import java.time.LocalTime;
public class TimeMachine {
private LocalTime from = LocalTime.MIDNIGHT;
private LocalTime until = LocalTime.of(6, 0);
private Clock clock = Clock.systemDefaultZone();
@banterCZ
banterCZ / monitoring_user.sql
Created October 6, 2016 15:17
sqlplus / as sysdba
CREATE USER MONITORING IDENTIFIED BY password;
GRANT CREATE SESSION TO MONITORING;
GRANT SELECT any dictionary MONITORING;
GRANT SELECT ON V_$SYSSTAT TO MONITORING;
GRANT SELECT ON V_$INSTANCE TO MONITORING;
GRANT SELECT ON V_$LOG TO MONITORING;
GRANT SELECT ON SYS.DBA_DATA_FILES TO MONITORING;
GRANT SELECT ON SYS.DBA_FREE_SPACE TO MONITORING;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.By;
public class JTSK {
private double x;
private double y;
public JTSK(double x, double y) {
this.x = x;
this.y = y;
}
@banterCZ
banterCZ / SPeL.java
Created June 15, 2017 07:33
SPeL and propety placeholder using default value
/**
* Optional property <code>myApp.node-name</code>, hostname otherwise.
*/
@Value("#{'${myApp.node-name:}'?:T(java.net.InetAddress).getLocalHost().getHostName()}")
private String nodeName;
@banterCZ
banterCZ / filter_reduce.clj
Last active July 5, 2017 21:08
Get me the average age of the older than 50. (def ages [55 20 75])
(= 65
(/
(reduce + (filter #(> % 50) ages))
(count (filter #(> % 50) ages))
)
)
import javax.annotation.PostConstruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
/**
@banterCZ
banterCZ / data.json
Created September 20, 2017 12:27
JSON filter (no order), test at http://jsonpath.com/
{
"traceId": "491a1826-0fa1-46d8-970d-704027a2548b",
"code": "validation.error",
"message": "Validation failed",
"errors": [
{
"attributeCode": "firstName",
"messageCode": "validation.empty"
},
{
public class SecureRandomTest {
public static void main(String[] args) {
System.out.println("SecureRandom Test");
final SecureRandom random = new SecureRandom(); // Default: Win - SHA1PRNG, Linux/maxOS - NativePRNG
// final SecureRandom random = SecureRandom.getInstance("NativePRNGNonBlocking");
System.out.println("Algorithm: " + random.getAlgorithm());
for (int i = 0; i < 100; i++) {
System.out.print('.');
final byte[] seed = random.generateSeed(2 * 8);
}