Skip to content

Instantly share code, notes, and snippets.

View baens's full-sized avatar

Erik Lindblom baens

View GitHub Profile
@baens
baens / watch-run.sh
Last active August 29, 2015 14:20
Bash watching
#!/bin/bash
trap 'kill -TERM $pid' TERM INT
source=$1
shift
command=$*
@baens
baens / POST
Created January 10, 2018 13:22
Telnethttp-with-telnet/
HTTP/1.1 200 OK
Connection: close
Server: meinheld/0.6.1
Content-Type: application/json
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
X-Powered-By: Flask
X-Processed-Time: 0.000699043273926
Content-Length: 326
Via: 1.1 vegur
@baens
baens / complicated-reverse.js
Last active January 22, 2018 20:54
ostk code challenge 2018-01-22
function reverseWord(word) {
return word.split(/(\w+)/)
.filter(s=>s.trim() != '')
.map(word=>word.split('').reverse().join(''))
.join('');
}
function reverse(string) {
return string.split(' ')
.map(reverseWord)
@baens
baens / kotlin.kt
Created March 30, 2018 12:19
cc-2018-03-30
infix fun Int.toThePowerOf(exponent: Int): Int = Math.pow(this.toDouble(), exponent.toDouble()).toInt()
fun main(args: Array<String>) {
val sets = mutableListOf<Set<String>>()
sets.add(emptySet())
for(setNumber in 1 until 2.toThePowerOf(args.size)) {
val set = mutableSetOf<String>()
@baens
baens / much-better-way.sh
Created June 28, 2018 03:25
Demonstrate better way to write vault commands in shell scripts
cat <<EOM | vault write dbs/config/mydb -
{
"plugin_name": "postgresql-database-plugin",
"allowed_roles": "mydb-admin",
"connection_url": "postgresql://{{username}}:{{password}}@database:5432/mydb",
"username": "admin",
"password": "secret",
"verify_connection": false
}
EOM