Skip to content

Instantly share code, notes, and snippets.

@javierarilos
javierarilos / py-code-update.py
Last active December 28, 2023 05:46
Sample of reloading a class definition in python. Old and new instances point to the correct class definition.
# writing c1 class definition to module mod1
cs = """
class c1(object):
att = 1
def m1(self):
self.__class__.att += 1
# printing class name, class-id, and the id of the class, which happens to be its memory address
print "uno:", self.__class__, "class-id:", id(self.__class__), "att:", self.__class__.att
"""
@mateuszgachowski-snippets
mateuszgachowski-snippets / itunes.sh
Created December 6, 2013 22:19
Bash: iTunes CLI
#!/bin/sh
#
####################################
# iTunes Command Line Control v1.0
# written by David Schlosnagle
# created 2001.11.08
# @edited Mateusz Gachowski
####################################
showHelp () {
@gismo141
gismo141 / remove_gui_from_debian.sh
Last active May 23, 2024 17:42
Remove all GUI-related Packages from Existing Debian-Installation
apt-get remove -y --purge x11-common
apt-get autoremove -y --purge
apt-get install -y deborphan
deborphan | xargs dpkg -P # do this a bunch of times
@weapp
weapp / nginx.conf
Created August 4, 2014 17:21
Return common errors as json in Nginx
error_page 500 /500.html;
location /500.html{
return 500 '{"error": {"status_code": 500,"status": "Internal Server Error"}}';
}
error_page 502 /502.html;
location /502.html{
return 502 '{"error": {"status_code": 502,"status": "Bad Gateway"}}';
}
#!/bin/bash
# This Works is placed under the terms of the Copyright Less License,
# see file COPYRIGHT.CLL. USE AT OWN RISK, ABSOLUTELY NO WARRANTY.
#
# COPYRIGHT.CLL can be found at http://permalink.de/tino/cll
# (CLL is CC0 as long as not covered by any Copyright)
OOPS() { echo "OOPS: $*" >&2; exit 23; }
[ -z "`pidof openssl`" ] || OOPS "openssl running, consider: killall openssl"
@cecilemuller
cecilemuller / letsencrypt_2020.md
Last active April 15, 2024 02:19
How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SSL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SLL rating)


Virtual hosts

Let's say you want to host domains first.com and second.com.

Create folders for their files:

@stevejenkins
stevejenkins / unifi_ssl_import.sh
Last active August 30, 2021 03:57
Import and use SSL certificates (including Let's Encrypt) with the Ubiquiti UniFi Controller on Unix/Linux Systems
# MOVED TO https://github.com/stevejenkins/unifi-linux-utils
@Rhernandez513
Rhernandez513 / sendEmail.sh
Last active August 12, 2023 19:31
Simple script to send emails with mailgun api
#!/bin/bash
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
set -o allexport
source .env
set +o allexport
@nrollr
nrollr / nginx.conf
Last active June 9, 2024 23:39
NGINX config for SSL with Let's Encrypt certs
# UPDATED 17 February 2019
# Redirect all HTTP traffic to HTTPS
server {
listen 80;
listen [::]:80;
server_name www.domain.com domain.com;
return 301 https://$host$request_uri;
}
# SSL configuration
@ansemjo
ansemjo / ipa-sysaccount.py
Last active June 17, 2024 12:29
Add or update a sysaccount in a FreeIPA LDAP directory. These accounts can then be used to bind with other services that require LDAP authentication. Run `make install` to install script in `/usr/local/bin/`.
#!/usr/bin/env python
from argparse import ArgumentParser
from random import SystemRandom
from string import ascii_letters, digits
from subprocess import Popen as subprocess, PIPE
from shlex import split as sh
ap = ArgumentParser()
ap.add_argument('action', help='add, delete or change password', choices=('add', 'delete', 'passwd'))