Skip to content

Instantly share code, notes, and snippets.

View patriciomg's full-sized avatar
🎖️
I may be slow to respond.

Don Pato patriciomg

🎖️
I may be slow to respond.
  • KK
  • Germany
View GitHub Profile
@patriciomg
patriciomg / replacement.py
Last active May 4, 2023 08:01
tag replacement with BeautifulSoup
"""
I found this somewhere... if this code is yours, please
let me know it and I will update the comments with proper credits.
"""
from bs4 import BeautifulSoup
REPLACEMENTS = [('b', {}, 'strong', {}),
('u', {}, 'span', {'class': 'underline'}),
('i', {}, 'em', {}),
@patriciomg
patriciomg / .htaccess
Created February 21, 2023 09:26
mod rewrite variables
###### List of Mod_Rewrite Variables: http://www.askapache.com/htaccess/mod_rewrite-variables-cheatsheet.html
###HTTP header variables:
#HTTP_USER_AGENT, HTTP_REFERER,
#HTTP_COOKIE, HTTP_FORWARDED, HTTP_HOST, HTTP_PROXY_CONNECTION, HTTP_KEEP_ALIVE
#HTTP_ACCEPT, HTTP_ACCEPT_CHARSET, HTTP_ACCEPT_ENCODING, HTTP_ACCEPT_LANGUAGE
#HTTP_CACHE_CONTROL, HTTP_CONNECTION
###Connection & request variables:
# REMOTE_ADDR, REMOTE_HOST, REMOTE_PORT, REMOTE_USER, REMOTE_IDENT
@patriciomg
patriciomg / Copy as textile
Created December 7, 2022 08:59 — forked from jakob-stoeck/Copy as textile
Copies SequelPro results as a textile table to use it in Redmine or other textile-supported systems. To use, just copy it into your SequelPro Bundle Editor.
#!/usr/bin/php
<?php
$in = fopen('php://stdin', 'r');
$result=array();
$format='_.';
while($line=fgetcsv($in, 0, "\t")) {
$result[]='|'.$format.implode('|'.$format, $line).'|';
$format='';
}
fclose($in);
@patriciomg
patriciomg / .htaccess
Created January 25, 2022 08:38 — forked from ludo237/.htaccess
The ultimate .htaccess file. Please feel free to fork it, edit it and let me know what do you think about it.
# Apache configuration file
# httpd.apache.org/docs/2.2/mod/quickreference.html
# Note .htaccess files are an overhead, this logic should be in your Apache
# config if possible: httpd.apache.org/docs/2.2/howto/htaccess.html
# Techniques in here adapted from all over, including:
# Kroc Camen: camendesign.com/.htaccess
# perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/
# Sample .htaccess file of CMS MODx: modxcms.com
# This is the free sample of .htaccess from 6GO s.r.l.
# @author Claudio Ludovico Panetta (@Ludo237)
@patriciomg
patriciomg / certs
Created August 26, 2021 10:13
Self generated certificates
# https://www.devtech101.com/2017/05/18/gotchas-tips-creating-private-docker-registry-self-signed-certificate/
mkdir -p /docker-data/registry/{data,ssl,config}
docker run --rm -v /docker-data/registry/ssl:/certs \
-e SSL_IP=10.10.10.10 \
-e SSL_DNS=docker.domain.com \
-e SSL_SUBJECTdocker.domain.com \
-e CA_SUBJECT=docker.domain..com \
-e CA_EXPIRE=1095 \
paulczar/omgwtfssl
@patriciomg
patriciomg / emoji_as_entity.php
Last active May 4, 2023 08:06
Convert emojis in a string to html entities.
function emoji_as_entity($str) {
$emoji_pattern = "/\\x{1F469}\\x{200D}\\x{2764}\\x{FE0F}\\x{200D}\\x{1F48B}\\x{200D}\\x{1F469}|\\x{1F469}\\x{200D}\\x{2764}\\x{FE0F}\\x{200D}\\x{1F48B}\\x{200D}\\x{1F468}|\\x{1F468}\\x{200D}\\x{2764}\\x{FE0F}\\x{200D}\\x{1F48B}\\x{200D}\\x{1F468}|\\x{1F469}\\x{200D}\\x{1F469}\\x{200D}\\x{1F466}\\x{200D}\\x{1F466}|\\x{1F468}\\x{200D}\\x{1F468}\\x{200D}\\x{1F467}\\x{200D}\\x{1F466}|\\x{1F469}\\x{200D}\\x{1F469}\\x{200D}\\x{1F467}\\x{200D}\\x{1F467}|\\x{1F469}\\x{200D}\\x{1F469}\\x{200D}\\x{1F467}\\x{200D}\\x{1F466}|\\x{1F468}\\x{200D}\\x{1F469}\\x{200D}\\x{1F467}\\x{200D}\\x{1F467}|\\x{1F468}\\x{200D}\\x{1F469}\\x{200D}\\x{1F467}\\x{200D}\\x{1F466}|\\x{1F468}\\x{200D}\\x{1F469}\\x{200D}\\x{1F466}\\x{200D}\\x{1F466}|\\x{1F468}\\x{200D}\\x{1F468}\\x{200D}\\x{1F467}\\x{200D}\\x{1F467}|\\x{1F468}\\x{200D}\\x{1F468}\\x{200D}\\x{1F466}\\x{200D}\\x{1F466}|\\x{1F3CC}\\x{FE0F}\\x{200D}\\x{2640}\\x{FE0F}\\x{1F3FB}|\\x{1F3CB}\\x{FE0F}\\x{200D}\\x{2640}\\x{FE0F}\\x{1F3FF}|\\x{1F575}\\x{FE
@patriciomg
patriciomg / LICENSE.txt
Created April 27, 2021 15:49 — forked from jed/LICENSE.txt
generate random UUIDs
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Jed Schmidt <http://jed.is>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@patriciomg
patriciomg / docker-compose.yml
Created March 7, 2021 17:32
This setup allows us to have mongodb and a nice web UI mongo-express running. For additional security, we have set password for our db, and we have also set a web login BASICAUTH for our mongo-express service. (localhost:8081). Spin this up with docker-compose up --build
mongodb:
image: mongo:4.2.5-bionic
container_name: mongodb
restart: always
environment:
- MONGO_INITDB_ROOT_USERNAME=root
- MONGO_INITDB_ROOT_PASSWORD=example
volumes:
- './database:/data/db'
ports:
@patriciomg
patriciomg / curl-format.txt
Created October 14, 2020 09:06
curl-format.txt
\n
time_namelookup: %{time_namelookup}\n
time_connect: %{time_connect}\n
time_appconnect: %{time_appconnect}\n
time_pretransfer: %{time_pretransfer}\n
time_redirect: %{time_redirect}\n
time_starttransfer: %{time_starttransfer}\n
----------\n
time_total: %{time_total}\n
\n
@patriciomg
patriciomg / gunicorn_start.bash
Created July 1, 2020 12:05 — forked from postrational/gunicorn_start.bash
Example of how to set up Django on Nginx with Gunicorn and supervisordhttp://michal.karzynski.pl/blog/2013/06/09/django-nginx-gunicorn-virtualenv-supervisor/
#!/bin/bash
NAME="hello_app" # Name of the application
DJANGODIR=/webapps/hello_django/hello # Django project directory
SOCKFILE=/webapps/hello_django/run/gunicorn.sock # we will communicte using this unix socket
USER=hello # the user to run as
GROUP=webapps # the group to run as
NUM_WORKERS=3 # how many worker processes should Gunicorn spawn
DJANGO_SETTINGS_MODULE=hello.settings # which settings file should Django use
DJANGO_WSGI_MODULE=hello.wsgi # WSGI module name