Skip to content

Instantly share code, notes, and snippets.

View vangheem's full-sized avatar

Nathan Van Gheem vangheem

View GitHub Profile
@vangheem
vangheem / cpu_bound_flask.py
Created June 11, 2019 08:15
Simple CPU bound flask app
# ./bin/uwsgi --http 127.0.0.1:5000 --module cpu_bound_flask:app
from flask import Flask
import time
DURATION = 0.5
app = Flask(__name__)
# Usage
# python load.py http://localhost:8080 --concurrency=100 --total=10000
import asyncio
import time
from functools import partial
import aiohttp
import argparse
parser = argparse.ArgumentParser(description='Process some integers.')
FROM ubuntu:18.04
RUN apt-get update && apt-get -y upgrade && apt-get install -y openssh-server vim \
build-essential htop locales cron rsync libssl-dev libffi-dev tmux git gcc libreadline-dev \
curl httpie wget clang-3.9 lldb-3.9 cmake sudo iputils-ping apt-transport-https \
libgflags-dev libsnappy-dev zlib1g-dev libbz2-dev liblz4-dev libzstd-dev libsqlite3-dev
RUN locale-gen en_US.UTF-8
RUN mkdir /var/run/sshd
RUN groupadd developers && useradd --shell /bin/bash --create-home --home-dir /home/developers -g developers developers
### Keybase proof
I hereby claim:
* I am vangheem on github.
* I am vangheem (https://keybase.io/vangheem) on keybase.
* I have a public key ASDWwYJREMp_Tw9pG4omwj4mnLOTJ2a5t5m0CtNRsmmxsQo
To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am vangheem on github.
  • I am vangheem (https://keybase.io/vangheem) on keybase.
  • I have a public key ASCNjRhUMtWBRcsWbhvLA8bxXGTtTbURKVorvouxR9rsdwo

To claim this, I am signing this object:

@vangheem
vangheem / tablo-export.py
Last active May 8, 2017 22:54
Export all your tablo vidoes
#
# Requirements:
# - Python >= 3.5
# - requests
# - aiohttp
#
import argparse
import asyncio
import json
import os
@vangheem
vangheem / view.py
Created February 27, 2017 14:59
Streaming s3 file for downloads
# using aiobotocore and plone.server(aiohttp)
ob = await client.get_object(Bucket=bucket, Key=key)
info = ob['ResponseMetadata']['HTTPHeaders']
resp = aiohttp.web.StreamResponse(headers=aiohttp.MultiDict({
'CONTENT-DISPOSITION': 'attachment; filename="%s"' % self.filename,
'Content-Type': info['content-type']
}))
resp.content_type = info['content-type']
resp.content_length = info['content-length']
/* globals define */
define(function(){
'use strict';
var REGISTERED = {};
var register = function(name, config){
REGISTERED[name] = config;
};
<tal:container tal:define="image python: view.get_image()">
<div class="image-tile-container" tal:define="caption view/data/caption|nothing">
<p class="image" tal:condition="nocall: image">
<img src="${image/absolute_url}/@@images/image/${view/data/scale|large}" alt="${image/Title}" />
<p class="description" tal:condition="caption">${caption}</p>
</p>
<p tal:condition="python: not image">
No image specified
</p>
from plone.tiles import Tile
from plone.app.z3cform.widget import RelatedItemsFieldWidget
from plone.app.standardtiles.image import image_scales
from plone.autoform import directives as form
from plone.supermodel import model
from zope import schema
from zope.component import getMultiAdapter
from zope.component.hooks import getSite
from zope.globalrequest import getRequest
from zope.interface import Invalid