Skip to content

Instantly share code, notes, and snippets.

View arthurafarias's full-sized avatar

Arthur de Araújo Farias arthurafarias

  • Campina Grande, Brasil
View GitHub Profile
@arthurafarias
arthurafarias / check-server-up.sh
Last active October 17, 2023 22:16
A simple script to send an e-mail using ssmtp when a site is up (bash)
#!/bin/bash
while getopts u:i:c:a:m: flag
do
case "${flag}" in
u) url=${OPTARG};;
i) interval=${OPTARG};;
c) code=${OPTARG};;
a) email=${OPTARG};;
m) message=${OPTARG};;
@arthurafarias
arthurafarias / ModelViewViewModelArchitecture.cpp
Last active July 8, 2023 11:43
A Simple Model View Architecture in C++
#include <list>
#include <functional>
#include <iostream>
#include <string>
namespace Core
{
class Object {};
namespace Collections
@arthurafarias
arthurafarias / README.md
Last active July 8, 2023 11:43
Encoding URI and URI Component in C++

Encode and Decode HTTP URIs and URI components in C++

What is a URI?

A Uniform Resource Identifier (URI) is a string of characters that unambiguously identifies a particular resource. To guarantee uniformity, all URIs follow a predefined set of syntax rules,[1] but also maintain extensibility through a separately defined hierarchical naming scheme (e.g. "http://").

Such identification enables interaction with representations of the resource over a network, typically the World Wide Web, using specific protocols. Schemes specifying a concrete syntax and associated protocols define each URI. The most common form of URI is the Uniform Resource Locator (URL), frequently referred to informally as a web address. More rarely seen in usage is the Uniform Resource Name (URN), which was designed to complement URLs by providing a mechanism for the identification of resources in particular namespaces.

The common parts of a URI are described below.

@arthurafarias
arthurafarias / main.c
Created August 25, 2017 10:32
Sample Code for Zephyr OS
#include <zephyr.h>
#include <misc/printk.h>
/* size of stack area used by each thread */
#define STACKSIZE 1024
K_SEM_DEFINE(sem, 0, 1);
K_MUTEX_DEFINE(mutex);
@arthurafarias
arthurafarias / gsmtpc
Created June 7, 2017 04:58
Atividade de Redes de Computadores - Questão 02
#!/usr/bin/env python
"""Google SMTP Client.
Usage:
gsmtpc (-l=<email>|--login=<email>)
gsmtpc (-l=<email>|--login=<email>) [-p=<plain> | --password=<plain>] [-r=<email> | --recipient=<email>] [-s=<text> | --subject=<text>] [-m=<text> | --message=<text>]
gsmtpc (-h | --help)
Options:
-h --help Show this screen.
@arthurafarias
arthurafarias / httpd
Created June 7, 2017 04:37
Atividade de Redes de Computadores - Questão 01
#!/usr/bin/env python
"""HTTP Daemon.
Usage:
httpd [-p=<port> | --port=<port>] [-r=<path> | --root=<path> ]
httpd (-h | --help)
Options:
-h --help Show this screen.
-p --port=<port> Specify port number [default: 8888 ].
@arthurafarias
arthurafarias / Client.py
Created December 2, 2016 00:34
UDP Simple Client and Threaded Server written in Python
import socket
import sys
HOST, PORT = "localhost", 8888
data = " ".join(sys.argv[1:])
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.sendto(data + "\n", (HOST, PORT))
received = sock.recv(1024)
@arthurafarias
arthurafarias / exp01.mdl
Created November 7, 2016 12:15
ufcg-ee-cem-exp01
Model {
Name "simulacao"
Version 7.7
MdlSubVersion 0
GraphicalInterface {
NumRootInports 0
NumRootOutports 0
ParameterArgumentNames ""
ComputedModelVersion "1.1"
NumModelReferences 0
@arthurafarias
arthurafarias / fifo.c
Created October 24, 2016 17:58
A simple fifo demostration written in C
/* To compile this code just type in terminal
* gcc fifo.c -o fifo
* ./fifo
*/
#include <stdio.h>
#include <stdlib.h>
char fifo[256];
int fifo_tail;
clear; clc;
fs = 8000;
ws = 2*pi*fs;
fc = 600;
wc = 2*pi*fc;
N = 29;
T = 1/fs;
syms n_;