Skip to content

Instantly share code, notes, and snippets.

Daniel Bechler SQiShER

Block or report user

Report or block SQiShER

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
SQiShER / metrics.diff
Last active Nov 18, 2019
HAProxy Exporter vs. Built-in Metrics
View metrics.diff
go_gc_duration_seconds | haproxy_backend_active_servers
go_gc_duration_seconds_count | haproxy_backend_backup_servers
go_gc_duration_seconds_sum <
go_goroutines <
go_info <
go_memstats_alloc_bytes <
go_memstats_alloc_bytes_total <
go_memstats_buck_hash_sys_bytes <
go_memstats_frees_total <
go_memstats_gc_cpu_fraction <
Created Dec 17, 2015
Delete unused Docker images

In theory it shouldn't be a problem to run docker rmi on images that are currently in use, as Docker will simply skip them.

In practice this doesn't seem to be bulletproof. On more than one occasion this caused weird problems, so I prefer to only run rmi for images that I know, are not in use.

Here's the command I use to do so:

docker rmi $(docker inspect -f '{{.Image}}' `docker ps -a -q --no-trunc` | grep -v -f - <(docker images -q --no-trunc))
SQiShER / example.json
Last active Nov 5, 2015
GraphQL question: how to query for all items of a map without knowing the field names?
View example.json
"id-123": {
"name": "foo"
"id-456": {
"name": "bar"
Last active Sep 14, 2015
Custom Differ for java-object-diff to add "equals-only" byte array support
import de.danielbechler.diff.NodeQueryService;
import de.danielbechler.diff.access.Instances;
import de.danielbechler.diff.differ.Differ;
import de.danielbechler.diff.differ.DifferDispatcher;
import de.danielbechler.diff.differ.DifferFactory;
import de.danielbechler.diff.node.DiffNode;
import java.util.Arrays;
public class ByteArrayDiffer implements Differ
Last active Nov 3, 2019
Docker stats with Container Names instead of IDs
docker stats $(docker inspect -f '{{.Name}}' $(docker ps -q) | cut -c 2-)
SQiShER / build.gradle
Last active Aug 29, 2015
Gradle Cargo Plugin configuration example for isolated containers
View build.gradle
def availablePortFinder = AvailablePortFinder.createPrivate()
def tomcatDownloadUrl = 'http://.../'
def cargoHome = "$buildDir/cargo"
// ...
buildscript {
repositories {
SQiShER / URLConnection.h
Last active May 9, 2016
Here is my solution for a better synchronous NSURLConnection. Although asynchronous NSURLConnections are usually a good way to go, sometimes there is just no way around waiting (and blocking) until a request finished. NSURLConnection offers a method to perform synchronous requests, but it is far from perfect and has some serious flaws. In my cas…
View URLConnection.h
#import <Foundation/Foundation.h>
@interface URLConnection : NSObject <NSURLConnectionDataDelegate, NSURLConnectionDelegate>
+ (NSData *)sendSynchronousRequest:(NSURLRequest *)request
returningResponse:(NSURLResponse **)response
error:(NSError **)error;
Last active Dec 13, 2015
The bumpy road to iOS Command-Line builds. A step-by-step guide. (Work in progress)
  • Configure a new (shared) Scheme to run tests during the build phase

  • Install ios-sim via Homebrew

      brew install ios-sim
  • Run ios-sim from a script in the test target

      if [ "$RUN_UNIT_TEST_WITH_IOS_SIM" = "YES" ]; then
View gist:3555555

I'm afraid the paths you are storing in MongoDB won't be very useful, since they are simply the default toString() representation of the referenced collection item. In order to use this path to access the property via java-object-diff, you'd need to be able to deserialize it to an actual instance of an object that has the same identity (equals == true) as the one you want to reference.

There are ways to do that, like writing a custom serializer for the PropertyPath to serialize a deserializable version of the reference item, but that leads to pretty verbose JSON and is rather fragile.

I personally don't recommend storing the diff in a database, but rather compare two document versions on demand. Depending on your scenario that may or may not cause performance issues. If it does, there are usually ways to cache the information you actually need, without storing the entire diff in the database.

I once had the same problem when I tried to generate a Github-like activity stream. I first approached it by stor

Created May 17, 2012
Two simple commands to resolve problems with Maven installed via Homebrew
defaults write ~/.MacOSX/environment.plist M2_HOME `brew --prefix maven`/libexec
defaults write ~/.MacOSX/environment.plist M2 `brew --prefix maven`/libexec/bin
You can’t perform that action at this time.