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 is_ip(value): | |
"""IP simple validation in response to blog post http://goo.gl/L9cKh""" | |
try: | |
bytes = [int(e) for e in value.split('.') if 0 <= int(e) <= 255)] | |
except ValueError: | |
return False | |
return len(bytes) == 4 | |
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
# -*- coding: utf-8 -*- | |
# | |
# logr.py is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU Lesser General Public License as | |
# published by the Free Software Foundation, either version 3 of the | |
# License, or (at your option) any later version. | |
# | |
# logr.py is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
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
# -*- coding: utf-8 -*- | |
# | |
# buscarcep.py | |
# | |
# Exemplo de uso do webservice http://buscarcep.com.br/ | |
# Para Python 2.7 | |
# | |
# Daniel Gonçalves <daniel@base4.com.br> | |
# |
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
# Depende de PyESCPOS (https://github.com/base4sistemas/pyescpos) | |
# Testado em uma Daruma DR700 L-e v01.21.00 | |
# Resultado: https://plus.google.com/105886422423352640759/posts/YBedvhKL8SQ?pid=6131402497594282098&oid=105886422423352640759 | |
from escpos.serial import SerialSettings | |
from escpos.impl.daruma import DarumaGeneric | |
conn = SerialSettings.as_from('COM1:9600,8,1,N').get_connection() | |
printer = DarumaGeneric(conn) | |
printer.init() |
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
<?xml version="1.0"?> | |
<CFe> | |
<infCFe versaoDadosEnt="0.06"> | |
<ide> | |
<CNPJ>08427847000169</CNPJ> | |
<signAC>SGR-SAT SISTEMA DE GESTAO E RETAGUARDA DO SAT</signAC> | |
<numeroCaixa>002</numeroCaixa> | |
</ide> | |
<emit> | |
<CNPJ>61099008000141</CNPJ> |
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
# -*- coding: utf-8 -*- | |
# Requires https://github.com/base4sistemas/pyescpos | |
# Have a look at https://github.com/base4sistemas/pyescpos/wiki | |
from __future__ import unicode_literals | |
from __future__ import print_function | |
import logging.config | |
from escpos import showcase | |
from escpos.conn.usb import USBConnection |
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 ctypes, sys | |
from ctypes import windll, wintypes | |
from uuid import UUID | |
class GUID(ctypes.Structure): # [1] | |
_fields_ = [ | |
("Data1", wintypes.DWORD), | |
("Data2", wintypes.WORD), | |
("Data3", wintypes.WORD), | |
("Data4", wintypes.BYTE * 8) |
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
# Copyright 2017 Dan Krause | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, |
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
from reportlab.pdfgen import canvas | |
from reportlab.lib.pagesizes import A4 | |
from reportlab.lib.units import mm | |
#I"ll be generating code39 barcodes, others are available | |
from reportlab.graphics.barcode import code39 | |
# generate a canvas (A4 in this case, size doesn"t really matter) | |
c=canvas.Canvas("barcode_example.pdf",pagesize=A4) | |
# create a barcode object | |
# (is not displayed yet) |
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
// (!) This implementation seems to work; | |
// Trying this in DartPad results in "s = false" and "f = true" as expected. | |
// This was taken from https://gist.github.com/theburningmonk/6401183 | |
class FooBar { | |
static final FooBar _instance = new FooBar._internal(); | |
factory FooBar() => _instance; | |
FooBar._internal() { | |
// initialization logic here |
OlderNewer