Skip to content

Instantly share code, notes, and snippets.

View pragex's full-sized avatar

Richard Savard pragex

View GitHub Profile
#!/bin/perl
# Convertit un ring group de peers en ring group de local
my ($str, $suffix) = @ARGV;
if (not defined $str) {
die "Ring group string missing\n";
}
if (not defined $suffix) {
#!/bin/perl
# Compte le nombre d'extension unique à faire sonner dans un ring group.
my ($str, $suffix) = @ARGV;
if (not defined $str) {
die "Ring group string missing\n";
}
if (not defined $suffix) {
============ Fichier de configuration d'apache ====================
<Directory>
SSLCertificateFile /etc/pki/tls/certs/mydomain.com.pem
SSLCertificateKeyFile /etc/pki/tls/private/mydomain.com.key
SSLCACertificateFile /etc/pki/tls/certs/domain-ca.pem
</Directory>
================ Conversion du PFX pour Apache ====================
openssl pkcs12 -in filename.pfx -nocerts -out mydomain.com.privatekey.pem
openssl pkcs12 -in filename.pfx -clcerts -nokeys -out /etc/pki/tls/certs/mydomain.com.pem
def split_str2int(src):
tab = []
for val in src.split(","):
try:
tab.append(int(val))
except (ValueError, TypeError):
pass
return tab
@pragex
pragex / Canada Postal Code.py
Last active August 8, 2023 20:50
Find the Canada province code by address postal code.
import re
import sys
def province_by_postal_code(postal_code):
pc = postal_code.replace(" ", "").replace("-", "").upper()
if not re.match(r"^([ABCEGHJKLMNPRSTVXY]\d)"
r"([ABCEGHJKLMNPRSTVWXYZ]\d){2}$", pc):
return "<INVALID>" # Invalid, 6 characters required
@pragex
pragex / website
Last active August 1, 2019 11:57
Check if one or more websites are unreachable. Requires wget installed to work properly.
#!/bin/bash
myfile=""
usage()
{
echo "usage: [[-f, --file FILENAME] [SITENAME...] | -h, --help]"
}
check()
''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(12))
''.join(random.choices(string.ascii_lowercase + string.ascii_uppercase + string.digits, k=3))
def hash_str(s):
"""Get the int hash value of a string."""
modulo = 0x100000001b3
myhash = 0
for ch in bytearray(s.encode('utf-8')):
myhash = (31 * myhash + ch) % modulo
return myhash
import re
import os
from django.conf import settings
from django.contrib.sites.models import Site
RE_HTTPS = re.compile(r"^https?://")
STAGE = os.getenv('STAGE', 'local').lower()
def get_site_url(request=None, path=None, *args):
from django.http import Http404
from django.utils.translation import ugettext_lazy as _
from django.contrib.auth.mixins import LoginRequiredMixin
from django.contrib import messages
from django.views.generic import FormView
from django.core.urlresolvers import reverse
class ProfileFormView(LoginRequiredMixin, FormView):
template_name = 'template.html'
@pragex
pragex / Dockerfile
Created May 23, 2019 17:47
Fix GDAL missing for divio docker image
[...]
RUN apt update && apt install -y --no-install-recommends libgdal20
[...]