Skip to content

Instantly share code, notes, and snippets.

View sergiosvieira's full-sized avatar

Sérgio Vieira sergiosvieira

  • Fortaleza
View GitHub Profile
#include <iostream>
#include <vector>
using Vector = std::vector<std::string>;
Vector split(const std::string& input, const std::string& delimiter) {
size_t b = 0, e = 0;
Vector result;
while ((e = input.find_first_of(delimiter, b)) <= std::string::npos) {
result.emplace_back(input.substr(b, e - b));
@sergiosvieira
sergiosvieira / digits.cpp
Created February 20, 2021 22:14
Count digits of an integer
int n = 123456;
std::cout << (int)log10(n) + 1 << "\n";
FFBBBFBLRL
BFFFBFBRRR
BFFFBFBLRL
BFFBFBBLRR
BBFFBFFRLL
BFFFBFBRLR
FFFFBBBRLR
BBFFFBBRRR
BBFBFBBRRR
BFFBBBFLRR
@sergiosvieira
sergiosvieira / Banco.java
Created September 18, 2020 15:48
Semana 02 - Interfaces
import java.util.*;
import java.time.LocalDate;
enum Sexo {M, F};
interface ICadastro {
void nome(String valor);
void cpf(int valor);
void rg(int valor);
void uf(String valor);
@sergiosvieira
sergiosvieira / Tela.java
Created September 18, 2020 14:35
Semana 02 - Classe Abstrata
import java.util.*;
abstract class ObjetoGeometrico {
public abstract void desenhar(); // método abstrato
public void posicao() { // método não-abstrato
System.out.print("Estou no centro da tela!");
}
}
class Quadrado extends ObjetoGeometrico {
@sergiosvieira
sergiosvieira / codigos.txt
Created September 18, 2020 13:58
Semana 02 - Polimorfismo
import java.util.*;
class Veiculo {
public void buzinar() {
System.out.println("Buzina não instalada!:(");
}
}
class Automovel extends Veiculo {
public void buzinar() { // Método Polimórfico
@sergiosvieira
sergiosvieira / codigo.txt
Created September 18, 2020 12:40
Semana 02 - Herança
Exemplo de herança entre as classes Conta, Conta Corrente e Conta Poupança.
Linguagem C++
=============
class Conta {
protected:
int numero;
string titular;
double saldo_atual;
@sergiosvieira
sergiosvieira / dwa131v5.md
Created September 5, 2020 13:39
Install DLINK DWA 131 V5 drivers on linux

sudo apt install git dkms build-essential git clone https://github.com/Mange/rtl8192eu-linux-driver.git sudo dkms add rtl8192eu-linux-driver sudo dkms install rtl8192eu/1.0 echo "blacklist rtl8xxxu" | sudo tee /etc/modprobe.d/rtl8xxxu.conf

Reboot go into BIOS/UEFI settings, make sure Secure Boot is disabled

@sergiosvieira
sergiosvieira / prime.cpp
Created September 2, 2020 09:50
Fast Prime Number
#include <iostream>
/*
* function is_prime(n)
if n ≤ 3 then
return n > 1
else if n mod 2 = 0 or n mod 3 = 0
return false
@sergiosvieira
sergiosvieira / fib.cpp
Last active September 2, 2020 09:49
Fast Fibonacci
#include <iostream>
#include <iomanip>
#include <cmath>
int main() {
int input = 0;
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
if (std::cin >> input) {
double sqrt5 = std::sqrt(5);