Skip to content

Instantly share code, notes, and snippets.

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

István Pató patoi

👀
...
View GitHub Profile
@patoi
patoi / gist:11284658
Created April 25, 2014 10:20
SSH commands
PUSH:
* tar cvf - . | gzip -c -1 | ssh user@host cat ">" remotefile.gz
* ssh target_address cat <localfile ">" remotefile
* ssh target_address cat <localfile - ">" remotefile
* cat localfile | ssh target_address cat ">" remotefile
@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;
@kamermans
kamermans / configure_docker0.sh
Last active April 26, 2024 00:58
Change the IP subnet of Docker's docker0 interface
#!/bin/sh -e
#
# NOTE: Since Docker 1.10 (February 4, 2016), it has been possible to configure the
# Docker daemon using a JSON config file. On Linux, this file is normally located at
# /etc/docker/daemon.json. You should use this JSON config method if you are running
# a version of Docker that is at least 1.10!
# Here is an example configuration that sets the docker0 bridge IP to 192.168.254.1/24:
# {
# "bip": "192.168.254.1/24"
# }
@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)
}
@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
@patoi
patoi / RuleSystem.swift
Last active August 16, 2017 18:38
Playing with GameplayKit rule system 1.
//: Check divisible by 3 and 5 with GameplayKit Rule System
import GameplayKit
let divisibleBy3Rule = GKRule(blockPredicate: { system in
(system.state["value"] as! Int) % 3 == 0
}, action: { system in
system.assertFact("divisibleBy3and5", grade: 0.5)
system.assertFact("divisibleBy3", grade: 1)
})
@patoi
patoi / resource_alloc_docker.md
Created April 28, 2016 09:52 — forked from afolarin/resource_alloc_docker.md
Resource Allocation in Docker

#Container Resource Allocation Options in docker-run You have various options for controlling resources (cpu, memory, disk) in docker. These are principally via the docker-run command options.

##Dynamic CPU Allocation -c, --cpu-shares=0
CPU shares (relative weight, specify some numeric value which is used to allocate relative cpu share)

##Reserved CPU Allocation

@yuezhu
yuezhu / gist:47b15b4b8e944221861ccf7d7f5868f5
Created February 7, 2018 18:10
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
@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.

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} .