https://wiki.python.org.br/CookBook
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 | |
$pastaUpload = '/c:/wamp64-3.3.0-20230516/www/aps/uploads/'; | |
$endereco = 'http://localhost/aps/uploads/'; | |
if ($_SERVER['REQUEST_METHOD'] === 'POST') { | |
// Check if file was uploaded without errors | |
if (isset($_FILES['file']) && $_FILES['file']['error'] === UPLOAD_ERR_OK) { | |
$uploadDir = $pastaUpload; // Directory to save uploaded files | |
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
<html> | |
<head> | |
<title>Título do site</title> | |
</head> | |
<body> | |
<?php echo $conteudo; ?> | |
</body> | |
</html> |
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
""" | |
ExecutionTime | |
This class is used for timing execution of code. | |
For example: | |
timer = ExecutionTime() | |
print 'Hello world!' | |
print 'Finished in {} seconds.'.format(timer.duration()) | |
""" |
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 peewee import * | |
import datetime | |
db = SqliteDatabase('banco_dados.sqlite') | |
class BaseModel(Model): | |
class Meta: | |
database = db | |
class Cotacao(BaseModel): |
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
/* | |
* To change this license header, choose License Headers in Project Properties. | |
* To change this template file, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package bovespa; | |
import java.text.DateFormat; | |
import java.text.ParseException; | |
import java.text.SimpleDateFormat; |
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 urllib.request import urlopen | |
import xml.etree.ElementTree as ET | |
link_xml = 'http://imgur.com/r/cosplay/top/day.xml'; | |
arq_xml = urlopen(link_xml) | |
xml = ET.parse(arq_xml) | |
items = [] | |
for item_xml in xml.findall('item'): | |
lista = { |
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 | |
function extract_link_from_text($text) | |
{ | |
//The Regular Expression filter | |
$reg_exUrl = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,4}(\/\S*)?/"; | |
// Check if there is a url in the text | |
if(preg_match($reg_exUrl, $text, $url)) { | |
return $url[0]; | |
} else { |
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
unit Strings; | |
interface | |
uses | |
Windows, Dialogs, Messages, SysUtils, Classes, Controls, StdCtrls, Mask; | |
function ArredontaFloat(x : Real): Real; | |
function RoundNum(Valor:Extended;Decimais:Integer):Extended; | |
function Gerapercentual(valor:real;Percent:Real):real; |
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
ref_arquivo = open("COTAHIST_A2016.TXT","r") | |
# formata uma data do tipo yyyymmdd para dd/mm/yyyy | |
def formata_data(data): | |
return data[6:8] + '/' + data[4:6] + '/' + data[0:4] | |
def formata_numero(numero): | |
return int(numero) / 100 | |
for linha in ref_arquivo: |
NewerOlder