Skip to content

Instantly share code, notes, and snippets.

View ruanpetterson's full-sized avatar
🏠
Working from home

Ruan Petterson ruanpetterson

🏠
Working from home
View GitHub Profile

Keybase proof

I hereby claim:

  • I am ruanpetterson on github.
  • I am ruanpetterson (https://keybase.io/ruanpetterson) on keybase.
  • I have a public key whose fingerprint is 1B9C 43D4 C297 E95C DC33 613B 5BB4 8885 465B 1B76

To claim this, I am signing this object:

#include <stdio.h>
#include <string.h>
void swap(char *a, char* b);
void reverse(char* s);
int main() {
char s[] = "Hello, world!";
printf("Before: %s\n", s);
@ruanpetterson
ruanpetterson / makerom.c
Last active July 16, 2021 15:39
[Ben Eater] Build a 6502 computer
#include <stdio.h>
#include <unistd.h>
#define SIZE 0x8000
int main() {
FILE *fp = fopen("rom.bin", "w");
if (fp != NULL) {
unsigned char rom[SIZE];
@ruanpetterson
ruanpetterson / main.cpp
Last active June 14, 2021 09:04
Binary Search Tree Example
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <iostream>
template <typename T> struct Node {
bool filled;
T data;
Node* left;
Node* right;
#include <iostream>
using namespace std;
static void usage()
{
cerr << "usage: fibonacci N" << endl;
}
int main(int argc, char *argv[])
@ruanpetterson
ruanpetterson / movida.py
Last active July 23, 2020 11:40
Scraping daily rates of Movida Rent a Car
from bs4 import BeautifulSoup as bs
from datetime import date, datetime, timedelta
import random, requests
class Movida(object):
possible_locations = ['RBR', 'MCZ', 'MAA', 'MCP', 'MAO', 'MOVMAN', 'MOVCMR', 'FEC', 'IOS', 'SSA', 'BPS', 'MOVSVD', 'VDC', 'FOR', 'FORC', 'JDOC01', 'BSB', 'MOVTAG', 'MOVLNR', 'VIX', 'MOVANP', 'MOVAG', 'GYN', 'MOVHCG', 'MOVRVD', 'IMP', 'SLZ', 'CC', 'CGB', 'CGR', 'MOVCGC', 'MOVDOC', 'MOVBHC', 'MOVBHZ', 'PLU', 'MOVBHCL', 'MOVBHR', 'MOVBET', 'MOVCTG', 'JDFC', 'IZA', 'CNF', 'MOC', 'MOVPAL', 'UBA', 'UDI', 'JPA', 'CPV', 'JPAC01', 'MOVCCV', 'MOVCWB', 'IGU', 'LDB', 'MGF', 'MOVPTG', 'CWB', 'BEL', 'MOVBLC', 'MAB', 'CRJ', 'MOVCKS', 'PNZ', 'REC', 'RECC02', 'MOVRFR', 'THE', 'MOVCPG', 'MOVMCE', 'MOVNTR', 'MOVQRZ', 'MOVRJB', 'MOVCOPA', 'GIG', 'MOVJPG', 'MOVMDR', 'MOVRNR', 'MOVSHH', 'SDU', 'MOVMSR', 'MOVNTC', 'NAT', 'MOVCNS', 'CXJ', 'MOVNHG', 'MOVPLT', 'POA', 'POABOX', 'MOVPOAC', 'PAS', 'PVH', 'BVB', 'MOVBLM', 'FLN', 'JOI', 'MOVJOI', 'NVT', 'MOVAME', 'MOVARB', 'MOVAPH', 'MOVBAU', 'VCP', 'MOVCPQC
@ruanpetterson
ruanpetterson / monty_hall.cpp
Last active February 17, 2021 04:42
Simulation of Monty Hall problem with n doors
#include <iostream>
#include <ctime>
using namespace std;
int monty_hall(bool switch_doors = true)
{
unsigned short int n_doors, choice, prize;
n_doors = 3;
@ruanpetterson
ruanpetterson / calendar.js
Last active May 23, 2020 09:00
Calendar Generator in Javascript
/**
* Calendar Generator
* @param {string} element - HTML element by ID
*/
var Calendar = function(element = '#calendar') {
let d = new Date()
this.year = d.getFullYear()
this.month = d.getMonth() + 1
this.element = element