Skip to content

Instantly share code, notes, and snippets.

Espen Herseth Halvorsen Espenhh

  • Bekk Consulting
  • Oslo
Block or report user

Report or block Espenhh

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:9e915e68c2483fce13d203cb8a94cdac
### Keybase proof
I hereby claim:
* I am espenhh on github.
* I am espenhh (https://keybase.io/espenhh) on keybase.
* I have a public key ASCfqeGuidGjUaMb5hBKERUNWyuZKy6u3Rt5NRF8GHjBYgo
To claim this, I am signing this object:
View gist:d4445656650fd586321149fa06f5cc3e
### Keybase proof
I hereby claim:
* I am espenhh on github.
* I am espenhh (https://keybase.io/espenhh) on keybase.
* I have a public key ASCfqeGuidGjUaMb5hBKERUNWyuZKy6u3Rt5NRF8GHjBYgo
To claim this, I am signing this object:
@Espenhh
Espenhh / gist:7305254
Created Nov 4, 2013
Fargelegger output rødt/gult for en vilkårlig kommando basert på warn/error i loggene
View gist:7305254
#/bin/bash
COMMAND="mvn run whatever kommandoen din for å kjøre er"
RED=$(echo -e '\033[41m\033[37m')
YELLOW=$(echo -e '\033[43m\033[37m')
NORMAL=$(echo -e '\033[0m')
$COMMAND | sed -e "s/.*WARN.*/$YELLOW&$NORMAL/" -e "s/.*ERROR.*/$RED&$NORMAL/"
@Espenhh
Espenhh / branch-blame.sh
Created Sep 29, 2012
Script that lists out all branches, how old they are, groups them by merged/notmerged, and "blames" who commited last
View branch-blame.sh
#!/bin/bash
# --------------------------- FUNCTIONS ---------------------------------
_line() {
printf %80s |tr " " "-"; echo ""
}
_info() {
echo -e 1>&2 "\033[32m"$@"\033[0m"
}
View gist:1193089
@Component
public class SignatureVerifikasjonsFilter implements ContainerRequestFilter {
@Override
public ContainerRequest filter(final ContainerRequest request) {
// Henter ut id'en brukeren utgir seg for å være
String userIdHeader = request.getHeaderValue"X-Vendor-Userid");
// Henter ut Bruker-objektet
View gist:1193067
public class ContentMD5VerifikasjonsFilter implements ContainerRequestFilter {
@Override
public ContainerRequest filter(final ContainerRequest request) {
try {
// Henter ut alle bytes fra requesten (payload)
byte[] entityBytes = IOUtils.toByteArray(request.getEntityInputStream()); // Apache commons
// Sjekker bare Content-MD5 dersom det er en request med payload
if (entityBytes.length > 0) {
String contentMD5Client = request.getHeaderValue("Content-MD5");
View gist:1193046
public class DatoVerifikasjonsFilter implements ContainerRequestFilter {
@Override
public ContainerRequest filter(final ContainerRequest request) {
String dato = request.getHeaderValue(Headers.Date);
if (dato != null) {
sjekkDato(dato);
} else {
// Kast feil - datoheader mangler!
}
View gist:1193029
POST
/path/to/resource
content-md5: Q2hlY2sgSW50YWdyaXR5IQ==
date: Wed, 29 Jun 2011 14:58:11 GMT
x-vendor-userid: 59829
param1=34&param2=lol
View gist:1193027
String stringToSign = uppercase(verb) + "\n" +
lowercase(path) + "\n" +
"content-md5: " + md5Header + "\n" +
"date: " + datoHeader + "\n" +
"x-vendor-userid: " + virksomhetsId + "\n" +
lowercase(urlencode(requestparametre)) + "\n";
View gist:1193013
public class MittResponseFilter implements ContainerResponseFilter {
@Override
public ContainerResponse filter(final ContainerRequest request, final ContainerResponse response) {
// Gjør det du vil med responsen
return response;
}
}
You can’t perform that action at this time.