Skip to content

Instantly share code, notes, and snippets.

View rendon's full-sized avatar
🧑‍🔬
Trying new things out.

Rafael Rendón rendon

🧑‍🔬
Trying new things out.
View GitHub Profile
@rendon
rendon / base64.cpp
Created August 4, 2023 03:30
Basic Base64 encoding
// Reference: https://en.wikipedia.org/wiki/Base64
#include <bits/stdc++.h>
using namespace std;
const char* alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
int getValue(char c) {
int len = strlen(alphabet);
for (int i = 0; i < len; i++) {
if (c == alphabet[i]) { return i; }
@rendon
rendon / LeetCodeHelper.js
Last active September 15, 2023 22:54
A script to copy LeetCode problem IDs to the clipboard
// ==UserScript==
// @name LeetCode Helper
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Facilitate interactions with the LeetCode website. It adds one button on the top-left to easily copy the problem ID and problem URL.
// @author Rafael Rendon Pablo
// @match https://leetcode.com/problems/*/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=leetcode.com
// @run-at document-idle
// @grant none
@rendon
rendon / Merriam-WebsterHelper.js
Last active March 17, 2024 22:13
A script that add the saved status to the Word of the Day page so you don't have to click on the "See the entry" link, thus saving you a few precious seconds
// ==UserScript==
// @name Merriam-Webster Helper
// @namespace http://tampermonkey.net/
// @version 0.1
// @description A tiny script that makes merriam-webster.com/ work nicely with Vimium, namely, it removes the focus from the search bar so that you can use the vim commands to move around.
// @author Rafael Rendon Pablo
// @run-at document-idle
// @match https://www.merriam-webster.com/
// @match https://www.merriam-webster.com/word-of-the-day
// @match https://www.merriam-webster.com/word-of-the-day/*
#include <bits/stdc++.h>
using std::vector;
using std::pair;
using std::set;
using std::unordered_map;
using std::unordered_set;
void updateIndex(vector<int> const& ballot, int& index, unordered_set<unsigned> const& losers, int C) {
while (index < C) {
int candidate = ballot[index];
#include <bits/stdc++.h>
using std::vector;
int main() {
int N;
std::cin >> N;
vector<bool> sieve(N);
int a = 1, b = 1;
sieve[a] = true;
sieve[b] = true;
#include <bits/stdc++.h>
using std::vector;
bool cycleIsIncomplete(vector<int> const & sequence, int a, int b, int idx) {
unsigned m = sequence.size();
int aa = sequence[(idx-2+m)%m];
int bb = sequence[(idx-1+m)%m];
return aa != a || bb != b;
}
#include <bits/stdc++.h>
using std::vector;
void printAnswer(int frequency, int station) {
if (frequency < station) {
std::cout << "adelante " << station - frequency << "\n";
} else if (frequency > station) {
std::cout << "atras " << frequency - station << "\n";
}
}
// NOTE: Code from my early beginnings (circa 2010).
#include<iostream>
#include <cstdio>
#define MAX_V 1001
#define INFINITO 1000000 //Cualquier valor mas grande que los pesos que usemos
void InicializaArreglos();
void Dijkstra(int NodoInicial);
int AunEncolado(int nodo);
int DevuelveMinimo();
#include <bits/stdc++.h>
using namespace std;
int const kInf = 1 << 29;
struct edge {
int node;
int cost;
};
struct state {
@rendon
rendon / scaler.sh
Last active July 5, 2021 16:13
A script to scale images using ImageMagick
#!/usr/bin/env bash
SOURCE_DIRECTORY=$1 # Provide absolute path
TARGET_DIRECTORY=$2 # Provide absolute path
if [ ! -d $SOURCE_DIRECTORY ]
then
echo "Source directory ${SOURCE_DIRECTORY} does not exist"
exit 1
fi