Skip to content

Instantly share code, notes, and snippets.

Avatar

Georgios Andrianakis geoand

View GitHub Profile
@thomasdarimont
thomasdarimont / readme.md
Created Feb 23, 2018
Wait for HTTP Service to become available with timeout (bash)
View readme.md
timeout 40s /bin/bash -c "while ! httping -qc1 http://somehost:8080/app ; do sleep 1 ; done; echo OK" || echo TIMEOUT

If the service cannot be reached within 40s then TIMEOUT will be printed otherwise OK.

@joshlong
joshlong / DynamicIntegration.kt
Last active Jan 6, 2018
Dynamic registration of Spring Integration adapters using functional bean definition with the Spring Framework 5.0 Kotlin DSL.
View DynamicIntegration.kt
package com.example.feed
import com.rometools.rome.feed.synd.SyndEntry
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.builder.SpringApplicationBuilder
import org.springframework.context.support.beans
import org.springframework.core.io.UrlResource
import org.springframework.integration.dsl.IntegrationFlows
import org.springframework.integration.feed.dsl.Feed
import org.springframework.integration.handler.GenericHandler
@fitzoh
fitzoh / SpringCloudGatewayApplication.java
Created Sep 7, 2017
Canary deploys with spring-cloud-gateway (2.0.0-M1)
View SpringCloudGatewayApplication.java
@EnableGateway
@SpringBootApplication
public class SpringCloudGatewayApplication {
private final String cookieName = "beta_active";
private final String headerName = "X-Beta-active";
private final String betaActiveValue = "true";
/**
* They're in the beta if they have a cookie or request header set
@jeffsheets
jeffsheets / ApiSecurityConfig.groovy
Created Sep 6, 2017
Spock Test for Spring Boot Security configuration - showing basic simple examples for unauthenticated users, role based access, and httpBasic logins
View ApiSecurityConfig.groovy
@EnableWebSecurity
class ApiSecurityConfig extends WebSecurityConfigurerAdapter {
@Inject
void configureGlobal(AuthenticationManagerBuilder auth) {
auth.inMemoryAuthentication()
.withUser('svc_acct').password('somePassword').roles('FULL_ACCESS')
}
@Override
protected void configure(HttpSecurity http) {
@rgl
rgl / wait_for_http_200.sh
Last active Oct 24, 2020
Wait for an HTTP endpoint to return 200 OK with Bash and curl
View wait_for_http_200.sh
bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:9000)" != "200" ]]; do sleep 5; done'
# also check https://gist.github.com/rgl/c2ba64b7e2a5a04d1eb65983995dce76
View splitted_xml_slurping.groovy
// Example of using StAX to split a large XML document and parse a single element using XmlSlurper
import javax.xml.stream.XMLInputFactory
import javax.xml.stream.XMLStreamReader
import javax.xml.transform.Transformer
import javax.xml.transform.TransformerFactory
import javax.xml.transform.sax.SAXResult
import javax.xml.transform.stax.StAXSource
def url = new URL("http://repo2.maven.org/maven2/archetype-catalog.xml")
@oza
oza / SparkOnYARN.md
Last active Nov 19, 2019
How to run Spark on YARN with dynamic resource allocation
View SparkOnYARN.md

YARN

  1. General resource management layer on HDFS
  2. A part of Hadoop

Spark

  1. In memory processing framework

Spark on YARN

@cy6erGn0m
cy6erGn0m / merge-maps.kt
Created May 20, 2015
Merge two maps with custom reduce function for Kotlin
View merge-maps.kt
private fun <K, V> Map<K, V>.mergeReduce(other: Map<K, V>, reduce: (V, V) -> V = { a, b -> b }): Map<K, V> {
val result = LinkedHashMap<K, V>(this.size() + other.size())
result.putAll(this)
other.forEach { e ->
val existing = result[e.key]
if (existing == null) {
result[e.key] = e.value
}
else {
@staltz
staltz / introrx.md
Last active Oct 27, 2020
The introduction to Reactive Programming you've been missing
View introrx.md
@timyates
timyates / Collate.java
Last active May 30, 2016
Implementing Groovy's collate method in Java 8 Streams
View Collate.java
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/* Efficiency must be questioned
*
* Also, no error checking, so could go infinite if called with dodgy params
*
* (left as an exercise for the reader) ;-)
You can’t perform that action at this time.