Skip to content

Instantly share code, notes, and snippets.

View samuelsonbrito's full-sized avatar

Samuelson Brito samuelsonbrito

View GitHub Profile
/*
* 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 javafxarduino;
import com.fazecast.jSerialComm.SerialPort;
import java.io.PrintWriter;
import java.net.URL;
@FXML
private void ligarLed(ActionEvent event) {
PrintWriter output = new PrintWriter(porta.getOutputStream());
if(led == 0){
output.print("1");
output.flush();
led = 1;
}else{
@FXML
private void conectar(ActionEvent event) {
if (btnConectar.getText().equals("Conectar")) {
porta = SerialPort.getCommPort(cbPortas.getSelectionModel().getSelectedItem().toString());
porta.setComPortTimeouts(SerialPort.TIMEOUT_SCANNER, 0, 0);
if (porta.openPort()) {
btnConectar.setText("Desconectar");
/*
* 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 javafxarduino;
import com.fazecast.jSerialComm.SerialPort;
import java.net.URL;
import java.util.ResourceBundle;
public void carregarPortas() {
SerialPort[] portNames = SerialPort.getCommPorts();
for (SerialPort portName : portNames) {
cbPortas.getItems().add(portName.getSystemPortName());
}
}
@samuelsonbrito
samuelsonbrito / Download.java
Created August 9, 2017 14:02
Download via java
public static File gravaArquivoDeURL(String stringUrl, String pathLocal) {
try {
//Encapsula a URL num objeto java.net.URL
URL url = new URL(stringUrl);
//Queremos o arquivo local com o mesmo nome descrito na URL
//Lembrando que o URL.getPath() ira retornar a estrutura
//completa de diretorios e voce deve tratar esta String
//caso nao deseje preservar esta estrutura no seu disco local.
String nomeArquivoLocal = url.getPath();
//Cria streams de leitura (este metodo ja faz a conexao)...
@samuelsonbrito
samuelsonbrito / persistence.xml
Created June 5, 2017 02:01
Persistence Unit
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="projetoPU" transaction-type="RESOURCE_LOCAL">
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/seuBanco"/>
<property name="javax.persistence.jdbc.user" value="root"/>
@samuelsonbrito
samuelsonbrito / bio.py
Created May 3, 2017 21:19
Leitor Biométrico CIS com Python
#!/usr/bin/env python
import ctypes
FAKE = 0 #NÃO DETECTAR DEDO FALSO
#FAKE = 1; #DETECTAR DEDO FALSO
try:
sdk = ctypes.cdll.LoadLibrary('/usr/lib/libcis_sdk.so')
except:
print("Falha ao importar bibliotecas.")
@samuelsonbrito
samuelsonbrito / Impressora.java
Created May 2, 2017 19:46
Impressão no Java
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import javax.print.Doc;
import javax.print.DocFlavor;
import javax.print.DocPrintJob;
import javax.print.PrintException;
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
import javax.print.SimpleDoc;
@samuelsonbrito
samuelsonbrito / emai.php
Created April 18, 2017 12:58
Gamb Mail
<?php
$post = filter_input_array(INPUT_POST, FILTER_DEFAULT);
if (isset($post)):
$post = array_map('strip_tags', $post);
include_once './libs/PHPMailerN/PHPMailerAutoload.php';
$font_texto = "<font face='Arial' size='2'>";
$ffont = "</font>";