Skip to content

Instantly share code, notes, and snippets.

View corneil's full-sized avatar

Corneil du Plessis corneil

View GitHub Profile
@corneil
corneil / gist:ffc00dc23060d002a866
Created August 29, 2015 19:35
Verifying that +corneil is my blockchain ID. https://onename.com/corneil
Verifying that +corneil is my blockchain ID. https://onename.com/corneil
@corneil
corneil / log
Created March 15, 2016 15:28
Scripted attack
198.245.55.60 - - [15/Mar/2016:15:22:02 +0000] "GET / HTTP/1.1" 302 499 "-" "Python-urllib/2.7"
198.245.55.60 - - [15/Mar/2016:15:22:04 +0000] "GET / HTTP/1.1" 401 3970 "-" "Python-urllib/2.7"
198.245.55.60 - - [15/Mar/2016:15:22:04 +0000] "GET /script HTTP/1.1" 302 511 "-" "Python-urllib/2.7"
198.245.55.60 - - [15/Mar/2016:15:22:05 +0000] "GET /script HTTP/1.1" 401 3970 "-" "Python-urllib/2.7"
198.245.55.60 - - [15/Mar/2016:15:22:07 +0000] "GET /jenkins/script HTTP/1.1" 302 527 "-" "Python-urllib/2.7"
198.245.55.60 - - [15/Mar/2016:15:22:08 +0000] "GET /jenkins/script HTTP/1.1" 401 3970 "-" "Python-urllib/2.7"
198.245.55.60 - - [15/Mar/2016:15:22:08 +0000] "GET /login HTTP/1.1" 302 509 "-" "Python-urllib/2.7"
198.245.55.60 - - [15/Mar/2016:15:22:09 +0000] "GET /login HTTP/1.1" 401 3970 "-" "Python-urllib/2.7"
198.245.55.60 - - [15/Mar/2016:15:22:10 +0000] "GET /jmx-console HTTP/1.1" 302 521 "-" "Python-urllib/2.7"
198.245.55.60 - - [15/Mar/2016:15:22:11 +0000] "GET /jmx-console HTTP/1.1" 401 3970 "-" "Python
@corneil
corneil / removeUnresolvedDeps.groovy
Created July 13, 2017 14:59
Groovy script to remove 'unresolved' dependencies from local Maven Repository
import groovy.io.FileType
def showOnly = true
def repoHome = new File(System.getProperty('user.home'), '.m2/repository')
def searchFolders = []
args.each { arg ->
if(arg == '-s') {
showOnly = true
} else if(arg == '-d') {
showOnly = false
} else {
@corneil
corneil / stack-trace.log
Created June 25, 2018 13:01
stack-trace
java.lang.NullPointerException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
at com.sun.proxy.$Proxy148.getLockModeType(Unknown Source)
at org.springframework.data.jpa.repository.support.QueryDslJpaRepository.createQuery(QueryDslJpaRepository.java:180)
at org.springframework.data.jpa.repository.support.QueryDslJpaRepository.findAll(QueryDslJpaRepository.java:101)
@corneil
corneil / CrudMethodMetadataPostProcessor.java
Last active July 2, 2018 16:21
differences in getResource
public Object getTarget() throws Exception {
MethodInvocation invocation = ExposeInvocationInterceptor.currentInvocation();
return TransactionSynchronizationManager.getResource(invocation.getMethod()); // this call has different parameter.
}

Keybase proof

I hereby claim:

  • I am corneil on github.
  • I am corneil (https://keybase.io/corneil) on keybase.
  • I have a public key ASDB40W4Wve9epF06pwJoXAKLcK4H5ivgHUjJsOct3FAlAo

To claim this, I am signing this object:

@corneil
corneil / pom.xml
Last active July 25, 2019 06:17
Kotlin Maven Dependencies and plugins
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.neo4j.examples</groupId>
<artifactId>sdn5-movies</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
@corneil
corneil / kotlin-compare.kt
Last active August 4, 2019 09:13
Kotlin extension function to use in compareTo when sorting requires multiple items.
inline fun <T> T.ifZero(exp: Int, block: T.() -> Int): Int = if (exp == 0) block() else exp
// using
data class User(
val firstName: String,
val lastName: String,
val dateOfBirth: Date
) : Comparable<User> {
// classic comparator.
@corneil
corneil / kotlin-get-required.kt
Last active August 3, 2019 21:34
A Kotlin expression function to get a required value from a map alternatively throw an IllegalArgumentException like require
inline fun <K, V> Map<K, V>.getRequired(key: K): V = this.get(key) ?: throw IllegalArgumentException("$key not found in $keys")
fun main() {
val aMap = mapOf("a" to 1, "b" to 2, "c" to 3)
val anA = aMap.get("a") ?: error("a not found in ${aMap.keys}")
// while line reads easier
val guaranteedB = aMap.getRequired("b")
@corneil
corneil / if-apply.kt
Last active August 3, 2019 21:32
Kotlin extension functions to provide logic in association with same behaviour as apply
inline fun <T> T.ifApply(expression: Boolean, block: T.() -> Unit, otherwise: T.() -> Unit) : T {
return if(expression) {
this.apply(block)
} else {
this.apply(otherwise)
}
}
inline fun <T> T.ifApply(expression: Boolean, block: T.() -> Unit) : T {
if(expression) {