Skip to content

Instantly share code, notes, and snippets.

@guilleJB
guilleJB / arp_ip.py
Last active October 30, 2024 13:16
ARP on fixed IP
import subprocess
from datetime import datetime
ip_addr = 'XX.xx.xx.xx'
mac_addr = 'XX:XX:XX:XX:XX'
server_name = 'SERVER_NAME'
log_file = 'path/log'
command = 'arp {}'.format(ip_addr)
process = subprocess.Popen(command.split(' '), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = process.communicate()
if mac_addr not in out:
@guilleJB
guilleJB / clean_redis_keys.py
Created October 25, 2024 11:36 — forked from polsala/clean_redis_keys.py
Clean not used redis keys since x seconds
def clean_idle_redis_keys(redis_host='192.168.0.4', redis_port=6379, db=0, startswithkey='rq', idletime=604800):
import redis
from tqdm import tqdm
r = redis.StrictRedis(host=redis_host, port=redis_port, db=db)
for key in tqdm(r.scan_iter("*")):
idle = r.object("idletime", key)
# idle time is in seconds.
if idle > idletime and key.startswith(startswithkey):
print("Deleting {}".format(key))
r.delete(key)
@guilleJB
guilleJB / setup-ubuntu-jammy-jellyfish.md
Created December 8, 2022 14:52 — forked from ahasverus/setup-ubuntu-jammy-jellyfish.md
Setup Ubuntu 20.04 on Lenovo X1 Carbon 7th Gen

Setup Ubuntu 22.04 on Lenovo X1 Carbon 7th Gen

SYSTEM SECURITY

Update System

@guilleJB
guilleJB / SimpleHTTPServerWithUpload.py
Created September 1, 2022 13:15 — forked from UniIsland/SimpleHTTPServerWithUpload.py
Simple Python Http Server with Upload
#!/usr/bin/env python
"""Simple HTTP Server With Upload.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
"""
@guilleJB
guilleJB / gist:8e41e3fa293f3ac3fc91833be66027ea
Created June 16, 2020 22:47 — forked from mtigas/gist:952344
Mini tutorial for configuring client-side SSL certificates.

Client-side SSL

For excessively paranoid client authentication.


Updated Apr 5 2019:

because this is a gist from 2011 that people stumble into and maybe you should AES instead of 3DES in the year of our lord 2019.

some other notes:

@guilleJB
guilleJB / gist:fca761b0c83270694f8b910a01eb230d
Last active April 13, 2020 14:27 — forked from jaumef/Ainstall_wkhtmltopdf.sh
Webkit Header HTML to PDF binaries for linux on version 0.12.2.1
We couldn’t find that file to show.
@guilleJB
guilleJB / oauth_client.py
Created December 17, 2019 22:51 — forked from utsengar/oauth_client.py
oAuth client - python
"""
The MIT License
Source: https://github.com/simplegeo/python-oauth2/blob/master/example/client.py
Copyright (c) 2007 Leah Culver
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
@guilleJB
guilleJB / nginx_reverse_for_notebook
Created November 20, 2019 17:06 — forked from kent119/nginx_reverse_for_notebook
Config Nginx as a reverse proxy for Jupyter notebook on VPS
# /etc/nginx/sites-enabled/some.domain
# Change the server name {some.domain}
# Change the {host.of.notebook} and {port} in the following locations
server {
listen 80;
# Change the server name {some.domain}
server_name some.domain;
location / {
# Change the {host.of.notebook} and {port}
proxy_pass http://host.of.notebook:port;
@guilleJB
guilleJB / Directions for creating PEM files
Created October 25, 2018 10:54 — forked from dain/Directions for creating PEM files
Create Java KeyStore from standard PEM encoded private key and certificate chain files
# To regenerate the test key and certificates
# Generate an RSA private key and convert it to PKCS8 wraped in PEM
openssl genrsa 2048 | openssl pkcs8 -topk8 -inform pem -outform pem -nocrypt -out rsa.key
# Generate a certificate signing request with the private key
openssl req -new -key rsa.key -out rsa.csr
# Sign request with private key
openssl x509 -req -days 10000 -in rsa.csr -signkey rsa.key -out rsa.crt
@guilleJB
guilleJB / git-squash.sh
Created January 4, 2018 16:04 — forked from favila/git-squash.sh
git-squash: script to create a squashed patch from a branch.
#! /bin/sh
# Produce a squash-commit patch from a branch of changes
MASTER=$1
PATCHBRANCH=$2
SQUASHBRANCH="$PATCHBRANCH-squash"
MESSAGE=$3
git checkout -b $SQUASHBRANCH $MASTER &&
git merge --squash $PATCHBRANCH &&
git commit -a -m "$MESSAGE" &&