This file contains hidden or 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 os | |
import psutil | |
import sys | |
""" | |
+---------------+-------------------------+-----------------------------+ | |
| Name | Number of Bytes | Amount of Text | | |
| Kilobyte (KB) | 2**10 or 1,024 | 1/2 page | | |
| Megabyte (MB) | 2**20 or 1,048,576 | 500 pages or 1 thick book | | |
+---------------+-------------------------+-----------------------------+ |
This file contains hidden or 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 Caixa(object): | |
def __init__(self, value=0): | |
self.value = value | |
def __sub__(self, value): | |
check = self.value - value | |
if check < 0: | |
print "Voce nao tem saldo para isso" | |
return |
This file contains hidden or 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 -*- | |
""" | |
Classe para um sorteio rápido :D | |
run test: python -m doctest sorteio.py | |
>>> s = DoorPrize([1,2,3]) | |
>>> s[0] | |
1 | |
>>> s.shuffle() != [1,2,3] | |
True |
This file contains hidden or 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
$.fn.slugify = function(options){ | |
var defaults = { | |
separator: '_', | |
}; | |
var opts = jQuery.extend(defaults, options); | |
var map = {"2d":"_","20":"_","24":"s","26":"and","30":"0","31":"1","32":"2","33":"3","34":"4","35":"5","36":"6","37":"7","38":"8","39":"9","41":"A","42":"B","43":"C","44":"D","45":"E","46":"F","47":"G","48":"H","49":"I","50":"P","51":"Q","52":"R","53":"S","54":"T","55":"U","56":"V","57":"W","58":"X","59":"Y","61":"a","62":"b","63":"c","64":"d","65":"e","66":"f","67":"g","68":"h","69":"i","70":"p","71":"q","72":"r","73":"s","74":"t","75":"u","76":"v","77":"w","78":"x","79":"y","100":"A","101":"a","102":"A","103":"a","104":"A","105":"a","106":"C","107":"c","108":"C","109":"c","110":"D","111":"d","112":"E","113":"e","114":"E","115":"e","116":"E","117":"e","118":"E","119":"e","120":"G","121":"g","122":"G","123":"g","124":"H","125":"h","126":"H","127":"h","128":"I","129":"i","130":"I","131":"i","132":"IJ","133":"ij","134":"J","135":"j","136":"K","137":"k","138":"k","139":"L" |
This file contains hidden or 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 download(url, save_to_diretory='.'): | |
def percent(downloaded, total_size): | |
return (math.floor((downloaded / total_size) * 100)) | |
# Open the url | |
try: | |
req = urlopen(url) | |
#handle errors | |
except HTTPError, e: | |
print "HTTP Error:", e.code, url |
This file contains hidden or 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 SearchCatalog(object): | |
""" | |
- Design Patterns Catalog | |
- https://github.com/faif/python-patterns/blob/master/catalog.py | |
""" | |
def __new__(self, request, application, keywords): | |
search_function = getattr(self, '%s_search' % application, False) | |
if keywords == 'Search...': | |
keywords = '' |
This file contains hidden or 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: cp1252 -*- | |
from math import * | |
def DotProduct(v, w): #Produto Escalar | |
try: | |
result = reduce(lambda x, y: x+y, map(lambda x, y: x*y, v, w)) | |
return result | |
except TypeError as error: | |
print "Verifique se foram digitados dois vetores de mesma dimensão:", error |
This file contains hidden or 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 -*- | |
from django.db import models | |
import uuid | |
ANIMALS = (('DO', 'Dog'), ('CA', 'Cat')) | |
class Animal(models.Model): | |
tipo = models.CharField(max_length=2, choices=ANIMALS) |
This file contains hidden or 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
set wsc = CreateObject("WScript.Shell") | |
Do | |
'Five minutes | |
WScript.Sleep(5*60*1000) | |
wsc.SendKeys("{NUMLOCK}") | |
Loop |
This file contains hidden or 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 pandas as pd | |
import re | |
from customer_purchase_order.models import CustomerPurchaseOrderItem | |
from django.db import connection | |
from django.db.models import Q | |
# read file XLSX | |
# file_name = r"D:\zina-files\NFList.xlsx" | |
# xl_file = pd.ExcelFile(file_name) | |
# show avaliable sheets |