Skip to content

Instantly share code, notes, and snippets.

@paitonic
paitonic / docker.py
Created April 21, 2023 16:46
Example using argparse to build CLI resembling Docker
# docker ps
# docker ps -a
# docker ps --all
# docker volume ls
# docker volume ls -f dangling=true
# docker volume ls -q
# python3 -m pip install aiosmtpd
python3 -m aiosmtpd -ddd -n
# send.py
import smtplib
from email.message import EmailMessage
smtp = smtplib.SMTP(host='localhost', port=8025)
msg = EmailMessage()
@paitonic
paitonic / resizable.html
Created November 26, 2022 09:13
resizeable
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" href="styles.css">
<style>
body {
margin: 200px 200px;
}
function Get-Games {
# Game installation locations
$gameDirectoryNames = @("Genshin Impact", "Diablo II Resurrected")
return (
(Get-ChildItem "C:\Program Files (x86)\Steam\steamapps\common") +
(Get-ChildItem "C:\Program Files (x86)\GOG Galaxy\Games") +
(Get-ChildItem "C:\Program Files (x86)\Ubisoft\Ubisoft Game Launcher\games") +
(Get-ChildItem "C:\Program Files" | Where-Object { $gameDirectoryNames.Contains($_.Name) }) +
@paitonic
paitonic / bindings.txt
Created September 22, 2021 18:12
micro bindings.json
Key Combination Code Action
Alt-j multi cursor selection, "SpawnMultiCursor"
// selection
Shift+Up [1;2A]
Shift+Right [1;2C]
Shift+Down [1;2B]
Shift+Left [1;2D]
Shift+Home [1;2H] -- select to start of the line
@paitonic
paitonic / cache-api-demo.js
Last active August 21, 2021 13:30
cache-api
// Example 1 - fetch()
function fetchExample() {
appCacheName = 'my-app';
async function fetchData(url) {
// remove from cache
// const keys = await caches.keys();
// for (const key of keys) {
// console.log('deleting: ', key)
// caches.delete(key);
// }
@paitonic
paitonic / .tmux.conf
Last active January 16, 2021 20:34
.tmux.conf
set -g mouse on
set-option -g default-command bash
set -g default-terminal "screen-256color"
t2.nano
### Elastic Beanstalk, Single Instance
# single task
siege \
--concurrent=10 \
--reps=100 \
--header="Authorization: Bearer abc" \
http://some-ec2-instance.compute-1.amazonaws.com/task/1
@paitonic
paitonic / usePreventBrowserBack.js
Created June 22, 2020 18:54
usePreventBrowserBack.js
// https://medium.com/@subwaymatch/disabling-back-button-in-react-with-react-router-v5-34bb316c99d7
export const usePreventBrowserBack = () => {
const currentPathname = useRef(null);
const currentSearch = useRef(null);
const history = useHistory();
useEffect(() => {
history.listen((newLocation, action) => {
if (action === "PUSH") {
if (
from flask import Flask, jsonify, request, Response, make_response
import requests
# python3 -m venv venv
# . venv/bin/activate
# pip install flask requests
#
# export FLASK_APP=server.py
# export FLASK_ENV=development