Skip to content

Instantly share code, notes, and snippets.

View tonussi's full-sized avatar

Lucas Tonussi tonussi

View GitHub Profile
@tonussi
tonussi / barbeirodorminhoco.py
Last active December 19, 2015 10:59
Problema do Barbeiro Dorminhoco em Python, Tradução C-like -> Python de Andrew S. Tanenbaum Distributed Operating System, Prentice-Hall, 1995. Página 82.
Semaphore barbeiro = 0
Semaphore acentos = 1
Semaphore pronto = 0
int nro_acentos_livres = N
def Barbeiro():
while true:
wait(pronto)
wait(acentos)
nro_acentos_livres += 1
@tonussi
tonussi / Indice.java
Created July 10, 2013 18:00
Prioridades em Java Threads
package tonussi.concorrente.prioridades;
public class Indice {
int i, limite;
public Indice(int limite) {
i = 0;
this.limite = limite;
}
@tonussi
tonussi / utils.sql
Last active December 19, 2015 19:48
utils pgsql dump dados
-- BASE DE DADOS LEPTEN
SELECT * FROM tb_history,tb_station WHERE tb_history.id_station=tb_station.id_station AND tb_station.nm_station='COPEL_6' AND hr_data>='2010-08-01' AND hr_data<='2010-09-01' ORDER BY hr_data ASC
SELECT hr_data FROM tb_history,tb_station WHERE tb_history.id_station=tb_station.id_station AND tb_station.nm_station='COPEL_1' AND hr_data>='2010-09-01 09:00:00' AND hr_data<='2010-09-01 16:00:00' AND ((to_char(hr_data,'MI') like '%30%' or to_char(hr_data,'MI') like '%00%')) ORDER BY hr_data ASC
-- MEDIAS
SELECT avg(vl_air_temp_avg),sum(vl_rain_yearly),max(vl_solar_avg),max(vl_wind_speed_max),avg(vl_wind_speed_avg),min(vl_wind_speed_avg) FROM tb_history,tb_station WHERE tb_history.id_station=tb_station.id_station AND tb_station.nm_station='COPEL_4' AND hr_data BETWEEN '2011-05-01' and '2011-05-31 23:50:00' AND tb_history.vl_solar_avg<>-999999 AND tb_history.vl_wind_speed_avg<>-999999 AND tb_history.vl_air_temp_avg<>-999999
-- RAJADAS
@tonussi
tonussi / bibsty.tex
Created July 23, 2013 12:44
bib format
\begin{thebibliography}{9}
\bibitem{Ref1} Refer\^{e}ncias biogr\'{a}ficas no formato APS (Physical
Review) - Ex. Artigo: Autores, \ "T\'{\i}tulo do artigo entre aspas", Nome
da Revista \textbf{Volume em Negrito}, p\'{a}gina inicial (ano de publica%
\c{c}\~{a}o).
\bibitem{Ref2} Refer\^{e}ncias biogr\'{a}ficas no seguinte APS (Physical
Review) - Ex. Livro: Autores, \ \textit{T\'{\i}tulo do \ Livro em It\'{a}lico%
}, (Editora, Cidade de Publica\c{c}\~{a}o, Ano de publica\c{c}\~{a}o).
\newtheorem{theorem}{Theorem}
\newtheorem{acknowledgement}[theorem]{Acknowledgement}
\newtheorem{algorithm}[theorem]{Algorithm}
\newtheorem{axiom}[theorem]{Axiom}
\newtheorem{case}[theorem]{Case}
\newtheorem{claim}[theorem]{Claim}
\newtheorem{conclusion}[theorem]{Conclusion}
\newtheorem{condition}[theorem]{Condition}
\newtheorem{conjecture}[theorem]{Conjecture}
\newtheorem{corollary}[theorem]{Corollary}
@tonussi
tonussi / CEMIG_1_14.xml
Created July 24, 2013 18:01
Testando saidas da multilista
<root>
<medicoes class="linked-list">
<lista>
<lat>-20.29</lat>
<lon>-43.76</lon>
<dtLeitura>19/04/2010</dtLeitura>
<hrLeitura>08:30:00</hrLeitura>
<nmStation>CEMIG_1</nmStation>
<vlAirTempAvg>16.73</vlAirTempAvg>
#!/bin/bash
cd "/path/to/dir"
for file in `dir -d *` ; do
t=$(mktemp)
qpdf --password="password" --decrypt "$file" "$t" && \
mv "$t" "$file"
done
@tonussi
tonussi / pandoc-html2md.sh
Created September 2, 2013 06:10
Pandoc recursively html 2 markdown
#!/bin/bash
cd /home/tonussi/Git/test
for file in `dir -d *.html` ; do
pandoc -s -r html "$file" -o $file.markdown
done
@tonussi
tonussi / som.pde
Created September 8, 2013 21:17
som.pde
import ddf.minim.*;
import ddf.minim.ugens.*;
Minim minim;
AudioOutput out;
Circle circle;
void setup() {
size(512, 200);
minim = new Minim(this);
@tonussi
tonussi / ex1.asm
Created September 16, 2013 19:53
lab5
.data
#arranjo inicializado com elementos nao nulos
_array: .word 1, 2, 3, 4, 5, 6, 7, 8, 9, 2, 3
_size: .word 11
.text
.globl main
main:
jal clear1 #salto para o endereco d0 processamento
li $v0, 10 # exit syscall