This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
O algoritmo para validação do CPF e CNPJ é | |
bem conhecido, portanto a preocupação de tornar | |
o código legível foi sacrificada em prol de tornar | |
o código compacto. | |
Ambas as funções recebem uma string e retornam | |
TRUE ou FALSE dependendo do dígito de verificação | |
bater ou não. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE FUNCTION log_transacao_srph() RETURNS TRIGGER AS $$ | |
BEGIN | |
IF TG_OP = 'UPDATE' THEN | |
INSERT INTO sla_mudancastatus (datahora, numero_os, anterior, novo, abertura, orcamento, aprovacao, emissao, cancelamento, reabertura, operador) | |
VALUES(NOW(), NEW.numero_os, OLD.status_viagem, NEW.status_viagem, NEW.abertura, NEW.orcamento, NEW.aprovacao, NEW.emissao, NEW.cancelamento, NEW.reabertura, NEW.operador); | |
RETURN NEW; | |
END IF; | |
IF TG_OP = 'INSERT' THEN | |
INSERT INTO sla_mudancastatus (datahora, numero_os, anterior, novo, abertura, orcamento, aprovacao, emissao, cancelamento, reabertura, operador) | |
VALUES(NOW(), '', 'ABE', NEW.status_viagem, NEW.abertura, NEW.orcamento, NEW.aprovacao, NEW.emissao, NEW.cancelamento, NEW.reabertura, NEW.operador); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import argparse | |
import datetime | |
import sys | |
FORMAT = '%(asctime)-15s [%(levelname)s] %(message)s' | |
LOGLEVEL = logging.INFO | |
parser = argparse.ArgumentParser(description='Program descriptiom.') | |
parser.add_argument('-sf', '--someflag', const=True, action='store_const', help='Option description') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AESCipher: | |
def __init__( self, key ): | |
self.key = key | |
def encrypt( self, raw ): | |
raw = pad(raw) | |
iv = Random.new().read( AES.block_size ) | |
cipher = AES.new( self.key, AES.MODE_CBC, iv ) | |
return base64.b64encode( iv + cipher.encrypt( raw ) ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Windows Registry Editor Version 5.00 | |
[HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\Default%20Settings] | |
"Colour0"="101,123,131" | |
"Colour1"="88,110,117" | |
"Colour2"="253,246,227" | |
"Colour3"="238,232,213" | |
"Colour4"="238,232,213" | |
"Colour5"="101,123,131" | |
"Colour6"="7,54,66" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* .htaccess | |
RewriteRule markers?/([0-9a-fA-F]{6})/([0-9a-fA-F]{6})/([^/]+)/marker.png markers/index.php?bg=$1&fg=$2&icon=$3 | |
*/ | |
header('Content-type: image/png'); | |
// read parameters: icon file, foreground and background colors | |
$bgc = sscanf(empty($_GET['bg']) ? 'FFFFFF' : $_GET['bg'], '%2x%2x%2x'); | |
$fgc = sscanf(empty($_GET['fg']) ? '000000' : $_GET['fg'], '%2x%2x%2x'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#------------------------------------------------------------------------------- | |
# Name: validate_cnpj | |
# Purpose: check formal validity of a cnpj number (brazilian tax id) | |
# this only checks if the digits match, not if the number is | |
# valid at Receita Federal (Brazilian IRS) | |
# | |
# Author: Paulo Scardine <[email protected]> | |
# | |
# Created: 26/11/2012 | |
# Copyright: (c) PauloS 2012 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cairo | |
pol = 72.0 | |
mm = pol / 25.4 | |
surface = cairo.PDFSurface('teste.pdf', 210*mm, 297*mm) | |
ctx = cairo.Context(surface) | |
ctx.set_source_rgb (0, 0, 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def quebra_linha(frase, largura): | |
linha = "" | |
linhas = [] | |
for palavra in frase.split(): | |
largura_atual = text_extents(linha + palavra) | |
if largura_atual > largura: | |
if not linha: | |
raise Exception('Frase não cabe nesta largura') | |
linhas.append(linha) | |
linha = palavra |
OlderNewer