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
SQiShER / README.md
Created Dec 17, 2015
Delete unused Docker images
View README.md

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
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"
}
}
@SQiShER
SQiShER / ByteArrayDiffer.java
Last active Sep 14, 2015
Custom Differ for java-object-diff to add "equals-only" byte array support
View ByteArrayDiffer.java
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
@SQiShER
SQiShER / docker_stats_with_names.sh
Last active Aug 19, 2019
Docker stats with Container Names instead of IDs
View docker_stats_with_names.sh
docker stats $(docker inspect -f '{{.Name}}' $(docker ps -q) | cut -c 2-)
@SQiShER
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://.../apache-tomcat-7.0.50.zip'
def cargoHome = "$buildDir/cargo"
// ...
buildscript {
repositories {
jcenter()
}
@SQiShER
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;
@end
@SQiShER
SQiShER / ios-command-line-tests.md
Last active Dec 13, 2015
The bumpy road to iOS Command-Line builds. A step-by-step guide. (Work in progress)
View ios-command-line-tests.md
  • 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

      RUN_UNIT_TEST_WITH_IOS_SIM=YES
      if [ "$RUN_UNIT_TEST_WITH_IOS_SIM" = "YES" ]; then
      	test_bundle_path="$BUILT_PRODUCTS_DIR/$PRODUCT_NAME.$WRAPPER_EXTENSION"
    
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

@SQiShER
SQiShER / UpdateEnvironmentPlist.sh
Created May 17, 2012
Two simple commands to resolve problems with Maven installed via Homebrew
View UpdateEnvironmentPlist.sh
defaults write ~/.MacOSX/environment.plist M2_HOME `brew --prefix maven`/libexec
defaults write ~/.MacOSX/environment.plist M2 `brew --prefix maven`/libexec/bin
@SQiShER
SQiShER / IsTheAppleStoreOnline.sh
Created May 17, 2012
Script for OS X that checks every 2 minutes whether the Apple Store is online and notifies you as soon as it's back online. Great if you want to buy a new product before its sold out!
View IsTheAppleStoreOnline.sh
#!/bin/sh
while [ true ]
do
if [ $(curl -XGET "http://store.apple.com/de" | grep "We'll be back soon" | wc -l) -eq 0 ]
then
say -v Alex 'The Apple Store is back online!'
growlnotify -m 'The Apple Store is back online!' -t 'Apple Store'
fi
sleep 120
You can’t perform that action at this time.