Skip to content

Instantly share code, notes, and snippets.

View tonussi's full-sized avatar

Lucas Tonussi tonussi

View GitHub Profile
@tonussi
tonussi / pirsensor_teste.ino
Last active December 17, 2015 18:09
Testando Sensor de Presença
int pinoSensorPIR = 7;
int bRate = 9600;
void setup() {
pinMode(pinoSensorPIR, INPUT);
Serial.begin(bRate);
}
void loop() {
Serial.println(!digitalRead(pinoSensorPIR));
@tonussi
tonussi / carrimag.vhd
Created June 4, 2013 23:25
Subbloco para carregar a imagem
library ieee;
use ieee.std_logic_1164.all;
entity carrimag is
generic
(
n : natural := 8
);
@tonussi
tonussi / Formatex.java
Last active December 18, 2015 05:58
Metodo Java para formatar matrizes em latex
public class Formatex {
public static void formatMatrix(int[][] inputArray2D) {
assert (inputArray2D.length == inputArray2D[0].length && inputArray2D != null) : "BadInputArrayException";
StringBuilder latex = new StringBuilder(
"\\mathbf{G}_x = \\begin{bmatrix} ");
for (int i = 0; i < inputArray2D.length; i++) {
for (int j = 0; j < inputArray2D[i].length; j++) {
latex.append(inputArray2D[i][j]);
if (j != inputArray2D[i].length - 1)
@tonussi
tonussi / bc.vhd
Last active December 18, 2015 17:59
projeto vhd multiplicador
LIBRARY ieee;
USE ieee.std_logic_1164.all;
ENTITY bc IS
PORT (Reset, clk, inicio : IN STD_LOGIC;
Az, Bz : IN STD_LOGIC;
pronto : OUT STD_LOGIC;
ini, CA, dec, CP: OUT STD_LOGIC );
END bc;
@tonussi
tonussi / Conta.java
Created June 23, 2013 17:25
Simples classe de conta bancária
package concorrente;
public class Conta {
private int saldo = 0;
public synchronized boolean retira(int montante) {
assert (montante <= 0 || saldo < montante) : "montante: " + montante
+ "saldo: " + saldo;
saldo -= montante;
return true;
@tonussi
tonussi / nadadores.pfc
Last active December 19, 2015 00:39
nadadores
program piscina;
var st: array[1..14] of char;
monitor cesto;
export pega, larga;
var ncesto: integer;
ccesto: condition;
@tonussi
tonussi / contnb.vhd
Last active December 19, 2015 01:29
memram01
LIBRARY ieee;
USE ieee.std_logic_1164.all;
ENTITY contnb IS
PORT ( R : IN INTEGER RANGE 0 TO 7;
clk, limpa , carga : IN STD_LOGIC;
Q : BUFFER INTEGER RANGE 0 TO 7 );
END contnb ;
ARCHITECTURE comportamento OF contnb IS
@tonussi
tonussi / Main.java
Last active December 19, 2015 01:39
Method for delete some input string on a input path for a certain file
public class Main {
public static void main(String[] args) {}
public static void add(String fileName, String text) throws FileNotFoundException, IOException {
RandomAccessFile rafile = new RandomAccessFile(new File(fileName), "rw");
rafile.seek(0);
rafile.write(text.getBytes());
rafile.close();
}
@tonussi
tonussi / addappend.sh
Created June 27, 2013 18:19
addappend.sh
#!/bin/sh
for fname in /home/tecnica/cemig/*/*/*; do
printf '0a\n<root>\n.\nw\n' | ed "$fname" | echo '</root>' >> "$fname"
done #[email protected]
@tonussi
tonussi / Fila.java
Created June 28, 2013 17:13 — forked from senhorinha/Fila.java
Resolução questão Fila
public class Fila {
private final int[] dados;
private int inicio, fim, contador;
private final int max;
public boolean filaCheia() {
return contador == max;
}