This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# when I get lazy I put my bash wizard hat away and put on my vim wizard hat | |
echo bash 4.4.23 | |
sudo docker run bash:4.4.23 -c 'RANDOM=5; (md5sum) <<< $RANDOM' | |
sudo docker run bash:4.4.23 -c 'RANDOM=5; (md5sum) <<< $RANDOM' | |
echo | |
echo bash 4.4 | |
sudo docker run bash:4.4 -c 'RANDOM=5; (md5sum) <<< $RANDOM' | |
sudo docker run bash:4.4 -c 'RANDOM=5; (md5sum) <<< $RANDOM' | |
echo | |
echo bash 4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pessimist = [2, 2, 3, 2] | |
optimist = [4, 4, 5, 4] | |
def min_max(scores): | |
return list(map(lambda x : (x-min(scores))/(max(scores)-min(scores)), scores)) | |
print(min_max(pessimist)) # [0, 0, 1, 0] | |
print(min_max(optimist)) # [0, 0, 1, 0] | |
def div_avg(scores): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Cursor shape switch based on mode: | |
# https://unix.stackexchange.com/questions/547/make-my-zsh-prompt-show-mode-in-vi-mode | |
KEYTIMEOUT=5 | |
function zle-keymap-select { | |
if [[ ${KEYMAP} == vicmd ]] || | |
[[ $1 = 'block' ]]; then | |
echo -ne '\e[1 q' | |
elif [[ ${KEYMAP} == main ]] || |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Requires sqawk, datamash, and jq | |
# input tab delmited columns, newline delmited rows: | |
# foo bar | |
# 1 a | |
# 2 b | |
# tbr2j (rows to json) | |
#[ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env bash | |
# This script interrogates the system and constructs a JSON representation of the pipeline that it is part of. | |
# It is a proof-of-concept. A more useful utility would accept a parameter that targets not the pipeline of the | |
# utility itself, but insted that of its parent, or grandparent, or great grandparent, or whatever. Such a tool could | |
# be used to sense the correct output-format based on who is listening downstream. | |
# Usage Example: | |
# cat -b | ./luigi | cat -e | jq . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from locust import HttpLocust, TaskSet, task | |
import json | |
class UserBehavior(TaskSet): | |
def on_start(self): | |
# this retrieves a coookie from the server and stores in in a RequestsCookieJar: self.locust.client.cookes | |
# that is, it stores the cookie on an instance of this class, not the class itself (as your code does) | |
# your server may have different requirements for how the login request should look, but this worked for me | |
self.client.post("/login", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env bash | |
bg_process() | |
{ | |
sleep 1 | |
for i in a b c d e f g h i j k l m n o p | |
do | |
echo $i | |
sleep 1 | |
done | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
❯ docker run --rm -it ubuntu:18.04 | |
# apt update && apt install -y python3-pip python3-venv | |
... output omitted .. | |
# python3 -m venv ~/venv | |
# source ~/venv/bin/activate | |
(venv) # python -c 'import slackclient' | |
Traceback (most recent call last): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for event in slack_events: | |
if event['type'] == 'message': | |
mentiond_id, message = parse_direct_mention(event['text']) | |
# is it for me? | |
if mentiond_id == self_id: | |
# classify recipient | |
from_user = 'subtype' not in event |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
print(json.dumps({"JSON1" : "Hello World!", | |
"JSON2" : "Hello my World!", | |
"JSON3" : {"key1" : "value1"})) |