Skip to content

Instantly share code, notes, and snippets.

View mattbroekhuis's full-sized avatar

Matt Broekhuis mattbroekhuis

View GitHub Profile
@rrodseth
rrodseth / UnfoldPages.scala
Last active June 14, 2021 18:36
Create akka-stream Source from a pagination, using Source.unfoldAsync
// Inspired by a tweet from @trautonen 1/13/2016
// Use Source.unfoldAsync to turn paginated database results into an akka-streams Source
// unfold is the inverse of fold
case class Page[T](pageNumber:Long, totalPages:Long, contents:List[T])
case class Thing(id: Long, name: String = "foo")
val totalPages = 5 //
val pageSize = 3
#!/bin/bash
# Shamelessly stolen from https://gist.github.com/eduardocardoso/82a629882ddb02ab3677
set -o errexit
echo "Removing exited docker containers..."
docker ps -a -f status=exited -q | xargs -r docker rm -v
echo "Removing untagged images..."
docker images --no-trunc | grep "<none>" | awk '{print $3}' | xargs -r docker rmi
@donaldpipowitch
donaldpipowitch / auto-update-service.js
Created June 3, 2014 07:18
Add auto-update functionality to Restangular (only for collection.post, model.get and model.remove in this example)
angular.module('extensions.restangular.auto-update', [
'restangular'
]);
angular.module('extensions.restangular.auto-update')
.factory('RestangularAutoUpdate', function RestangularAutoUpdate(Restangular) {
// properties
var _routes = [];
@joshlong
joshlong / gist:5441496
Created April 23, 2013 07:25
a complete, 1-step Spring Batch job with supporting infrastructure (JobLauncher, JobRepository, DataSource, PlatformTransactionManager) and business logic entirely in Java. This job will read in data in a property file and then write them to the database. I used constant Strings for the bean names that way I didn't have too many magic strings fl…
// from my https://github.com/joshlong/a-walking-tour-of-all-of-springdom project
import org.apache.commons.logging.*;
import org.springframework.batch.core.*;
import org.springframework.batch.core.configuration.annotation.*;
import org.springframework.batch.core.step.builder.StepBuilder;
import org.springframework.batch.item.*;
import org.springframework.batch.item.database.*;
import org.springframework.batch.item.file.FlatFileItemReader;
import org.springframework.batch.item.file.mapping.*;
@aleung
aleung / ApplicationContextDumper.java
Created November 8, 2011 06:41
Dump beans information in a Springframework application context. Licensed under WTFPL v2. More detail in blog post: http://aleung.github.io/blog/2011/11/08/Dump-beans-information-from-live-Spring-application-context/
package leoliang.springtest;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.support.AbstractRefreshableApplicationContext;
<script src="http://raphaeljs.com/raphael.js" type="text/javascript" charset="utf-8"></script>
<style type="text/css" media="screen">
body {
background-color: black;
color: white;
font-family: helvetica;
}
#display {