Skip to content

Instantly share code, notes, and snippets.

View hscells's full-sized avatar

Harry Scells hscells

View GitHub Profile
@hscells
hscells / pipeline.sh
Last active August 10, 2017 23:38
Elasticsearch - Accessing a Term Vector
# Previous example
# https://gist.github.com/hscells/774e112d14e3f249e8960d7147d61353
# Access the term vector for the `body` field
# https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-termvectors.html
curl -X GET "localhost:9200/example/doc/AV3OdFAZ7fqYee2bfgSQ/_termvectors?term_statistics&fields=body"
# =>
# {
# "_index" : "example",
# "_type" : "doc",
@hscells
hscells / pipeline.sh
Last active August 10, 2017 23:30
Start Elasticsearch, 
Index & Query
# 1. Start Elasticsearch
# ./bin/elasticsearch, docker run ...
# 2. Create index
# https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html
curl -X PUT http://localhost:9200/example
# => {"acknowledged":true,"shards_acknowledged":true}
# 3. Add a document
# https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html
@hscells
hscells / publications.json
Last active August 10, 2017 15:47
elastic4ir kibana dashboard
[
{
"_id": "e3fe32d0-7dd6-11e7-b648-2bc197fbff8a",
"_type": "dashboard",
"_source": {
"title": "Publications",
"hits": 0,
"description": "",
"panelsJSON": "[{\"col\":1,\"id\":\"9bd57360-7dd6-11e7-b648-2bc197fbff8a\",\"panelIndex\":1,\"row\":1,\"size_x\":7,\"size_y\":3,\"type\":\"visualization\"},{\"col\":7,\"id\":\"6e1d38b0-7dde-11e7-b648-2bc197fbff8a\",\"panelIndex\":3,\"row\":4,\"size_x\":6,\"size_y\":6,\"type\":\"visualization\"},{\"col\":1,\"id\":\"1f353c80-7dd8-11e7-b648-2bc197fbff8a\",\"panelIndex\":4,\"row\":10,\"size_x\":12,\"size_y\":4,\"type\":\"visualization\"},{\"col\":1,\"id\":\"edbc1750-7de1-11e7-9902-0decf2213372\",\"panelIndex\":5,\"row\":4,\"size_x\":6,\"size_y\":6,\"type\":\"visualization\"},{\"size_x\":5,\"size_y\":3,\"panelIndex\":6,\"type\":\"visualization\",\"id\":\"49c94ea0-7de2-11e7-9902-0decf2213372\",\"col\":8,\"row\":1}]",
"optionsJSON": "{\"darkTheme\":false}",
@hscells
hscells / pipeline.conf
Last active September 16, 2019 19:55
Pubmed logstash pipeline
# http://www.front2backdev.com/2015/08/26/pulling-and-splitting-live-xml/
input {
file {
path => "/Users/harryscells/Docker/sigir2017-elastic4ir/*.xml"
start_position => "beginning"
sincedb_path => "NUL"
codec => multiline {
pattern => "<PubmedArticle>|</PubmedArticleSet>"
negate => true
what => "previous"
@hscells
hscells / tree.go
Created March 7, 2017 04:21
Go tree example
package main
// Node is a struct that represents any node in a tree
type Node struct {
Name string
Children []Node
}
// Traverse is a function that prints the name of each Node in a tree of Nodes.
func (n Node) Traverse() {
@hscells
hscells / conditions.md
Last active April 19, 2017 06:44
Useful shell tricks

Test if a file exits

if [ ! -f /tmp/foo.txt ]; then
    echo "File not found!"
fi
with_fx :bitcrusher do
with_fx :panslicer do
sample :guit_e_fifths, beat_stretch: 60, pitch_dis: 3, pan: 0.2, amp: 10
sample :guit_e_fifths, beat_stretch: 60, pitch_dis: 3, pan: 0.8, amp: 10
end
end
@hscells
hscells / MatrixMultiply.clj
Last active August 29, 2015 14:26
Recursive Matrix Multiply in Clojure
(defn col
"get the column n from list lst"
([lst n] (col lst n []))
([lst n l]
(cond
(empty? lst) l
:else
(recur (rest lst) n (conj l (nth (first lst) n))))))
(defn dot-product [A B]

Keybase proof

I hereby claim:

  • I am hscells on github.
  • I am hs (https://keybase.io/hs) on keybase.
  • I have a public key whose fingerprint is 784C 0AB5 40DF 3A16 8C5D A630 E24C 7ABB 3CAB 2732

To claim this, I am signing this object:

@hscells
hscells / source.js
Last active August 29, 2015 14:15
JS1k 2015 Entry (Pixel Space Train)
W = a.width;
H = a.height;
U = "#ccc";
s = [];
K = [];
Z = [];
function R(){
return Math.random();
}
function F(x,y,w,h,C){