Skip to content

Instantly share code, notes, and snippets.

@milesrichardson
milesrichardson / inherit_environment_variables_from_pid_1.md
Created January 21, 2023 07:35
inherit environment variables from PID 1

You can inherit the environment variables from PID 1 by iterating over the list of null-terminated strings in /proc/1/environ, parsing the first characters up to the first = as the variable name, setting the remaining value as that variable, and exporting it.

The Code Snippet

This works with multiline environment variables, and environment variables with arbitrary values, like strings, including = or JSON blobs.

Paste this in your current terminal session to inherit the environment variables from PID 1:

@vyach-vasiliev
vyach-vasiliev / ReadMe.md
Last active April 22, 2023 00:44
One element CSS Snow by Keith Clark
@DavidBuchanan314
DavidBuchanan314 / figlett.py
Last active August 18, 2024 03:00
Demo of rendering TrueType fonts in the terminal, in a figlet-like way. (p.s. it segfaults occasionally, lol)
import cairocffi
import pangocffi
import pangocairocffi
import sys
import os
try:
width, height = os.get_terminal_size().columns, 1024
except OSError:
# There doesn't seem to be a neat way of figuring out the size of some text without
#!/usr/bin/awk -f
# https://unix.stackexchange.com/a/495105
# usage: match_block START END MATCH [FILE]
# output a whole block of text enclosed by START and END that contains MATCH
BEGIN {
pstart=ARGV[1];
pstop=ARGV[2];
pmatch=ARGV[3];
ARGV[1]=ARGV[4];
ARGC=2;
@BH1SCW
BH1SCW / create-centos-6.5-mini-unattended-iso.sh
Created January 2, 2023 18:01 — forked from skiane/create-centos-6.5-mini-unattended-iso.sh
# This script create a Centos Minimal Unattended ISO
# This script create a Centos Minimal Unattended ISO
# This method is based on excellent article http://pyxlmap.net/technology/software/linux/custom-centos-iso
#
# This script has be tested with CentOS 6.5
# TODO:
# * test package update to reduce the update task on the target system. The following command downloads all updates :
# (cd $CENTOS_CUSTOM_PATH/Packages ; yumdownloader $(for i in *; { echo ${i%%-[0-9]*}; } ) )
# Some global settings :
@rikkihamano
rikkihamano / trss.go
Created December 28, 2022 11:41
convert Telegram Channel to RSS Feed
/*
MIT License
Copyright (c) 2020 Richard Chen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@deepaste
deepaste / services.py
Last active May 30, 2023 12:48
Dictionary of UDP and TCP services - Python
# Network services, Internet style
# Updated from https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml .
SERVICES = {
1: "tcpmux",
7: "echo",
7: "echo",
9: "discard",
9: "discard",
11: "systat",
13: "daytime",
@JoeBlakeB
JoeBlakeB / discordVersionUpdater.py
Last active December 8, 2024 11:14
Update the Discord build_info.json file so that you can still use it when there is a new version available.
#!/usr/bin/env python3
# Copyright (C) 2022 Joe Baker (JoeBlakeB)
# This program is free software under the GPLv3 license.
#
# This script is used to update the version number in the Discord
# build_info.json file so that you do not need to manually update it,
# or wait for the package maintainer to update it.
# Discord will instead open normally and will not prompt you to update.
#
# Requirements: python3 and requests
@neggles
neggles / Download-File.ps1
Last active July 19, 2023 06:53
download a file with powershell w/o using invoke-webrequest or DoSing yourself with progress prompts
function Download-File {
[CmdletBinding()]
param (
[Parameter(Mandatory = $True,
Position = 0,
HelpMessage = 'The URI of the file to download.')]
[ValidateNotNullOrEmpty()]
[Alias('Url', 'FileUri')]
[String]$Uri,
# Specifies a path to one or more locations.
@SpareSimian
SpareSimian / asntoipset.py
Created November 30, 2022 01:52
Convert a list of records from iptoasn.com to a firewalld ipset XML file.
#!/usr/bin/env python3
""" Convert a list of records from iptoasn.com to a firewalld ipset XML file.
Download https://iptoasn.com/data/ip2asn-v4.tsv.gz, uncompress, filter
with grep, and feed to this script to generate a file to place in
/etc/firewalld/ipsets for use in firewall rules.
Example:
wget -q -O - https://iptoasn.com/data/ip2asn-v4.tsv.gz | \