Skip to content

Instantly share code, notes, and snippets.

View MorningLightMountain713's full-sized avatar

David White MorningLightMountain713

View GitHub Profile
@MorningLightMountain713
MorningLightMountain713 / gist:2188098ab14d25e70b7ea9e8bc9b0f8d
Created October 9, 2024 08:05 — forked from igniteflow/gist:4474040
Create a folder and set user:group with Python's os module
import os
import pwd
file_path = '/tmp/example'
if not os.path.exists(file_path):
os.makedirs(file_path) # creates with default perms 0777
uid, gid = pwd.getpwnam('root').pw_uid, pwd.getpwnam('www-data').pw_uid
os.chown(file_path, uid, gid) # set user:group as root:www-data
# go check with ls -lah /tmp/example
@MorningLightMountain713
MorningLightMountain713 / dbus_api.py
Created October 7, 2024 13:44 — forked from gaurav36/dbus_api.py
Using dbus API in python for managing services in Linux
import sys
import dbus
bus = dbus.SystemBus()
systemd = bus.get_object('org.freedesktop.systemd1', '/org/freedesktop/systemd1')
manager = dbus.Interface(systemd, 'org.freedesktop.systemd1.Manager')
def disable_and_stop(service):
"""
disable_and_stop and stop method will check if the service is already running or not in system.
@MorningLightMountain713
MorningLightMountain713 / streaming_tar.py
Created September 12, 2024 20:29 — forked from abbbi/streaming_tar.py
streaming_tar.py
#!/usr/bin/env python3
#
# Building a tar file chunk-by-chunk.
#
# This is a quick bit of sample code for streaming data to a tar file,
# building it piece-by-piece. The tarfile is built on-the-fly and streamed
# back out. This is useful for web applications that need to dynamically
# build a tar file without swamping the server.
import os
import sys
@MorningLightMountain713
MorningLightMountain713 / streaming_tar.py
Created September 12, 2024 20:25 — forked from ateska/streaming_tar.py
Streaming asynchronous non-blocking tar using Python and asyncio
import os.path
import aiohttp.web
async def get_tar(request):
'''
AIOHTTP server handler for GET request that wants to download files from a `directory` using TAR.
'''
directory = <specify the directory>
response = aiohttp.web.StreamResponse(
@MorningLightMountain713
MorningLightMountain713 / SecureBoot.md
Created July 15, 2024 10:06 — forked from rgl/SecureBoot.md
Enroll certificates in UEFI OVMF Secure Boot

List the secure boot trust stores:

apt-get install -y efitools
efi-readvar

To take ownership of the system by following the next steps.

Create our own Platform Key (PK), Key Exchange Key (KEK), and Code Signing CAs:

#!/bin/bash
set -o errexit
source ./library
# Entry point of the script.
# If makes sure that the user supplied the right
# amount of arguments (image_name)
# and then performs the main workflow:
# 1. retrieve the image digest
# 2. retrieve the layer info of image
@MorningLightMountain713
MorningLightMountain713 / gist:7cd8fd28000069d0f036410bbe8bdd02
Created May 4, 2024 22:00 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@MorningLightMountain713
MorningLightMountain713 / deploy.py
Created March 6, 2024 21:32
Sandbox code to register flux app (needs refactor and httpx)
import time
import hashlib
import json
from rich.pretty import pprint
from Cryptodome.Random import get_random_bytes
from bitcoin.wallet import CBitcoinSecret, P2PKHBitcoinAddress
import requests
from bitcoin.signmessage import BitcoinMessage, VerifyMessage, SignMessage
@MorningLightMountain713
MorningLightMountain713 / README.md
Created February 20, 2024 09:54 — forked from etiennetremel/README.md
Simple Wireguard setup as VPN server and multiple clients

Simple WireGuard configuration

1 server, 2 clients

Getting started

Install Wireguard on all machines.

Generate all keys