Skip to content

Instantly share code, notes, and snippets.

View alyssonbruno's full-sized avatar
🤑
I'm here!

Alysson Bruno alyssonbruno

🤑
I'm here!
View GitHub Profile
@alyssonbruno
alyssonbruno / clone.py
Last active May 6, 2023 23:03
Make a clone of one file or device. Emule the command dd, without type conversion
import io
import mmap
from typing import Optional
_DEFAULTBS=io.DEFAULT_BUFFER_SIZE
def clone(input_file: Optional[str]='/dev/zero', output_file: Optional[str]='/dev/null', block_size: Optional[int]=_DEFAULTBS, count: Optional[int]=None, verbose: Optional[bool]=False):
"""Make a clone of one file or device. Emule the command dd, without type conversion
>>> clone(output_file='/tmp/swap.img',bs=512,count=8*2*1024*1024*1024)
@alyssonbruno
alyssonbruno / gist:3022589
Last active October 6, 2015 16:38
Alterando o label de um disco, com dbus
import dbus
def changelabel(device, newlabel):
"""Change label of device.
>>> changelabel('/dev/sdc1','Boot')
True
>>> changelabel('/dev/sxpto','Data')
False
"""
res = False
@alyssonbruno
alyssonbruno / gist:3037221
Created July 3, 2012 02:47
Mount and Unmount UDisks Device example
#http://hal.freedesktop.org/docs/udisks/Device.html
def mount(device, fs):
"""
>>> mount('/dev/sdb1','ext3')
/media/pendrive
>>> mount('/dev/sdc2','ext2')
''
"""
res = ''
@alyssonbruno
alyssonbruno / exp_verify.py
Created July 25, 2012 15:17
Verificando expressão numérica
def eval_expr(text):
test_char = lambda c: c in '1234567890.,*/+-()'
for char in text:
if not test_char(char):
raise Exception('Invalid Char in String')
return long(eval(text,{},{}))
abruno:/tmp$ cat notas.txt
Fulano 8.3 7.6 9.5 6.4
Sicrano 5.6 8.9 7.4 7.5
Beltrano 5.6 7.8 9.4 5. 3
abruno:/tmp$ cat notas.py
notas={}
for linha in open('notas.txt'):
linha_list = linha.strip().split(' ')
notas[linha_list[0]]=linha_list[1:]
print notas
// global scope
(function(){
// outer scope
var fibonacci = function(){
my_return = "0, ";
current_number = 0;
minus_one_order = 0;
minus_two_order = 0;
max_order=12;
for(current_order = 1;current_order<=max_order;current_order+=1){
@startuml
actor Foo1
boundary Foo2
control Foo3
entity Foo4
database Foo5
Foo1 -> Foo2 : To boundary
Foo1 -> Foo3 : To control
Foo1 -> Foo4 : To entity
Foo1 -> Foo5 : To database
@alyssonbruno
alyssonbruno / incluir_arquivo.php
Created July 5, 2017 22:29
Inclui um arquivo num processo SEI
define("ID_UNIDADE", "999"); //id da unidade onde o processo está
define("ID_SERIE", "50070"); //Tipo do documento que irá ser incluído, deve ser um tipo externo
define("SISTEMA, "meuSistemaNoSei'");//Nome do Sistema no menu Adminsitração/ Sistema
define("SERVICO", "servicoDoMeuSistema"); //Nome do Serviço dentro do Sistema
function inclui_evidencia_sei($cpf,$nome,$protocolo,$nome_arquivo,$arquivo){
$DocumentoRecebido = array();
$DocumentoRecebido['Tipo'] = 'R';
$DocumentoRecebido['Destinatarios'] = null;
$DocumentoRecebido['Interessados'] = array(array('Sigla' => $cpf, 'Nome' => $nome));
$DocumentoRecebido['Data'] = "" . date("d/m/Y");
@alyssonbruno
alyssonbruno / install_laravel_ubuntu.md
Created January 24, 2019 13:07
Instalando o laravel num Ubuntu Server
  1. certifique-se que o PATH contem o diretório ~/opt/bin:
  export PATH="$HOME/opt/bin:$PATH:"
  1. atualizar o sistema:
  sudo apt update --yes && sudo apt upgrade --yes && sudo apt autoremove --yes
  1. instalar a ultima versao do PHP (7.2 agora):