Skip to content

Instantly share code, notes, and snippets.

View gaubert's full-sized avatar

Guillaume Aubert gaubert

View GitHub Profile
# 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 / 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
anonymous
anonymous / gist:864108
Created March 10, 2011 13:44
@RequestMapping(value = "handle", method = RequestMethod.GET)
public void handle(HttpServletRequest request, HttpServletResponse response) throws IOException{
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
SearchResponse searchResponse = buildRequest(request).execute().actionGet();
builder.startObject();

DNS and DotCloud

In the following, replace example.net with your domain name. XXX.XXX.XXX.XXX is the IP of the reverse proxy.

DNS entries

Required DNS entries

example.net. 300 IN A XXX.XXX.XXX.XXX

@aseemk
aseemk / gist:3905781
Created October 17, 2012 14:23
Wrapper script around gmvault that allows setting default options.
#!/usr/bin/env bash
#
# Wrapper around gmvault binary that sets default options.
GMVAULT_DIR="$HOME/Dropbox/Applications/Utilities/gmvault-v1.7-beta/bin/"
DB_DIR="$HOME/Dropbox/.gmvault-db"
# Run in a sub-shell since we need to change directories:
(
cd $GMVAULT_DIR
@tacaswell
tacaswell / euler_rot.py
Created October 29, 2012 01:35
A simple function that implements rotation by Euler angles.
import numpy as np
def euler_rot(XYZ,phi,theta,psi):
'''Returns the points XYZ rotated by the given euler angles'''
ERot = np.array([[np.cos(theta)*np.cos(psi),
-np.cos(phi)*np.sin(psi) + np.sin(phi)*np.sin(theta)*np.cos(psi),
np.sin(phi)*np.sin(psi) + np.cos(phi)*np.sin(theta)*np.cos(psi)],
[np.cos(theta)*np.sin(psi),
np.cos(phi)*np.cos(psi) + np.sin(phi)*np.sin(theta)*np.sin(psi),
@electronut
electronut / showdata.py
Created May 24, 2013 07:44
Display analog data from Arduino using Python (matplotlib)
################################################################################
# showdata.py
#
# Display analog data from Arduino using Python (matplotlib)
#
# electronut.in
#
################################################################################
import sys, serial
@pithyless
pithyless / gist:1208841
Created September 10, 2011 21:49
Install Python 2.7 (homebrew + pip + virtualenv) on Mac OS X Lion

Install Python

$ brew install readline sqlite gdbm
$ brew install python --universal --framework
$ python --version
Python 2.7

Symlinks...

@0xc0re
0xc0re / check_link.py
Created April 28, 2018 21:32 — forked from DanielKoohmarey/check_link.py
A simple python script to check broken links of a wesite
@truemped
truemped / zmq_tornado_download.py
Created January 13, 2011 14:06
Toy example demonstrating the usage of pyzmq and tornado's AsyncHTTPClient
#
# "THE BEER-WARE LICENSE":
# <truemped at goggle.com> wrote this file. As long as you retain this notice you
# can do whatever you want with this stuff. If we meet some day, and you think
# this stuff is worth it, you can buy me a beer in return Daniel Truemper
#
import time
import zmq