Skip to content

Instantly share code, notes, and snippets.

@megarubber
megarubber / pca.r
Created November 4, 2024 22:02
PCA com R (Métodos Estatísticos Multivariados)
dados<-read.csv2("/home/aluno/Documentos/dados1_PCA.csv",header=T)
dados_sem_titulo<-data.frame(
dados$ganho_bruto,
dados$ganho_liquido,
dados$patrimonio
)
matriz_covariancia<-cov(dados_sem_titulo)
@megarubber
megarubber / counting.c
Last active April 2, 2024 16:33
Counting Sort
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define MAX 10000000
void countingsort(int* A, int* B, int size) {
int i;
int k = A[0];
#include <stdio.h>
#include <stdlib.h>
#define MAX 105
void sort(int *array, int k) {
int* ord = (int*)malloc(k * sizeof(int));
int i = 0;
@megarubber
megarubber / statistics.R
Created March 20, 2024 12:59
Estatística descritiva com R
x = 10
x
y <- c(10, 9, 8) # concatenar
y
x1 <- seq(0,1, by=0.1) # Cria sequencia de 0 até 1 (pulando 0.1)
x1
help(x1)
@megarubber
megarubber / quicksort.c
Created March 18, 2024 14:22
Quicksort in C
#include <stdio.h>
#include <stdlib.h>
// Returns the pivot
int partition(int *vet, int p, int r) {
int q = vet[r], i = p - 1, j = 0, temp = 0;
for(j = p; j < r - 1; j++) {
if(vet[j] < q) {
i++;
@megarubber
megarubber / commits.txt
Created June 9, 2023 23:27
Convential commits for me never forget anymore
feat: Used when adding a new feature to the project.
fix: Used when fixing a bug or issue in the project.
docs: Used for documentation-related changes, such as updating README files or adding comments.
style: Used for code style changes, such as formatting, indentation, or renaming variables.
refactor: Used when making code changes that neither fix a bug nor add a feature, but improve the overall structure or readability.
test: Used for adding or modifying tests.
chore: Used for miscellaneous tasks, such as updating dependencies, configuring build tools, or performing maintenance tasks.
@megarubber
megarubber / test.html
Created May 19, 2023 03:01
Repeat a HTML element for multiple pages, using vanilla JS
<include src="path_to_your_html_file"></include>
<script type="text/javascript">
async function includeHTML() {
const includes = document.getElementsByTagName('include');
[].forEach.call(includes, include => {
let filePath = include.getAttribute('src');
fetch(filePath).then((file) => {
file.text().then((content) => {
include.insertAdjacentHTML('afterend', content);
@megarubber
megarubber / image_test.py
Created May 19, 2023 02:52
Detect a simple face landmarks using Google's Mediapipe
import numpy
import math
import cv2
import mediapipe as mp
DESIRED_HEIGHT = 480
DESIRED_WIDTH = 480
localImages = [
r'/home/guilherme/Projects/mediapipe/teste.png'
@megarubber
megarubber / video.dart
Last active March 23, 2023 00:47
PageView + video_player package
import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';
class Desafio extends StatefulWidget {
const Desafio({Key? key}) : super(key: key);
@override
State<Desafio> createState() => DD();
}
@megarubber
megarubber / jogo.dart
Created March 22, 2023 01:31
Ball collision gyroscope flutter
import 'package:flutter/material.dart';
import 'package:sensors_plus/sensors_plus.dart';
import 'dart:math';
class Jogo extends StatefulWidget {
const Jogo({Key? key}) : super(key: key);
@override
State<Jogo> createState() => JJ();
}