Skip to content

Instantly share code, notes, and snippets.

View banterCZ's full-sized avatar

Luboš Račanský banterCZ

View GitHub Profile
@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 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 / 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>.
@banterCZ
banterCZ / Dispatcher.groovy
Last active January 29, 2016 10:28
"Because Groovy dispatches by the runtime type, the specialized implementation of oracle(String) is used in the second case." "Wherever there’s a Java API that uses the static type Object, this code effectively loses the strength of static typing. ... This is why the Java type concept is called weak static typing" Source: Groovy in Action Second…
def oracle(Object o) { return 'object' }
def oracle(String o) { return 'string' }
Object x = 1
Object y = 'foo'
assert 'object' == oracle(x)
assert 'string' == oracle(y)
########################################################
#
# Check certificates inside a java keystore
#
########################################################
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True)]
[string]$keystore,
@banterCZ
banterCZ / feature_branches.py
Created September 15, 2015 08:23
A Mercurial extension used to with features branches
"""commands for working with feature branches
feature_branches is a Mercurial extension used to with features branches."""
from mercurial import util, commands, merge
def close_feature(ui, repo, node, **opts):
"""Close a feature branch (e.g. fb-123) and merge it to default."""
branch = "fb-" + node
close_branch(branch, ui, repo, node, **opts)
@banterCZ
banterCZ / script.groovy
Last active April 28, 2016 14:11
Soap UI WS mock script
def request = mockRequest.requestContent
log.info "CA Request: $request"
def payload = new XmlSlurper().parseText(request)
def csr = "${payload.Body.issueCertificate.paramIn.pkcs10}"
def temp = File.createTempFile('temp', '.csr')
temp.deleteOnExit()
temp.write(csr)
@banterCZ
banterCZ / pom.xml
Last active August 29, 2015 14:23
How to keep war clean
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<id>enforce-banned-dependencies</id>
<goals>
<goal>enforce</goal>
</goals>
import javax.enterprise.context.SessionScoped;
import java.io.Serializable;
import java.util.concurrent.atomic.AtomicInteger;
@SessionScoped
public class Counter implements Serializable {
private AtomicInteger count = new AtomicInteger(0);
public void increase() {
var binding = new BasicHttpBinding {AllowCookies = true};
using (var svc = new ServiceReference1.MyWSClient(binding, new EndpointAddress("http://localhost:8080/myApp/myWS")));