Skip to content

Instantly share code, notes, and snippets.

View hellmrf's full-sized avatar

Heliton Martins hellmrf

View GitHub Profile
@hellmrf
hellmrf / build_php.sh
Created May 15, 2024 08:02
Script to build PHP 8.3 from source with ZTS enabled on Linux
#!/bin/bash
# From https://harry.plus/blog/install-php-zts-with-ext-parallel-in-ubuntu/
apt install build-essential pkg-config autoconf bison re2c libxml2-dev libssl-dev libsqlite3-dev libcurl4-openssl-dev libpng-dev libjpeg-dev libonig-dev libfreetype6-dev libzip-dev libtidy-dev libwebp-dev
VERSION=8.3.0
wget -qO- https://www.php.net/distributions/php-${VERSION}.tar.gz | tar -xz
cd php-${VERSION}/ext
git clone --depth=1 https://github.com/krakjoe/parallel.git
@hellmrf
hellmrf / vetor_dinamico.por
Created December 17, 2023 04:22
Vetor de tamanho dinâmico no Portugol Studio
/**
* HM Programming <https://www.youtube.com/@HMProgramming>
* Autor: Heliton Martins <helitonmrf@gmail.com>, https://linktr.ee/hellmrf
* Data: 17 de dezembro de 2023
* Runtime: Portugol Studio <https://univali-lite.github.io/Portugol-Studio/>
*/
programa {
funcao inicio() {
inteiro vetor[100]
@hellmrf
hellmrf / ltxcleandir.sh
Last active August 13, 2021 19:59
Bash script to clean auxiliary files in all LaTeX projects from a specific folder, using latexmk.
#!/usr/bin/bash
cd "$(pwd)"
FILES=$(find . -name "*.tex")
echo -e "\u001b[33mI will clear the aux files for the following projects (.tex, .bib, .bbl and .pdf will remain untouched):\u001b[0m"
echo $FILES
read -p "Great? [Y/n] " -n 1 -r
@hellmrf
hellmrf / .latexmkrc
Last active August 3, 2021 15:27
LaTeXmk configuration to use PythonTeX
#!/bin/perl
$pdf_mode = 5; # use XeLaTeX by default
# Support for pythontex in v. 0.16 or higher, with latexmk 4.62 or higher
#
# What these definitions provide/do:
# 1. Variable specifying command string for invoking pythontex
# 2. Addition to %extra_rule_spec of template for pythontex rule. This
# tells latexmkrc to create the rule when it is initializing for
# processing a TeX file.
@hellmrf
hellmrf / .md
Created April 12, 2021 15:21
Observações do vídeo Migrando de Portugol Studio para Python #2

Observações e erratas

  • Embora eu não tenha mostrado isso explicitamente, as operações unárias também existem em Python. Os exemplos são:
a = 10
+a # O conteúdo numérico inalterado = 10
-a # A negação do conteúdo numérico = -10
~a # A inversão bit a bit do conteúdo numérico = -(a+1). Veja Two's Complement para entender essa fórmula "mágica". Links para isso na seção se links.
  • Operadores aritméticos também podem ser usados como funções quando necessário. Veja o link do módulo operator (da standard library) na seção de links abaixo.
@hellmrf
hellmrf / .md
Last active April 11, 2021 14:01
Observações do vídeo Migrando de Portugol Studio para Python #1

Observações e Erratas

  • [10:10] Caso você queira fazer isso, sugiro pesquisar por "clear Python". A técnica consiste em chamar um comando do emulador de terminal que se está usando, seja ele o clear (Linux, Mac e Powershell) ou cls (Windows). Após importar o pacote os (parte da standard library), basta fazer os.system("clear").
  • [11:45] Faltou comentar que 'a', que seria um caractere em Portugol, é simplesmente uma string de tamanho 1 em Python. Assim, 'a' == "a".
  • [13:45] Na verdade, o nome correto é Geroge Boole e ele é o pai da Lógica Booleana, essa que se estuda usando tabelas verdade e é a base fundamental de todos os computadores modernos.
  • [14:51] O sistema de tipos em Python inclui:
    • Tipagem dinâmica: os tipos só são determinados em tempo de execução, e podem ser mutados. É o contrário de tipagem estática (como Portugol Studio, C++, Java, Rust dentre outras).
    • Tipagem Forte: o tipo é levado em conta para a maioria das operaç
@hellmrf
hellmrf / test.c
Created October 15, 2020 03:14
Testing performance of some languages when counting 10^9 iterations.
#include <time.h>
#include <stdio.h>
int for_loop(int ite)
{
int a = 0;
for(int i = 0; i < ite; i++)
{
a = a + 1;
}
programa
{
inclua biblioteca Matematica --> mat
funcao real f(real x){
retorne (mat.potencia(x,5)) + 27*(mat.potencia(x,4)) - ((13/4) * (mat.potencia(x,3))) + ((0.5)*mat.potencia(x,4)) + (37*x) + 15
}
funcao real integral(real a, real b, inteiro n){
real A = 0.0 //area
real Dx = (b-a)/n //Delta x
real b1, b2 //bases