Skip to content

Instantly share code, notes, and snippets.

View rmgimenez's full-sized avatar

Ricardo Moura Gimenez rmgimenez

View GitHub Profile
<html>
<head>
<title>Título do site</title>
</head>
<body>
<?php echo $conteudo; ?>
</body>
</html>
@rmgimenez
rmgimenez / execution_time.py
Created January 5, 2018 00:09
Script em python que mostra quanto tempo demorou para executar um script
"""
ExecutionTime
This class is used for timing execution of code.
For example:
timer = ExecutionTime()
print 'Hello world!'
print 'Finished in {} seconds.'.format(timer.duration())
"""
from peewee import *
import datetime
db = SqliteDatabase('banco_dados.sqlite')
class BaseModel(Model):
class Meta:
database = db
class Cotacao(BaseModel):
@rmgimenez
rmgimenez / Cotacao.java
Created July 14, 2016 18:43
Le o arquivo de cotação da bovespa e exporta para o metastock
/*
* 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;
@rmgimenez
rmgimenez / ler_xml_reddit_imgur.py
Created July 5, 2016 18:27
Ler xml reddit imgur
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 = {
@rmgimenez
rmgimenez / funcoes.php
Created June 25, 2016 16:12
Retorna dados de sites de imagens
<?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 {
@rmgimenez
rmgimenez / Strings.pas
Created June 15, 2016 12:13
Unit com várias funções para strings
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;
@rmgimenez
rmgimenez / ler_cotacao_hist_bovespa.py
Created June 13, 2016 18:01
Lê um arquivo de cotação da Bovespa e joga os valores para variáveis
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:
@rmgimenez
rmgimenez / share_button.js
Last active June 10, 2016 19:27
Botões de compartilhar conteúdos para blogs
// Vertical
<script>
document.write('<script src="//sharebutton.net/plugin/sharebutton.php?type=vertical&u=' + encodeURIComponent(document.location.href) + '"></scr' + 'ipt>');
</script>
// Horizontal
<script>
document.write('<script src="//sharebutton.net/plugin/sharebutton.php?type=horizontal&u=' + encodeURIComponent(document.location.href) + '"></scr' + 'ipt>');
</script>