Skip to content

Instantly share code, notes, and snippets.

View SQiShER's full-sized avatar
👨‍👩‍👧
Work, Family, Sleep, Repeat

Daniel Bechler SQiShER

👨‍👩‍👧
Work, Family, Sleep, Repeat
View GitHub Profile
@SQiShER
SQiShER / gist:1111424
Created July 28, 2011 11:41
This is the reason why Lucene scoring was a little bit off for searches with very short terms (if I recall correctly)
private final Similarity similarity = new DefaultSimilarity()
{
private static final long serialVersionUID = 1L;
@Override
public byte encodeNormValue(final float f)
{
return SmallFloat.floatToByte52(f);
}
@SQiShER
SQiShER / IsTheAppleStoreOnline.sh
Created May 17, 2012 14:14
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!
#!/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
@SQiShER
SQiShER / UpdateEnvironmentPlist.sh
Created May 17, 2012 16:46
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

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 / ios-command-line-tests.md
Last active December 13, 2015 23:19
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

      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"

@SQiShER
SQiShER / URLConnection.h
Last active July 16, 2020 10:51
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…
#import <Foundation/Foundation.h>
@interface URLConnection : NSObject <NSURLConnectionDataDelegate, NSURLConnectionDelegate>
+ (NSData *)sendSynchronousRequest:(NSURLRequest *)request
returningResponse:(NSURLResponse **)response
error:(NSError **)error;
@end
@SQiShER
SQiShER / build.gradle
Last active August 29, 2015 13:57
Gradle Cargo Plugin configuration example for isolated containers
def availablePortFinder = AvailablePortFinder.createPrivate()
def tomcatDownloadUrl = 'http://.../apache-tomcat-7.0.50.zip'
def cargoHome = "$buildDir/cargo"
// ...
buildscript {
repositories {
jcenter()
}
@SQiShER
SQiShER / docker_stats_with_names.sh
Last active May 5, 2020 07:35
Docker stats with Container Names instead of IDs
docker stats $(docker inspect -f '{{.Name}}' $(docker ps -q) | cut -c 2-)
@SQiShER
SQiShER / ByteArrayDiffer.java
Last active September 14, 2015 10:51
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
@SQiShER
SQiShER / example.json
Last active November 5, 2015 15:42
GraphQL question: how to query for all items of a map without knowing the field names?
{
"id-123": {
"name": "foo"
},
"id-456": {
"name": "bar"
}
}