Skip to content

Instantly share code, notes, and snippets.

@wojda
wojda / SecurityConfig
Created October 16, 2014 21:54
Spring Security - Java config
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.annotation.web.servlet.configuration.EnableWebMvcSecurity;
@Configuration
@EnableWebMvcSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter{
@wojda
wojda / login.html
Created October 16, 2014 21:58
Updated HTML Thymeleaf login page. Prepared to Spring Security
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
<title>Login page</title>
</head>
<body>
<h1>Login page</h1>
<p th:if="${loginError}">Wrong user or password</p>
<form th:action="@{/login}" method="post">
<label for="username">Username</label>:
@wojda
wojda / LocalDateTimeToStringConverter.java
Created October 16, 2014 22:08
LocalDateTime java8 MongoDB converter (Spring Data Mongo)
import org.springframework.core.convert.converter.Converter;
import java.time.LocalDateTime;
public class LocalDateTimeToStringConverter implements Converter<LocalDateTime, String> {
@Override
public String convert(LocalDateTime localDateTime) {
return localDateTime.toString();
}
@wojda
wojda / java8_installation
Created October 17, 2014 23:34
How to install java8 on external serwe, for example openshift
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u25-b17/jdk-8u25-linux-x64.tar.gz
tar -zxf jdk-8u25-linux-x64.tar.gz
export PATH=$OPENSHIFT_DATA_DIR/jdk1.8.0_25/bin:$PATH
export JAVA_HOME="$OPENSHIFT_DATA_DIR/jdk/jdk1.8.0_25"
@wojda
wojda / sources.scala.txt
Last active August 29, 2015 14:11
Scala knowledge sources
* http://scalakata.com/index
* https://github.com/lauris/awesome-scala
* https://github.com/scalatron/scalatron/blob/master/Scalatron/doc/markdown/Scalatron%20Tutorial.md
//Video
* https://skillsmatter.com/conferences/1948-scala-exchange-2014#skillscasts
* "Code Reviews Gems" - https://skillsmatter.com/skillscasts/5848-code-reviews-gems
* "Cake Pattern: The Bakery from the Black Lagoon" [https://www.youtube.com/watch?v=yLbdw06tKPQ]
//Blog
+Navigation
* https://medium.com/@andrey_cheptsov/top-20-navigation-features-in-intellij-idea-ed8c17075880
@wojda
wojda / flatButton
Created February 19, 2015 22:12
The simplest way to create flat button. HTML+CSS
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>How to create flat button - the simplest way</title>
<style>
.flatButton {
height: 50px;
width: 150px;
@wojda
wojda / gist:60ba3b77c1c320e7638f
Created March 27, 2015 08:09
Count tables rows in MySQL.
SELECT table_name, table_rows
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = 'schem_name';
@wojda
wojda / DynamicScala
Created April 12, 2015 10:40
Scala FTW
import scala.language.dynamics
class MyDynamicClass extends Dynamic {
private val fields = scala.collection.mutable.Map("foo" -> "1", "bar" -> 2)
def selectDynamic(fieldName: String) = fields.get(fieldName)
def addField(field: (String, String)) = fields += field
}
val dynamic = new MyDynamicClass()
dynamic.foo
dynamic.addField("wtf" -> "THIS IS SCALA!")
@wojda
wojda / 0_reuse_code.js
Created October 18, 2015 17:22
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console