Skip to content

Instantly share code, notes, and snippets.

View clintongormley's full-sized avatar

Clinton Gormley clintongormley

  • Barcelona, Spain
View GitHub Profile
@clintongormley
clintongormley / emoticon list
Created April 18, 2014 09:38
Emoticon analyzer
e_smiley :-) :) :o) :] :3 :c) :> =] 8) =) :} :^) :っ) :-)) :-))) :-)))) :)) :))) :))))
e_laugh :-D :D 8-D 8D x-D xD X-D XD =-D =D =-3 =3 B^D
e_sad >:[ :-( :( :-c :c :-< :っC :< :-[ :[ :{
e_wink_frown ;(
e_angry :-|| :@ >:(
e_cry :'-( :'(
e_happy_tears :'-) :')
e_disgust D:< D: D8 D; D= DX v.v D-':
e_surprise >:O :-O :O :-o :o 8-0 O_O o-o O_o o_O o_o O-O
e_kiss :* :^* '}{'
@clintongormley
clintongormley / demo.sh
Last active August 29, 2015 13:57
Rolling average with Elasticsearch aggregations
curl -XDELETE "http://localhost:9200/myindex"
# insert some data
curl -XPOST "http://localhost:9200/myindex/log/_bulk" -d'
{ "index": {}}
{ "num": 1, "date": "2014-01-01"}
{ "index": {}}
{ "num": 2, "date": "2014-01-02"}
{ "index": {}}
{ "num": 3, "date": "2014-01-03"}
curl -XDELETE "http://localhost:9200/myindex"
curl -XPUT "http://localhost:9200/myindex" -d'
{
"mappings": {
"animal": {},
"customer": {
"_parent": {
"type": "animal"
},
curl -XPUT "http://localhost:9200/production_index" -d'
{
"mappings": {
"production": {
"properties": {
"production_title": {
"type": "multi_field",
"fields": {
"production_title_edgengram": {
"type": "string",
GET /_search
{
"query": {
"bool": {
"must": [
{
"match": {
"myfield": {
"query": "quick brown fox",
"fuzziness": "AUTO",
curl -XGET "http://localhost:9200/_search" -d'
{
"query": {
"bool": {
"must": [
{
"match": {
"myfield": {
"query": "quick brown fox",
"fuzziness": "AUTO",
@clintongormley
clintongormley / gist:9217164
Created February 25, 2014 20:37
Multi-match
DELETE /_all
PUT /myindex
{
"settings": {
"number_of_shards": 1
}
}
POST /myindex/mytype/1
#!/usr/bin/env perl
use strict;
use warnings;
use Benchmark qw(timeit cmpthese timesum :hireswallclock);
use lib 'lib', '../p5-http-tiny/lib';
use Elasticsearch;
use v5.16;
my $Times = 3;
@clintongormley
clintongormley / gist:8980968
Created February 13, 2014 18:32
Comparing LWP, HTTP::Tiny, NetCurl and Hijk with different body sizes - 10,000 read/write requests x 3 runs

Body: 11 bytes

Write:
         s/iter      LWP HTTPTiny  NetCurl     Hijk
LWP        8.58       --     -43%     -60%     -64%
HTTPTiny   4.92      75%       --     -31%     -37%
NetCurl    3.42     151%      44%       --     -10%
Hijk       3.07     179%      60%      11%       --
Read:
@clintongormley
clintongormley / gist:8980882
Created February 13, 2014 18:27
Comparing keep-alive on/off for HTTP::Tiny - 11 bytes x 1,000 read/write requests x 10 runs

HTTP Tiny with keep-alive OFF

Write:
           Rate HTTPTiny      LWP  NetCurl     Hijk
HTTPTiny 1.12/s       --      -4%     -61%     -63%
LWP      1.17/s       4%       --     -59%     -61%
NetCurl  2.83/s     154%     143%       --      -7%
Hijk     3.03/s     171%     160%       7%       --
Read: