Skip to content

Instantly share code, notes, and snippets.

View pythoninthegrass's full-sized avatar

pythoninthegrass

View GitHub Profile
@pythoninthegrass
pythoninthegrass / launch-GRD.sh
Created July 30, 2023 19:32 — forked from greyltc/launch-GRD.sh
configures then activates gnome-remote-desktop from the command line
#!/usr/bin/env bash
# run this on the remote terminal machine, as auser with sudo powers, probably through a remote ssh shell
# this will overwrite all the settings it touches
# the name of the user to run these commands as
TARGET_USER=jane
# we need an inlocked desktop session. we can either start a new autologin one or unlock an existing one
@pythoninthegrass
pythoninthegrass / swap_off.sh
Last active June 26, 2023 17:06 — forked from anildigital/cleanup_swap.md
Cleanup swap space on macOS
#!/usr/bin/env bash
# To see current swap usage
sysctl -a | grep swap
# Monitor swap usage
vm_stat 60
# Use only when when your system is in a very bad shape
sudo pkill -HUP -u _windowserver
@pythoninthegrass
pythoninthegrass / Diablo II.ahk
Created June 13, 2023 22:03 — forked from fabd/Diablo II.ahk
A script I use to center the game window and play at exactly 2x the original resolution to avoid stretching and blurry image.
; Diablo II LoD
;
; Instructions:
;
; 1) Start the game in windowed mode (eg. "-sndbkg -skiptobnet -w" options in shortcut).
;
; 2) Press Ctrl Alt f , Ctrl Alt h to set game to 1600x1200 centered on the desktop.
;
;
; Ctrl Alt f Toggle active window title bar.

Loading variables from .env files in Ansible

Ansible has various ways of looking up data from outside sources, including plain text password files, CSV files and INI files. But it doesn't seem to have a lookup for .env files, as used in Laravel projects, also available for PHP, Ruby, Node.js, Python and others.

One option is to launch Ansible with the Ruby dotenv command line script... But that requires Ruby, which seems like overkill to me.

So here is a simpler solution that I use. It consists of:

  1. The .env file itself
  2. A small shell script that loads the .env file into environment variables - ansible-playbook.sh
@pythoninthegrass
pythoninthegrass / README.md
Last active February 28, 2023 21:13 — forked from nordineb/readme.MD
multipass + qemu on macOS

multipass + qemu on macOS

Multipass can launch and run virtual machines and configure them with cloud-init like a public cloud

Usage

brew install multipass libvirt
brew services start libvirt
multipass set local.passphrase=<foo>    # `multipass set local.passphrase` avoids stdout creds
multipass authenticate
multipass get local.driver
@pythoninthegrass
pythoninthegrass / openssl_commands.md
Created January 20, 2023 21:13 — forked from Hakky54/openssl_commands.md
Some list of openssl commands for check and verify your keys

OpenSSL 🔐

Install

Install the OpenSSL on Debian based systems

sudo apt-get install openssl
@pythoninthegrass
pythoninthegrass / convert.py
Last active November 6, 2022 18:39 — forked from aolle/convert.py
Convert Nimbus Notes HTML to Markdown for UpNote
#!/usr/bin/env python3
"""
NOTE:
Extended into a full repo at https://github.com/pythoninthegrass/convert_html_md
Any future work will be posted there.
SOURCES:
https://gist.github.com/aolle/6e595650391deef79ffb1c9bb38fb6e9
https://dev.to/kcdchennai/python-decorator-to-measure-execution-time-54hk
@pythoninthegrass
pythoninthegrass / osascript_close_windows.sh
Last active November 1, 2022 17:11 — forked from Koze/CloseAllWindows.scpt
Close all windows with AppleScript
#!/usr/bin/env bash
# SOURCE: https://gist.github.com/Koze/2e1a9bf967b2bf865fc9
# close all windows (e.g., thousands of finder windows from unarchiver)
osascript -e 'tell application "Finder" to close windows'
## index 1 is frontmost window
# osascript 'tell application "Finder" to close window 1'
@pythoninthegrass
pythoninthegrass / clean_code.md
Created May 24, 2022 04:55 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@pythoninthegrass
pythoninthegrass / get-oauth2-token-meetup-api
Created May 4, 2022 07:03 — forked from valeriocos/get-oauth2-token-meetup-api
Get a bearer/OAuth2 token for Meetup application-only requests in Python3
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright (C) 2015-2019 Bitergia
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#