Skip to content

Instantly share code, notes, and snippets.

View jessejlt's full-sized avatar

Jesse Thompson jessejlt

View GitHub Profile
@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 / experiment-pipeline.yaml
Last active May 1, 2019 17:11
concourse experimentation example
jobs:
- name: some experiment
plan:
- task: experiment
config:
platform: linux
run:
path: /bin/bash
args: -exc
- |
@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
package main
import (
"io"
"log"
)
func main() {
w := sink()
@jessejlt
jessejlt / main.go
Created October 8, 2017 16:50
AWS SDK S3 mocking
package main
import (
"fmt"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3"
"github.com/aws/aws-sdk-go/service/s3/s3iface"
)
@jessejlt
jessejlt / about.md
Created July 2, 2013 06:11
Some ECMAScript 6 features I'm excited about
@jessejlt
jessejlt / master.yml
Created May 14, 2012 19:02
ElasticSearch zen unicast discovery
cluster.name: elasticsearch_media
node.name: "media-dev"
node.master: true
node.data: true
discovery.zen.ping.multicast.enabled: false
discovery.zen.ping.unicast.hosts: ["153.32.228.250[9300-9400]", "10.122.234.19[9300-9400]"]
@jessejlt
jessejlt / command line example
Created April 6, 2012 19:37
nosetests running a single test programmatically
$ nosetests flask.testsuite.testing:TestToolsTestCase.test_environ_defaults
.
----------------------------------------------------------------------
Ran 1 test in 0.014s
OK
@jessejlt
jessejlt / nginx.conf
Created March 23, 2012 17:20
Flask + nginx + uwsgi
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:4050;
}
curl -XDELETE localhost:9200
curl -XPOST localhost:9200/test/tools -d '
{
"type": "crayon",
"color": "red"
}'
curl -XPOST localhost:9200/test/tools -d '
{