Skip to content

Instantly share code, notes, and snippets.

View smat's full-sized avatar

Stian Mathiassen smat

  • 2Park
  • Oslo
View GitHub Profile
@smat
smat / Luke1.kt
Last active December 9, 2016 09:21
Julekalender 2016
import java.lang.Math.floor
import java.lang.Math.log10
import java.util.stream.Stream
fun main(args: Array<String>) {
Stream.iterate(6, { it + 10 } )
.filter { swapFirstAndLastDigit(it) == 4 * it }
.findFirst()
.map { println(it) }
}
@smat
smat / ni-ah-price-per.user.js
Last active December 20, 2015 05:19
NordInvasion AH price per item
// ==UserScript==
// @name NordInvasion AH price per item
// @namespace http://github.com/smat
// @version 0.1
// @description Shows the price per item on the NordInvasion AH
// @match http://*.nordinvasion.com/*
// @match https://*.nordinvasion.com/*
// @grant none
// @copyright 2012+, Stian Mathissen
// ==/UserScript==
@smat
smat / localhost.conf
Created February 27, 2013 14:36
Example config for reverse proxy for nginx
server {
server_name localhost;
keepalive_timeout 5;
location /rest-api {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
@smat
smat / test.html
Created January 31, 2013 08:08
Positioning not working correctly in IE7 with hidden div
<html>
<head>
<title>Test</title>
<script type="text/javascript" src="http://fgnass.github.com/spin.js/dist/spin.min.js"></script>
<script type="text/javascript">
function testbug() {
var target1 = document.getElementById('spin-here1');
var spinner1 = new Spinner().spin(target1);
@smat
smat / tmux.conf
Created October 12, 2015 06:52
tmux.conf
# Enable mouse
setw -g mode-mouse on
# Start windows and panes at 1, not 0
set -g base-index 1
set -g pane-base-index 1
setw -g aggressive-resize on
setw -g mode-keys vi
@smat
smat / .gitignore
Created August 10, 2012 08:18
Jenkins backup
#
# The following ignores...
# Miscellaneous Jenkins litter
*.log
*.tmp
*.old
*.bak
*.jar
*.json
@smat
smat / MyBuilder.java
Created March 14, 2012 11:33
Prototype beans in Spring
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
@Component
@Scope("prototype")
public class MyBuilder {
public Object build() {
return new Object();
}
@smat
smat / pom.xml
Created February 22, 2012 15:49
Commit id in production
<project>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<!-- outputFile doesn't work in the regular v1.2 (see MEXEC-86) -->
<version>1.2.1-BRING</version>
<executions>
<execution>
@smat
smat / ProxyGenerator.java
Created December 7, 2011 14:57
Generate Mock-objects from a hashmap
import org.apache.commons.lang.NotImplementedException;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.WordUtils;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.HashMap;
public class ProxyGenerator {
@smat
smat / SemaphoreFilter.java
Created February 25, 2015 09:03
Semaphore filter
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.concurrent.Semaphore;