sudo yum -y update
I'm not a big fan of their default bash prompt:
echo "export PS1='[\D{%F %T}]\n\[\e]0;\w\a\]\[\e[32m\]\u:\[\e[33m\]\w\[\e[0m\]\n\$ '" >> ~/.bashrc
source ~/.bashrc
| # This Source Code Form is subject to the terms of the Mozilla Public | |
| # License, v. 2.0. If a copy of the MPL was not distributed with this | |
| # file, You can obtain one at https://mozilla.org/MPL/2.0/. | |
| # Context: https://stackoverflow.com/a/56701174/149900 | |
| from io import StringIO | |
| WHITESPACE = " \t\r\n" |
(In Ktor: 1.6.2)
application.conf
...
jwt {
issuer = "https://cognito-idp.ap-northeast-1.amazonaws.com/__SPECIFY_POOL_ID_HERE__"
audience = "__SPECIFY_CLIENT_ID_HERE__"
realm = "ktor sample app"
| import sys | |
| # choose() is the same as computing the number of combinations. Normally this is | |
| # equal to: | |
| # | |
| # factorial(N) / (factorial(m) * factorial(N - m)) | |
| # | |
| # but this is very slow to run and requires a deep stack (without tail | |
| # recursion). | |
| # |
| from PIL import Image | |
| from PIL.ExifTags import TAGS, GPSTAGS | |
| def get_exif_data(image): | |
| """Returns a dictionary from the exif data of an PIL Image item. Also converts the GPS Tags""" | |
| exif_data = {} | |
| info = image._getexif() | |
| if info: | |
| for tag, value in info.items(): | |
| decoded = TAGS.get(tag, tag) |
| config: | |
| target: "http://localhost:8000" | |
| http: | |
| timeout: 10 # Responses have to be sent within 10 seconds or the request will be aborted | |
| processor: "./processor.js" | |
| phases: | |
| # Create 100 virtual users every second for 60 seconds | |
| - duration: 60 # seconds | |
| arrivalRate: 100 # virtual users |
| """ | |
| Simple worker showing different worker ids sharing/incrementing the same memory region | |
| uwsgi --http :9090 --wsgi-file foobar.py --master --processes 4 --threads 2 --stats 127.0.0.1:9191 --sharedarea 2 | |
| Then just keep refreshing localhost:9090 | |
| """ | |
| import uwsgi | |
| INT_ORDS = {48, 49, 50, 51, 52, 53, 54, 55, 56, 57} |
Sometimes a Python script will simply hang forever with no indication of what is going wrong. Perhaps it's polling a service that will never return a value that allows the program to move forward.
Here's a way to see where the program is currently stuck, using pyrasite a tool for injecting code into running Python processes.
Install gdb.
| # Credit for this: Nicholas Swift | |
| # as found at https://medium.com/@nicholas.w.swift/easy-a-star-pathfinding-7e6689c7f7b2 | |
| from warnings import warn | |
| import heapq | |
| class Node: | |
| """ | |
| A node class for A* Pathfinding | |
| """ |