Skip to content

Instantly share code, notes, and snippets.

View richardiwnl's full-sized avatar
💻
Focusing

Richard Ferreira richardiwnl

💻
Focusing
View GitHub Profile
@richardiwnl
richardiwnl / validaCPF.js
Created December 4, 2022 01:51
Validador de CPF em JavaScript
function ValidaCPF(cpfEnviado) {
Object.defineProperty(this, "cpfLimpo", {
enumerable: true,
get: function() {
return cpfEnviado.replace(/\D+/g, '');
}
});
}
ValidaCPF.prototype.valida = function() {
@richardiwnl
richardiwnl / findProcessID.cpp
Created November 9, 2022 15:53
Searches for a process ID by its name
#include <iostream>
#include <Windows.h>
#include <TlHelp32.h>
DWORD findProcessID(const std::wstring_view processName);
int main()
{
std::cout << findProcessID(L"notepad.exe") << '\n';
@richardiwnl
richardiwnl / pagination.py
Created October 31, 2022 16:41
Pagination algorithm for web applications
def make_pagination(current: int, last: int, delta: int=2) -> list:
pagination_range = []
pagination_range_with_dots = []
left = None
for i in range(1, last + 1):
if (i == 1 or i == last
or i >= current - delta
and i < current + delta + 1):

Rust Cheat Sheet

Variables & Mutability

Variables are immutable by default. This makes Rust safer and makes concurrency easier.
Immutable means once a value is bound to that variable, it cannot be changed.
For example:

fn main() {
 let x = 5;
@richardiwnl
richardiwnl / primes.py
Created July 27, 2022 22:30
Looks for prime numbers until the nth element
import argparse
parser = argparse.ArgumentParser(
description='Calculates prime numbers until the nth element',
prog='primes',
epilog='Made with love by github.com/richardcss'
)
parser.add_argument(
'n',
@CTimmerman
CTimmerman / Tech prefs.md
Last active December 8, 2025 13:19
Technology preferences / tech prefs.

My Technology Preferences

For those who don't bother to remember.

Hardware

In recent years, it takes about 10 years to apply a discovery in a new field (e.g. "laptop batteries" in electric cars, down from 105 in case of radio's 1885 patent vs 1780 discovery, but it should be noted that electric cars like the 1914 Detroit Electric Model 47 Brougham worked just fine for city trips), 10 years to get it ready for mass production (e.g. Tesla), and 10 years to make it affordable to normal people (again Tesla).

Personal Computer

@tuxfight3r
tuxfight3r / 01.bash_shortcuts_v2.md
Last active December 11, 2025 07:36
Bash keyboard shortcuts

Bash Shortcuts

visual cheetsheet

Moving

command description
ctrl + a Goto BEGINNING of command line
@prashanthrajagopal
prashanthrajagopal / screenshot.cpp
Last active October 23, 2024 13:14
Take a screenshot and save as jpeg in c++
#include <stdio.h>
#include <windows.h>
#include <gdiplus.h>
#include <time.h>
int GetEncoderClsid(const WCHAR* format, CLSID* pClsid) {
using namespace Gdiplus;
UINT num = 0;
UINT size = 0;