Skip to content

Instantly share code, notes, and snippets.

View spencergibb's full-sized avatar

Spencer Gibb spencergibb

View GitHub Profile
@spencergibb
spencergibb / keybase.md
Created October 24, 2014 20:12
Keybase proof

Keybase proof

I hereby claim:

  • I am spencergibb on github.
  • I am spencergibb (https://keybase.io/spencergibb) on keybase.
  • I have a public key whose fingerprint is 23A8 EEDC F705 1B82 314F 44EE D204 4CC7 2D43 E641

To claim this, I am signing this object:

@spencergibb
spencergibb / Test.java
Last active August 29, 2015 14:16
underscores in domains and java's URI class
import java.net.URI;
public class Test {
public static void main(String[] args) {
String r = "http://user:password@foo_bar:8761/eureka/apps";
URI uri = URI.create(r);
System.out.println(uri.getHost());
// prints null
}
}
@spencergibb
spencergibb / hystrix-force-open.md
Last active September 22, 2020 11:03
Force a Spring Cloud Hystrix circuit to open

Want to know the behavoir of your app if a Hystrix Circuit is open?

Run with the circuit open

Run your spring cloud app with -Dhystrix.command.<circuitKeyName>.circuitBreaker.forceOpen=true

<circuiktKeyName> is the name of you hystrix circuit. If you used @HystrixCommand it is the name of the method. If you used @HystrixCommand(commandKey="mykey") is is the value of the commandKey attribute.

Dynamically force open the circuit

@spencergibb
spencergibb / DummyController.java
Created April 23, 2015 20:21
DummyController.java
package com.example.web;
import com.example.common.CustomRemoteEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.ApplicationContext;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@spencergibb
spencergibb / fortunes.txt
Last active August 29, 2015 14:23
Fortunes
"People are naturally attracted to you.",
"You learn from your mistakes... You will learn a lot today.",
"If you have something good in your life, don't let it go!",
"What ever you're goal is in life, embrace it visualize it, and for it will be yours.",
"Your shoes will make you happy today.",
"You cannot love life until you live the life you love.",
"Be on the lookout for coming events; They cast their shadows beforehand.",
"Land is always on the mind of a flying bird.",
"The man or woman you desire feels the same about you.",
"Meeting adversity well is the source of your strength.",
import httplib
from twisted.web import server, resource
from twisted.internet import reactor, endpoints
class Health(resource.Resource):
isLeaf = True
def render_GET(self, request):
request.setHeader("content-type", "application/json")
package io.spring.oscon.authserver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;
spring:
oauth2:
sso:
home:
secure: false
path: /env
client:
accessTokenUri: http://localhost:9999/uaa/oauth/token
userAuthorizationUri: http://localhost:9999/uaa/oauth/authorize
clientId: acme
#!/bin/bash
APP_NAME=$1
APP_NAME="$(tr '[:lower:]' '[:upper:]' <<< ${APP_NAME:0:1})${APP_NAME:1}"
APP_NAME=${APP_NAME}App
PKG_NAME="io.spring.oscon.$1"
CMD="curl https://start.spring.io/starter.tgz -d applicationName=$APP_NAME -d artifactId=$1 -d name=$1 -d packageName=$PKG_NAME -d baseDir=$1 -d dependencies=$2"
echo "Executing $CMD | tar -xf -"
$CMD | tar -xf -
"main@1" prio=5 tid=0x1 nid=NA runnable
java.lang.Thread.State: RUNNABLE
at org.springframework.cloud.netflix.feign.FeignClientsConfiguration.feignDecoder(FeignClientsConfiguration.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java:-1)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1123)