Skip to content

Instantly share code, notes, and snippets.

View patoi's full-sized avatar
👀
...

István Pató patoi

👀
...
View GitHub Profile
@patoi
patoi / SwiftStateMachine.swift
Last active April 30, 2021 05:06
Swift State machine
//: # State machine: handling three state and transition
import GameplayKit
class RetrievingDataState: GKState {
override func isValidNextState(stateClass: AnyClass) -> Bool {
print("\n---> \(stateClass) class")
return (stateClass == DataAvailableState.self) || (stateClass == DataNotAvailableState.self)
}
@maxsap
maxsap / CustomJwtTokenStore
Last active April 10, 2020 08:55
Spring Security OAuth2 programmatic configuration.
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.apache.commons.lang3.SerializationUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.jwt.JwtHelper;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.common.OAuth2RefreshToken;
import org.springframework.security.oauth2.common.exceptions.InvalidTokenException;
@rvillars
rvillars / README.md
Last active February 25, 2020 09:26
[Angular Translate Bunlde] Spring bundle based translations (i18n) for AngularJS applications with angular-translate

angular-translate with Spring bundles

Synopsis

AngularJS itself doesn't provide any features to translate the texts of your application to different languages and switching the language right on the page. Fornutalty there is now another open-source project called angular-translate that implements the needed functionalities.

AnularJS proposes a technologiy where as much as possible application behevior is exeuted on the client (the browser). So it makes sense to hold translated texts clientside and enrich the static templates with the transalted texts there.

Spring message bundles in the opposite are a collection of serverside key=value files that hold the translated texts each for one language. A well known and widly used pattern.

@patoi
patoi / haproxy.cfg
Created January 21, 2020 15:16
haproxy configuration: SSL termination of the local server – haproxy running in docker container
# If you already have an haproxy.cfg file, you can probably leave the
# global and defaults section as-is, but you might need to increase the
# timeouts so that long-running CLI commands will work.
global
ssl-default-bind-options ssl-min-ver TLSv1.2
ssl-default-bind-ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256
maxconn 4096
# log stdout local0 debug
defaults
@patoi
patoi / gist:79f35edc05e73f423db12fd8ef64158f
Last active January 21, 2020 15:22 — forked from yuezhu/gist:47b15b4b8e944221861ccf7d7f5868f5
Generate self-signed certificate for HAProxy
# Generate a unique private key (KEY)
sudo openssl genrsa -out mydomain.key 2048
# Generating a Certificate Signing Request (CSR)
sudo openssl req -new -key mydomain.key -out mydomain.csr
# Creating a Self-Signed Certificate (CRT)
openssl x509 -req -days 365 -in mydomain.csr -signkey mydomain.key -out mydomain.crt
# Append KEY and CRT to mydomain.pem
@franciscopreller
franciscopreller / gist:8427264
Last active April 15, 2019 15:07
AngularJS authentication service which communications with an AspNet Identity Back End running Web API 2.
'use strict';
angular.module('ngApp')
.factory('AuthenticationService', ['$rootScope', '$cookieStore', 'Restangular', '$http', '$q', '$location',
function ($rootScope, $cookieStore, Restangular, $http, $q, $location) {
var UserModel = {
// Set default user state
FROM node:8-alpine
# the client version we will download from bumpx repo
ENV CLIENT_FILENAME instantclient-basic-linux.x64-12.1.0.1.0.zip
# work in this directory
WORKDIR /opt/oracle/lib
# take advantage of this repo to easily download the client (use it at your own risk)
ADD https://github.com/bumpx/oracle-instantclient/raw/master/${CLIENT_FILENAME} .
@patoi
patoi / start_testing_java8_today.asciidoc
Last active February 28, 2018 11:44 — forked from aslakknutsen/start_testing_java8_today.asciidoc
Example of how to use both JDK 7 and JDK 8 in one build.

JDK 8 Released

Most of us won’t be able to use/deploy JDK 8 in production for a looong time. But that shouldn’t stop us from using it, right?

It should be possible to sneak in JDK 8 in the back way, the same way we snuck in Groovy and other libraries we wanted to use.

The Test Suite to the rescue

The Maven compiler plugin run in two separate lifecycles, compile and testCompile. Those can be configured separately.

@magnetikonline
magnetikonline / README.md
Last active November 10, 2017 14:36
Enable a daily SSD TRIM operation for Ubuntu 12.04+.

SSD TRIM support for Ubuntu 12.04+

Steps to add a daily SSD TRIM task to your Ubuntu system (tested with 12.04+) which will run via anacron with logging of the trim process to /var/log/fstrimall.log.

Note: if you have previously enabled TRIM support for your mounted drive(s) using the discard option within /etc/fstab you will want to remove this option and re-mount your drives first ($ mount -a).

  • Install scripts

    $ sudo wget \

https://gist.github.com/magnetikonline/8190599/raw/fstrimall.sh \

@patoi
patoi / SwiftComponentsAndEntities.swift
Created October 11, 2015 08:14
Swift Components and Entities
//: Playground - noun: a place where people can play
import GameplayKit
class ShootingComponent: GKComponent {
let power: Int
init(power: Int) {
self.power = power