Skip to content

Instantly share code, notes, and snippets.

View davidbkemp's full-sized avatar

David Kemp davidbkemp

  • Melbourne Australia
View GitHub Profile
@davidbkemp
davidbkemp / elasticsearch-percolation-example.txt
Last active May 3, 2023 14:25
Example of using Elasticsearch percolation to match a listing against saved searches
# Example listings definition
PUT /listings
{
"mappings": {
"properties": {
"description": {"type": "text", "analyzer": "english"},
"suburb": {"type": "keyword"},
"bedrooms": {"type": "integer"}
}
}
@davidbkemp
davidbkemp / addressSuggestionDocument.json
Last active October 12, 2016 06:11
Example of how to use Elasticsesarch's Completion Suggesters for address auto-complete
{
"suggest": {
"output": "5/1-3 Abby Court, West Moonah, Tas 7009",
"input": [
"5/1-3 Abby Court, West Moonah, Tas 7009",
"Abby Court, West Moonah, Tas 7009",
"1-3 Abby Court, West Moonah, Tas 7009",
"1 Abby Court, West Moonah, Tas 7009",
"3 Abby Court, West Moonah, Tas 7009",
"5/1 Abby Court, West Moonah, Tas 7009",
@davidbkemp
davidbkemp / gist:1602e1efd2ab7a6188c7
Created January 11, 2015 07:59
Modified Arduino USB Host Shield Keyboard Example
// Modified from https://github.com/felis/USB_Host_Shield_2.0/blob/master/examples/HID/USBHIDBootKbd/USBHIDBootKbd.ino
// Modified to print the ASCII hex codes of the keys pressed, and to handle some of the non-printable keys.
#include <hidboot.h>
#include <usbhub.h>
// Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude
#include <spi4teensy3.h>
#endif
@davidbkemp
davidbkemp / self_included_example.rb
Created May 20, 2012 05:04
Use of self.included
module Foo
# Should not really need the check for const_dedined?, but...
FOO = [] unless const_defined?(:FOO)
def self.included(host_class)
FOO << host_class
end
end
class Baa
include Foo