Skip to content

Instantly share code, notes, and snippets.

View kevana's full-sized avatar

Kevan Ahlquist kevana

View GitHub Profile
@kevana
kevana / groovy.groovy
Last active September 16, 2015 23:33
@Unroll
def "kbaQuizAnswers is invalid when property #field of answer #ansNumber is null"() {
given:
command.kbaQuizAnswers.answers[ansNumber][field] = null
when:
def isValid = command.validate()
then:
!isValid
@kevana
kevana / es6-demo.js
Last active September 23, 2015 05:46
Short demo of useful ES6 features, for Babel REPL https://babeljs.io/repl/
// Based on https://medium.com/sons-of-javascript/javascript-an-introduction-to-es6-1819d0d89a0f
console.log('========== Block scope and arrow functions');
let square = x => x * x;
let add = (a, b) => a + b;
let pi = () => 3.1415;
console.log(square(5)); // 25
console.log(add(3, 4)); // 7
console.log(pi()); // 3.1415
var x = 0;
@kevana
kevana / mmmmCookies.hbs
Last active May 28, 2019 10:30
Part of Nginx config for cookie-based routing.
if ($http_cookie ~* (
{{~#each cookies~}}
{{~ this }}{{#unless @last}}|{{/unless}}
{{~/each~}}
)=Y) {
rewrite ^{{ ocpUrl }}$ {{ bcpUrl }} redirect;
}
if ($http_cookie !~* (
{{~#each cookies~}}
{{~ this }}{{#unless @last}}|{{/unless}}
# Case 1: If user is going to credit app from desktop prevent them from being redirected
# - User has cookie set
# - url is in active list.
# THEN prevent moovweb redirect
# Case 2: User is already on moovweb and goes to credit app page
# - Via header is set
# - User has cookie set
# - url is in active list
@kevana
kevana / bootstrap.js
Created November 23, 2015 23:46
Bootstrap JS 3.3.4 from our repo
/*!
* Bootstrap v3.3.4 (http://getbootstrap.com)
* Copyright 2011-2015 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
if (typeof jQuery === 'undefined') {
throw new Error('Bootstrap\'s JavaScript requires jQuery')
}
@kevana
kevana / nginx-if.conf
Created November 30, 2015 18:57
Poor man's HTTPS redirect.
location /statement {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
proxy_set_header Connection "";
# Redirect to https if the protocol is http and the cookie is set
14:47:35.041 [DEBUG] [TestEventLogger] java.lang.StackOverflowError
14:47:35.041 [DEBUG] [TestEventLogger] at java.util.concurrent.locks.ReentrantReadWriteLock$Sync.tryReleaseShared(ReentrantReadWriteLock.java:423)
14:47:35.042 [DEBUG] [TestEventLogger] at java.util.concurrent.locks.AbstractQueuedSynchronizer.releaseShared(AbstractQueuedSynchronizer.java:1341)
14:47:35.042 [DEBUG] [TestEventLogger] at java.util.concurrent.locks.ReentrantReadWriteLock$ReadLock.unlock(ReentrantReadWriteLock.java:881)
14:47:35.042 [DEBUG] [TestEventLogger] at org.grails.datastore.gorm.GormEnhancer.registerAssociationIdentifierGetter_closure4(GormEnhancer.groovy:320)
@kevana
kevana / classes.md
Last active August 4, 2017 14:12
UMN Unite CSCI courses, Spring 2016
Interest Course number Title
| CSCI 5105 | Introduction to Distributed Systems 
| CSCI 5106 | Programming Languages
| CSCI 5125 | Collaborative and Social Computing 
| CSCI 5161 | Introduction to Compilers
| CSCI 5221 | Foundations of Advanced Networking
| CSCI 5421 | Advanced Algorithms and Data Structures
| CSCI 5451 | Introduction to Parallel Computing: Architectures, Algorithms, and Programming

| CSCI 5461 | Functional Geometrics, Systems Biology and Bioinformatics

@kevana
kevana / create-machines.sh
Last active February 26, 2016 03:49
dvm + machine: Easy testing for apps that support multiple Docker versions
# create docker-machines and use dvm to switch client binaries.
docker-machine create \
--driver=virtualbox \
--virtualbox-boot2docker-url=https://github.com/boot2docker/boot2docker/releases/download/v1.10.2/boot2docker.iso \
1.10.2-dev
docker-machine create \
--driver=virtualbox \
--virtualbox-boot2docker-url=https://github.com/boot2docker/boot2docker/releases/download/v1.9.1/boot2docker.iso \
@kevana
kevana / stacktrace.txt
Last active December 17, 2015 23:41
asset-pipeline transform failure: ReferenceError: "babel" is not defined. (BabelProcessor.groovy#72)
java.lang.Exception: babel-transforming SearchBar.react.es6 failed: org.mozilla.javascript.EcmaError: ReferenceError: "babel" is not defined. (BabelProcessor.groovy#72)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_40]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_40]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_40]
at java.lang.reflect.Constructor.newInstance(Constructor.java:422) ~[na:1.8.0_40]
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrConstructorNewInstance(ReflectiveInterceptor.java:1075) ~[springloaded-1.2.5.RELEASE.jar:1.2.5.RELEASE]
at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:80) ~[groovy-2.4.5.jar:2.4.5]
at org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:74) ~[groovy-2.4.5.jar:2.4.5]
at org.codehaus.groovy.runtime.callsite.Constructor