Skip to content

Instantly share code, notes, and snippets.

@peterszatmary
peterszatmary / Dockerfile
Created October 24, 2016 19:56
Dockerfile focused on how to create properly regular user with Docker. elixir:latest image was used with this example.
FROM elixir:latest
# not root but rather work with regular user
RUN useradd -ms /bin/bash regularuser
USER regularuser
WORKDIR /home/regularuser/
EXPOSE 4000
# Run REPL
@peterszatmary
peterszatmary / test-hibernate.cfg.xml
Created October 24, 2016 20:00
Hibernate configuration xml file for testing with H2 in memory database.
<!--?xml version="1.0" encoding="UTF-8"?-->
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">org.h2.Driver</property>
<property name="hibernate.connection.username">sa</property>
<property name="hibernate.connection.password"></property>
<property name="hibernate.connection.url">jdbc:h2:mem:test</property>
<property name="hibernate.dialect">org.hibernate.dialect.H2Dialect</property>
<property name="show_sql">true</property>
@peterszatmary
peterszatmary / hibernate.cfg.xml
Created October 24, 2016 20:02
Hibernate configuration xml file for dev with MySQL database.
<!--?xml version="1.0" encoding="UTF-8"?-->
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">newlife</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/evidence_db</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">true</property>
@peterszatmary
peterszatmary / Application.java
Last active October 24, 2016 20:11
Example of writing functional java non blocking code with Play! framework 2.4. Results are in json format. For more see https://github.com/peterszatmary/play-service-one and https://github.com/peterszatmary/play-main-microservice-app
package controllers;
import com.google.inject.Inject;
import core.CalculationSystem;
import play.libs.F;
import play.libs.Json;
import play.mvc.Controller;
import play.mvc.Result;
import java.util.HashMap;
@peterszatmary
peterszatmary / GetAllThreads.java
Last active October 24, 2016 20:30
How to get all currently running threads in java.
public static Thread[] getThreads() {
Set<Thread> threadSet = Thread.getAllStackTraces().keySet();
return threadSet.toArray(new Thread[threadSet.size()]);
}
@peterszatmary
peterszatmary / Car.java
Last active October 25, 2016 20:08
Java 7 and java 8 working with collection comparision. How to use void functions to affect objects. Lombok used for Objects that represents datas.
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@NoArgsConstructor
@AllArgsConstructor
public @Data class Car {
private String type;
}
@peterszatmary
peterszatmary / linux-cheatsheet.sh
Last active July 26, 2017 13:36
Usefull linux commands for everyone
# for informations
sudo lshw # hardware informations to standard output
sudo lshw -html > hw.html # hardware informations to html file
sudo lshw -xml > hw.xml # hardware informations to xml file
lsb_release -a # information about your linux distribution
cat /proc/cpuinfo # informations about your CPU
lscpu # informations about your CPU
public class JavaQuestions {
public willCompileOrNot() {
https://www.github.com/peterszatmary/
System.out.println("will compile or not ?");
}
public void question1() {
System.out.println(null);
}
@peterszatmary
peterszatmary / StartingWithPlayFramework.txt
Created October 30, 2016 13:09
Notes about how to start with Play framework. Just few first steps.
- For Intelijj Idea install Scala plugin
- ./activator new # creates new application
- go to project folder
- ./activator run ( http://localhost:9000 )

JavaInTheory

Static and dynamic binding

  • Static binding happens at compile-time, dynamic binding at runtime.
  • Binding of private, static and final methods always happen at compile time since these methods cannot be overridden. Binding of overridden methods happen at runtime.
  • Java uses static binding for overloaded methods and dynamic binding for overridden methods.

Mix