Skip to content

Instantly share code, notes, and snippets.

@becker990
becker990 / ARC4.php
Created July 16, 2023 10:53
arc4 encryption and decryption in php
<?php
// RC4 encryption function
function ARC4($data, $key) {
$s = array();
$keyLength = strlen($key);
if ($keyLength == 0) {
return "";
}
@becker990
becker990 / rgb_to_hsl_converter
Created December 13, 2021 01:24
Converts a color from RGB to HSL
def converte_hex_para_hsl(hexstring : str):
import colorsys
# especificacao do formato retirada de
# https://en.wikipedia.org/wiki/Web_colors
# tamanho da string
CONST_FULLSIZE = 7
CONST_MINSIZE = 4
@becker990
becker990 / noip2.service
Created May 27, 2019 21:14 — forked from NathanGiesbrecht/noip2.service
Systemd Service file for no-ip.com dynamic ip updater
# Simple No-ip.com Dynamic DNS Updater
#
# By Nathan Giesbrecht (http://nathangiesbrecht.com)
#
# 1) Install binary as described in no-ip.com's source file (assuming results in /usr/local/bin)
# 2) Run sudo /usr/local/bin/noip2 -C to generate configuration file
# 3) Copy this file noip2.service to /etc/systemd/system/
# 4) Execute `sudo systemctl enable noip2`
# 5) Execute `sudo systemctl start noip2`
#
@becker990
becker990 / plymouth_themes.sh
Created July 6, 2015 09:29
plymouth boot screen theme change
#!/bin/bash
yum install -y plymouth-theme-*
plymouth-set-default-theme solar
dracut --force
echo "The following are possible:"
@becker990
becker990 / django forms python estados brasil
Created June 18, 2015 19:14
Uma classe em python para o django forms que valida estados brasileiros
# -*- coding: utf-8 -*-
from django.forms import fields, util, Form
class EstadoField(fields.CharField):
default_error_messages = {
'invalid' : u'Este campo não é um Estado da União Federal.',
'required' : u'Este campo é obrigatório.',
'out_of_range': u'Este campo deve ser igual a 2 letras.',
}
@becker990
becker990 / estados do brasil
Created June 18, 2015 19:05
Um array ou lista (list) em python com todos es tados brasileiros para verificação rápida.
estados = [ "AC","AL","AM","AP","BA",
"CE","DF","ES","GO","MA",
"MT","MS","MG","PA","PB",
"PR","PE","PI","RJ","RN",
"RO","RS","RR","SC","SE",
"SP","TO"]
@becker990
becker990 / example_image_utils.py
Created December 11, 2011 00:00 — forked from turicas/example_image_utils.py
Layer on top of Python Imaging Library (PIL) to write text in images easily
#!/usr/bin/env python
# coding: utf-8
# You need PIL <http://www.pythonware.com/products/pil/> to run this script
# Download unifont.ttf from <http://unifoundry.com/unifont.html> (or use
# any TTF you have)
# Copyright 2011 Álvaro Justen [alvarojusten at gmail dot com]
# License: GPL <http://www.gnu.org/copyleft/gpl.html>
from image_utils import ImageText
@becker990
becker990 / qrcodegoogle.py
Created November 22, 2011 13:08
Generate QR Code image from a string with the Google charts API
import urllib
from django.utils.html import conditional_escape
from django.utils.safestring import mark_safe
def qrcode(value, alt=None, size = 250):
"""
Generate QR Code image from a string with the Google charts API
http://code.google.com/intl/fr-FR/apis/chart/types.html#qrcodes
@becker990
becker990 / ldap_auth.php
Created May 21, 2011 17:54
LDAP openLDAP simple authentication method, returns 1 if user and pass are correct
function ldap_auth($uname,$ldappass,$server_config){
// takes three parameters: array of config
// add id address, dist_name is distinguished name,
// user and password
// returns 1 if user and pass are correct
//
$basedn = $server_config['dist_name'];
$server = $server_config['add'];
$port = $server_config['port'];