Skip to content

Instantly share code, notes, and snippets.

View isidroas's full-sized avatar

Isidro isidroas

  • Spain
  • 10:21 (UTC +02:00)
View GitHub Profile
@srugano
srugano / noroot_tcpdump.sh
Created October 9, 2021 12:23
Enable tcpdump for non-root users on Debian/Ubuntu.
#!/usr/bin/env bash
# NOTE: This will let anyone who belongs to the 'pcap' group
# execute 'tcpdump'
# NOTE2: User running the script MUST be a sudoer. It is
# convenient to be able to sudo without a password.
sudo groupadd pcap
sudo usermod -a -G pcap $USER
@scimad
scimad / age_not_okay.html
Last active June 24, 2024 14:59
Basic python HTTP server and manipulation of POST data
<!DOCTYPE html>
<html>
<head>
<title>Not eligible</title>
</head>
<body>
<h1>Oops, you are too young to have your own conscience. Try again next year.</h1>
</body>
</html>
@GLMeece
GLMeece / Sphinx_Setup_for_autodoc.md
Last active November 29, 2023 14:22
Setting up Sphinx for generating documentation from DocStrings, leveraging the Napoleon extension.

Sphinx Setup for autodoc

Sphinx is a documentation generator that is the de facto standard for Python projects. The official documentation can be a bit daunting as it includes so many options, it's hard to know where to start.

Note: This Gist was updated on 04/04/2019 to accomodate a newer version of Sphinx, as well as Python 3.7. YMMV!

This document is written with the following presuppositions:

@minhoryang
minhoryang / Dockerfile
Last active May 21, 2024 11:46
docker-ubuntu-build-essential
FROM ubuntu:latest
RUN apt-get update
RUN apt-get install -y --no-install-recommends apt-utils build-essential sudo git
RUN useradd -m docker && echo "docker:docker" | chpasswd && adduser docker sudo
USER docker
@CMCDragonkai
CMCDragonkai / keyboard_enter_return_and_backspace_delete.md
Last active January 8, 2024 16:43
CLI: Keyboard Enter/Return and Backspace/Delete

Keyboard Enter/Return and Backspace/Delete

In older keyboards, enter and return are 2 different keys. Old Macintosh keyboards set it up so that the Return sends a carriage return \r, while the Enter key sends a linefeed \n. However many computers nowadays do not have separate Return and Enter keys. So what do these keyboards send? While it actually depends on your operating system, its keyboard settings, and the application you're interacting with. Windows applications will generally interpret \r\n as a newline, while Mac OS 9 and earlier interpreted \r as a newline, and finally Unix with Mac OS X and later will interpret \n as a newline. People involved in the technology space will generally use the convention of \n as the newline, with \r as an artifact of computing history.

A similar situation occurs with the Backspace and Del keys. Modern convention has settled on the behaviour wher

@drmalex07
drmalex07 / README-oneshot-systemd-service.md
Last active June 25, 2024 17:52
An example with an oneshot service on systemd. #systemd #systemd.service #oneshot

README

Services declared as oneshot are expected to take some action and exit immediatelly (thus, they are not really services, no running processes remain). A common pattern for these type of service is to be defined by a setup and a teardown action.

Let's create a example foo service that when started creates a file, and when stopped it deletes it.

Define setup/teardown actions

Create executable file /opt/foo/setup-foo.sh:

@bsphere
bsphere / py_exceptions.py
Last active November 17, 2022 15:01
How to catch exceptions raised by Python worker threads
import Queue
import threading
class WorkerThread(threading.Thread):
def __init__(self, q):
super(WorkerThread, self).__init__()
self q = q
self.exception = None