Skip to content

Instantly share code, notes, and snippets.

View gaubert's full-sized avatar

Guillaume Aubert gaubert

View GitHub Profile
@gaubert
gaubert / gist:0bf785679a89a419fa30
Last active August 29, 2015 14:05
working elastic search query with highlight and facets
# 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" :
{
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 October 30, 2014 16:26
typical Json document created from the ISO19115 XML Metadata record
{
"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",
# 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:
@gaubert
gaubert / websocketserver.py
Created August 13, 2010 11:52 — forked from mumrah/websocketserver.py
websocket server
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 October 21, 2010 14:39
quick and dirty script for posting a file content with curl (second file also changes the HTTP Header
#!/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 December 14, 2010 14:22
0MQ lruqueue implementation
"""
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 December 15, 2010 08:45
lruqueue2 example implementation
"""
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 December 15, 2010 14:43
0MQ msgqueue.py zguide implementation
"""
Simple message queuing broker
Same as request-reply broker but using QUEUE device
Author: Guillaume Aubert (gaubert) <guillaume(dot)aubert(at)gmail(dot)com>
"""
@gaubert
gaubert / mtserver.py
Created December 15, 2010 15:19
0MQ zguide mtserver python implementation
"""
Multithreaded Hello World server
Author: Guillaume Aubert (gaubert) <guillaume(dot)aubert(at)gmail(dot)com>
"""
import time
import threading
import zmq