Skip to content

Instantly share code, notes, and snippets.

Avatar

Nathan Van Gheem vangheem

View GitHub Profile
@vangheem
vangheem / cpu_bound_flask.py
Created Jun 11, 2019
Simple CPU bound flask app
View cpu_bound_flask.py
# ./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__)
View service-loader.py
# 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.')
View rocksdb-Dockerfile
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
View gist:ec00bdceab1e9e48778500e3d9f9f1fe
### 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:
View keybase.md

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
Export all your tablo vidoes
View tablo-export.py
#
# Requirements:
# - Python >= 3.5
# - requests
# - aiohttp
#
import argparse
import asyncio
import json
import os
@vangheem
vangheem / view.py
Created Feb 27, 2017
Streaming s3 file for downloads
View view.py
# 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']
View patterns.js
/* globals define */
define(function(){
'use strict';
var REGISTERED = {};
var register = function(name, config){
REGISTERED[name] = config;
};
View example-image-tile.pt
<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>
View example-image-tile.py
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