Skip to content

Instantly share code, notes, and snippets.

Avatar

Guillaume Aubert gaubert

View GitHub Profile
@gaubert
gaubert / gist:0bf785679a89a419fa30
Last active Aug 29, 2015
working elastic search query with highlight and facets
View gist:0bf785679a89a419fa30
# working query with highlight and facets first
curl -XGET 'http://localhost:9200/_search?pretty=true' -d '
{ "from" : 0, "size" : 1,
"highlight" : {
"fields" :
{ "identificationInfo.title": {"fragment_size":150,"number_of_fragments":3}, "identificationInfo.abstract": {} }
} ,
"facets" :
{
View gist:f1584808b0f1d0b845ce
import re
class CardOutParser(object):
LINEEXPR = "##T-step: old_ts#(?P<tstep_old>.*), new_ts#(?P<tstep_new>.*), gyro_Dt#(?P<dt>.*)"
lre_timing = re.compile(LINEEXPR)
LINEEXPR = "#T-acc#(?P<timestamp_tacc>.*)#Am-Raw#(?P<r_ax>.*),(?P<r_ay>.*),(?P<r_az>.*)#T-gyr#(?P<timestamp_tgyr>.*)#Gm-Raw#(?P<g_ax>.*),(?P<g_ay>.*),(?P<g_az>.*)#T-mag#(?P<timestamp_tmag>.*)#Mm-Raw#(?P<m_ax>.*),(?P<m_ay>.*),(?P<m_az>.*)"
lre_data = re.compile(LINEEXPR)
@gaubert
gaubert / gist:e26eb189f7e42317fbb1
Created Oct 30, 2014
typical Json document created from the ISO19115 XML Metadata record
View gist:e26eb189f7e42317fbb1
{
"identificationInfo":
{
"abstract": "A DevCoCast product, GOES\/MSG Composite is a product created by composing the GOES-12 IR images with MSG IR images, every 15 minutes. Every 3 hours, the composite will be derived from the full disk of GOES and full disk of MSG, in the 13-North to 50-South Latitude; 85-West to 55-East Longitude region, encompassing South America and Africa.",
"title": "Composites - GOES-MSG - Africa, South America",
"thumbnail": "http:\/\/navigator.eumetsat.int:80\/smartEditor\/preview\/GMC.jpg",
"keywords":
[
"Atmospheric conditions",
"Agriculture",
@gaubert
gaubert / gist:7f4f3e05845eface3861
Last active Aug 29, 2015
WMO_CategoryCodeList
View gist:7f4f3e05845eface3861
<!- WMO_CategoryCode :: New CodeList for WMO Core Metadata Profile
-->
<gmx:codelistItem>
<gmx:CodeListDictionary gml:id="WMO_CategoryCode">
<gml:description>additional topic categories for WMO community</gml:description>
<gml:identifier codeSpace="WMO Core Metadata Profile">WMO_CategoryCode</gml:identifier>
<gmx:codeEntry>
<gmx:CodeDefinition gml:id="WMO_CategoryCode_weatherObservations">
<gml:description>weather observations</gml:description>
<gml:identifier codeSpace="WMO Core Metadata Profile">weatherObservations</gml:identifier>
View serv.py (simple echo server)
# Echo server program
import socket
HOST = '' # Symbolic name meaning the local host
PORT = 9001 # Arbitrary non-privileged port
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((HOST, PORT))
s.listen(1)
print "listenning on %s , port = %d"%(HOST,PORT)
while 1:
View websocketserver.py
import struct
import socket
import hashlib
import sys
from select import select
import re
import logging
class WebSocket(object):
handshake = (
@gaubert
gaubert / curl_post
Created Oct 21, 2010
quick and dirty script for posting a file content with curl (second file also changes the HTTP Header
View curl_post
#!/bin/bash
if [ ! -e "$1" ]; then
echo "Error: Need a file to post"
echo "Usage: curl_post file_to_post.file"
exit 1
fi
if [ -c "$1" ]
then
@gaubert
gaubert / lruqueue.py
Created Dec 14, 2010
0MQ lruqueue implementation
View lruqueue.py
"""
Least-recently used (LRU) queue device
Clients and workers are shown here in-process
Author: Guillaume Aubert (gaubert) <guillaume(dot)aubert(at)gmail(dot)com>
"""
import threading
@gaubert
gaubert / lruqueue2.py
Created Dec 15, 2010
lruqueue2 example implementation
View lruqueue2.py
"""
Least-recently used (LRU) queue device
Demonstrates use of the multipart messages in python
Author: Guillaume Aubert (gaubert) <guillaume(dot)aubert(at)gmail(dot)com>
"""
import threading
@gaubert
gaubert / msgqueue.py
Created Dec 15, 2010
0MQ msgqueue.py zguide implementation
View msgqueue.py
"""
Simple message queuing broker
Same as request-reply broker but using QUEUE device
Author: Guillaume Aubert (gaubert) <guillaume(dot)aubert(at)gmail(dot)com>
"""