Skip to content

Instantly share code, notes, and snippets.

View jessejlt's full-sized avatar

Jesse Thompson jessejlt

View GitHub Profile
# nuke the database
curl -XDELETE localhost:9200/test
# post 3 items, 2 of which have the same <type>
curl -XPOST localhost:9200/test/item -d '
{
"color": "yellow",
"type": "crayon"
}'
@jessejlt
jessejlt / about.txt
Created October 23, 2011 03:20
nginx, flask, and file downloads
Okay so here's the setup:
[-] The primary server API is exposed via Flask (Python) and all static files, including all html, css, js is served by nginx.
[-] Python is exposing an API at url http://domain.com/api/download/<file_id>, where file_id is a database id for the file that we're interested in downloading.
1. User wants to download a file, so we spawn a new window with the url '/api/download/<file_id>'
2. Nginx intercepts the request, sees that it starts with /api/, and then forwards the request to Flask, which is being served on port 5000.
3. Flask routes the request to its download method, retrieves the pertinent data from the file_id, and constructs additional header settings to make nginx happy and to force the browser to see the file stream as a download request instead of the browser just trying to open the file in a new window. Flask then returns the modified header stream to nginx
4. Nginx is finally ready to do some work. While parsing the headers for the incoming request, it encounters "X
@jessejlt
jessejlt / client_side_script.js
Created September 9, 2011 18:34
nginx & socket.io
var socket = io.connect('http://mydomain.com:4000');
@jessejlt
jessejlt / elasticsearch.yml
Created August 19, 2011 21:47
EalsticSearch synonym configuration
# The cluster name
cluster.name: media
# Path Settings
#path.conf: /path/to/conf
#path.data: /path/to/data
#path.work: /path/to/work
#path.logs: /path/to/logs
@jessejlt
jessejlt / gist:1025732
Created June 14, 2011 19:57
dim background on mouse-over
#login {
z-index: 2;
}
#login:after {
content: "";
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;