This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_code(tree, feature_names, class_names): | |
left = tree.tree_.children_left | |
right = tree.tree_.children_right | |
threshold = tree.tree_.threshold | |
features = [feature_names[i] for i in tree.tree_.feature] | |
value = tree.tree_.value | |
def recurse(left, right, threshold, features, node, indent): | |
if threshold[node] != -2: | |
print "%sif %s <= %s:" % (indent, features[node], threshold[node]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -XPOST 'http://127.0.0.1:9200/test/a/1?pretty=true' -d '{"b": [{"i": [1]}]}' | |
curl -XPOST 'http://127.0.0.1:9200/_all/_flush?pretty=true' | |
curl -XGET 'http://127.0.0.1:9200/test/a/_search?q=*&fields=b.i&pretty=true' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -XPOST 'http://127.0.0.1:9200/test/a/1?pretty=true' -d '{"b": {"i": [null]}}' | |
curl -XPOST 'http://127.0.0.1:9200/_all/_flush?pretty=true' | |
curl -XGET 'http://127.0.0.1:9200/test/a/_search?q=*&fields=b&pretty=true' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"ok":true,"_index":"test","_type":"b","_id":"1","_version":1}{ | |
"took" : 2, | |
"timed_out" : false, | |
"_shards" : { | |
"total" : 5, | |
"successful" : 4, | |
"failed" : 1, | |
"failures" : [ { | |
"index" : "test", | |
"shard" : 2, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SERVER='http://127.0.0.1:9200/' | |
curl -XDELETE "$SERVER/test/" | |
curl -XPUT "$SERVER/test/" | |
curl -XPUT "$SERVER/test/a/_mapping" -d '{"a": {"properties": {"field1": {"type": "integer"}}}}' | |
curl -XPUT "$SERVER/test/b/1" -d '{"field1": 1}' | |
sleep 1 | |
curl -XGET 'http://localhost:9200/test/a/_search?size=0' -d '{"facets":{"f":{"terms":{"field":"field1"}}},"query":{"match_all":{}}}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Prolog solution to: | |
% http://www.theguardian.com/science/alexs-adventures-in-numberland/2015/may/04/einsteins-election-riddle-are-you-in-the-two-per-cent-that-can-solve-it | |
left(X, Y, [X | [Y | _]]). | |
left(X, Y, [_ | List]) :- left(X, Y, List). | |
neighbour(X, Y, List) :- left(X, Y, List); left(Y, X, List). | |
% house(Person, Pattern, Pet, Drink, Transport) | |
solution(Answer) :- Z = [_, _, _, _, _], | |
% 1. Nicola lives in the tartan house. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Bug demonstrating Release crash in swift code (XCode 6.2 / swift 1.1, Release builds only) | |
import UIKit | |
import XCTest | |
func dictSetValue(value: AnyObject, forKey key: String, inout #dictionary: [String : AnyObject]) { | |
dictSetValue(value, forKeyPathComponents: key.componentsSeparatedByString("."), dictionary: &dictionary) | |
} | |
func dictSetValue(value: AnyObject, forKeyPathComponents components: [String], inout #dictionary: [String : AnyObject]) { |
NewerOlder