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
mencoder -idx input.ogv -ovc lavc -oac mp3lame -o output.avi |
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 read_by_column(path, line, column): | |
""" | |
Uso: | |
# Ler o caractere na linha 1 coluna 14 | |
read_by_column("arquivo.txt", 0, 15) | |
# Ler os caracteres na linha 2 | |
# das colunas 4 até 10 | |
read_by_column("arquivo.txt", 3, slice(4,10)) |
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 tail(arquivo, n, offset=None): | |
""" | |
Lê `n` linhas de `arquivo` com um deslocamento de linhas de `offset`. | |
O valor de retorno é uma tupla na forma `(linhas, has_more)` | |
onde `has_more` é um indicador que é `True` se houver mais linhas no arquivo | |
`arquivo` pode ser um caminho absoluto ou uma instancia de file() | |
""" | |
# f é arquivo aberto(caminho) se passarmos string, se não é arquivo mesmo |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" | |
__author__ = Curso De Python | |
Aula 3 - Exceptions | |
""" | |
############################################################################### | |
# Função que irá gravar o arquivo de log |
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
META: | |
Otimizar o código | |
- Tratar exceptions | |
- Criar funções | |
- Evitar repetições | |
- Interpolar strings ao invés de concatenar | |
- Otimizar | |
Após este passo iremos passar para a oritentação a objetos e encapsular como um método de uma classe.. |
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 -*- | |
class File(file): | |
""" Ler arquivos de texto de traś para frente TAIL, | |
ou apenas uma certa quantidade de linhas do começo HEAD | |
Lendo em blocos de 4096 bytes (altere se desejar))""" | |
def __init__(self, *args, **kwargs): | |
super(File, self).__init__(*args, **kwargs) |
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
#!usr/bin/env python | |
#-*- coding: utf-8 -*- | |
import os | |
import sys | |
import datetime | |
backup_dbs = True | |
backup_w2p = True | |
backup_s = True |
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 datetime import datetime | |
class Conta(object): | |
''' | |
>>> c = Conta(100.00) | |
>>> c.saldo | |
100.0 | |
>>> isinstance(c._ultimo_acesso, datetime) | |
True |
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
#rec | |
ffmpeg -f alsa -ac 2 -i pulse -f x11grab -r 30 -s 1600x900 -i :0.0 -acodec pcm_s16le -vcodec libx264 -vpre lossless_ultrafast -threads 0 output.mkv | |
###convert | |
mencoder -oac mp3lame -lameopts cbr=128 -ovc xvid -xvidencopts bitrate=1200 aula3.mkv -o aula3_mencoder.avi | |
#MERGE | |
mkvmerge -o complete.mkv part1.mkv +part2.mkv +part3.mkv +part4.mkv | |
#conv ffmpeg |
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 -*- | |
class Arquivo(object): | |
""" Ler aquivo de texto .csv """ | |
def __init__(self, arquivo=None): | |
# O arquivo poderá ser definido no construtor | |
if arquivo: | |
self.arquivo = arquivo |