Skip to content

Instantly share code, notes, and snippets.

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

István Pató patoi

👀
...
View GitHub Profile
@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 / 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)
}
@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"
# }
@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;
@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
@joshlong
joshlong / gist:10964238
Created April 17, 2014 08:23
Register this EmbeddedServletContainerCustomizer @bean in a Spring Boot application to customize the embedded Tomcat instance. In particular, this sets up SSL support for the container. I quite like this because it uses Java 8 lambas to nice effect. No finals, no anonymous inner classes. it just... works.
@Bean
EmbeddedServletContainerCustomizer containerCustomizer(
@Value("${keystore.file}") Resource keystoreFile,
@Value("${keystore.pass}") String keystorePass) throws Exception {
String absoluteKeystoreFile = keystoreFile.getFile().getAbsolutePath();
return (ConfigurableEmbeddedServletContainer container) -> {
if (container instanceof TomcatEmbeddedServletContainerFactory) {
@aslakknutsen
aslakknutsen / start_testing_java8_today.asciidoc
Last active May 10, 2024 20:15
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.

@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
@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 \

@wsargent
wsargent / docker_cheat.md
Last active August 31, 2023 12:10
Docker cheat sheet