start new:
tmux
start new with session name:
tmux new -s myname
from pprint import pprint | |
import jinja2 | |
import markdown | |
HTML_TEMPLATE = """{% macro get_html() %} | |
{{ content | markdown }} | |
{% endmacro %} | |
{% set html_content = get_html() %} | |
Title from Markdown meta-data: {{ get_title() }} |
packer build packer.json 2>&1 | sudo tee output.txt | |
tail -2 output.txt | head -2 | awk 'match($0, /ami-.*/) { print substr($0, RSTART, RLENGTH) }' > sudo ami.txt |
A minimal HTTP server in python. It sends a JSON Hello World for GET requests, and echoes back JSON for POST requests.
python server.py 8009
Starting httpd on port 8009...
curl http://localhost:8009
{"received": "ok", "hello": "world"}
State | State FIPS | County FIPS | IECC Climate Zone | IECC Moisture Regime | BA Climate Zone | County Name | |
---|---|---|---|---|---|---|---|
AK | 02 | 013 | 7 | N/A | Very Cold | Aleutians East | |
AK | 02 | 016 | 7 | N/A | Very Cold | Aleutians West | |
AK | 02 | 020 | 7 | N/A | Very Cold | Anchorage | |
AK | 02 | 050 | 8 | N/A | Subarctic | Bethel | |
AK | 02 | 060 | 7 | N/A | Very Cold | Bristol Bay | |
AK | 02 | 068 | 7 | N/A | Very Cold | Denali | |
AK | 02 | 070 | 8 | N/A | Subarctic | Dillingham | |
AK | 02 | 090 | 8 | N/A | Subarctic | Fairbanks North Star | |
AK | 02 | 100 | 7 | N/A | Very Cold | Haines |
from pyramid.security import NO_PERMISSION_REQUIRED | |
def includeme(config): | |
config.add_directive( | |
'add_cors_preflight_handler', add_cors_preflight_handler) | |
config.add_route_predicate('cors_preflight', CorsPreflightPredicate) | |
config.add_subscriber(add_cors_to_response, 'pyramid.events.NewResponse') | |
class CorsPreflightPredicate(object): |
#!/usr/bin/nft -f | |
# ipv4/ipv6 Simple & Safe Firewall | |
# you can find examples in /usr/share/nftables/ | |
table inet filter { | |
chain input { | |
type filter hook input priority 0; | |
# allow established/related connections | |
ct state {established, related} accept |
/** | |
* Retrieve the array key corresponding to the largest element in the array. | |
* | |
* @param {Array.<number>} array Input array | |
* @return {number} Index of array element with largest value | |
*/ | |
function argMax(array) { | |
return array.map((x, i) => [x, i]).reduce((r, a) => (a[0] > r[0] ? a : r))[1]; | |
} |
apiVersion: extensions/v1beta1 | |
kind: Deployment | |
metadata: | |
labels: | |
app: myproject | |
name: myproject | |
namespace: default | |
spec: | |
progressDeadlineSeconds: 600 | |
replicas: 1 |
from collections import OrderedDict | |
# >>> import cache_dict | |
# >>> c = cache_dict.CacheDict(cache_len=2) | |
# >>> c[1] = 1 | |
# >>> c[2] = 2 | |
# >>> c[3] = 3 | |
# >>> c | |
# CacheDict([(2, 2), (3, 3)]) | |
# >>> c[2] |