Skip to content

Instantly share code, notes, and snippets.

View saulozitos's full-sized avatar
🏠
Working from home

Saulo Campos saulozitos

🏠
Working from home
View GitHub Profile
@saulozitos
saulozitos / Byte.h
Last active September 25, 2023 17:21
Byte
#include <iostream>
#include <string>
#include <stdexcept>
#include <cstdint>
#include <bitset>
#include <sstream>
#include <iomanip>
#include <cctype>
class Byte {
@saulozitos
saulozitos / passwordgenerator.cpp
Last active August 20, 2021 17:38
An example of a secure password generator
#include <iostream>
#include <algorithm>
#include <random>
#include <string>
class PasswordGenerator
{
public:
PasswordGenerator() = default;
@saulozitos
saulozitos / smartPtrInMap.cpp
Last active July 26, 2021 17:03
Storing std::unique_ptr in a std::map
#include <array>
#include <iostream>
#include <map>
#include <memory>
#include <string>
namespace Global {
const std::array<std::string, 20> namesArray {
"Kiesha",
"Ashlee",
@saulozitos
saulozitos / smartPtrInVector.cpp
Created July 25, 2021 15:37
Storing std::unique_ptr in a std::vector
#include <array>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
namespace Global {
const std::array<std::string, 20> namesArray {
"Kiesha ",
"Ashlee ",
@saulozitos
saulozitos / FibonacciAnswers.cpp
Created July 9, 2021 18:40
The first 300 Fibonacci numbers in a constexpr array
#include <iostream>
#include <string_view>
#include <array>
constexpr std::array<std::string_view, 301>fiboAnswers = {
"0", "1", "1", "2", "3", "5", "8", "13", "21", "34", "55", "89", "144", "233", "377",
"610", "987", "1597", "2584", "4181", "6765", "10946", "17711", "28657", "46368",
"75025", "121393", "196418", "317811", "514229", "832040", "1346269", "2178309",
"3524578", "5702887", "9227465", "14930352", "24157817", "39088169", "63245986",
"102334155", "165580141", "267914296", "433494437", "701408733", "1134903170",
@saulozitos
saulozitos / any.hpp
Last active July 5, 2021 02:19 — forked from shoooe/any.hpp
A simple implementation of Boost's any, as an exercise.
#pragma once
#include <exception>
#include <memory>
#include <typeinfo>
#include <type_traits>
namespace utils{
class any;
@saulozitos
saulozitos / make_unique.cpp
Created April 27, 2021 18:37
Template make_unique to C++11
#include <memory>
template<typename T, typename... Args>
std::unique_ptr<T> make_unique(Args&&... args)
{
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}
@saulozitos
saulozitos / testSharedPtr.cpp
Last active April 23, 2021 15:31
std::shared_ptr tests
#include <iostream>
#include <memory>
#include <utility>
// Class modified to use shared_ptr of Nodes.
class Node
{
private:
int num{0};
std::shared_ptr<Node> next;
#include <numeric>
#include <vector>
#include <iostream>
long aVeryBigSum(const std::vector<long> &array)
{
return std::accumulate(array.begin(), array.end(), 0LL);
}
int main()
@saulozitos
saulozitos / arch_cheatsheet.txt
Created September 21, 2020 11:34 — forked from yufengwng/arch_cheatsheet.txt
Arch Linux Commands Cheatsheet
pacman
======
view logs: /var/log/pacman.log
update system
# pacman -Syu
list installed packages
# pacman -Q