Skip to content

Instantly share code, notes, and snippets.

import org.scalatest.matchers.ShouldMatchers
import org.scalatra.test.scalatest.ScalatraFunSuite
import org.scalatra.ScalatraServlet
import org.scalatra.CookieSupport
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import org.scalatra.ScalatraFilter
import org.scalatra.scalate.ScalateSupport
import org.scalatra.FlashMapSupport
@lvonk
lvonk / rax_dns
Created November 19, 2013 19:17
Ansible module that to register reverse DNS records in rackspace using pyrax.
#!/usr/bin/python
# Place this file in for instance my_project/modules and run playbook with
# ansible-playbook project.yml -i development --module-path modules
# Usage:
# - hosts: local-app
# connection: local
# user: root
# tasks:
# - name: Rackspace | Add PTR records
@lvonk
lvonk / alternative_vault.py
Last active October 15, 2015 19:05
Alternative Ansible vault.
# Copyright 2014 Zilverline B.V.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@lvonk
lvonk / Cursor.rb
Last active July 7, 2024 12:20
Simple postgres cursor
# Use as
Cursor.new(Model.includes(foos: [:bar], :foo_bars).where(id < 1000000)).find_each do |model|
# do something
end
# Inspired by https://github.com/afair/postgresql_cursor
class Cursor
class NoopObserver
def close_failed(e)
end
@lvonk
lvonk / index.html
Last active November 30, 2018 14:08
Proxy all fetch request using a service worker to prevent unwanted urls
<html>
<head>
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('load', function() {
console.log('[APP] registering ServiceWorker')
navigator.serviceWorker.register('/sw.js').then(function(registration) {
// Registration was successful
console.log('[APP] ServiceWorker registration successful with scope: ', registration.scope);
}, function(err) {