Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Debugging

Ndifreke Friday ndiecodes

:octocat:
Debugging
View GitHub Profile
@ndiecodes
ndiecodes / Mail.js
Last active Jul 17, 2020
Email Templating Nodejs Helper
View Mail.js
const nodemailer = require("nodemailer");
const path = require("path");
const hbs = require("nodemailer-express-handlebars");
const exphbs = require("express-handlebars");
const Handlebars = require("handlebars");
const {
allowInsecurePrototypeAccess,
} = require("@handlebars/allow-prototype-access");
/** Start Mail Helper */
@ndiecodes
ndiecodes / dna.py
Last active Jun 15, 2020
CS50 Problem Set 6 - DNA Solution
View dna.py
from csv import reader, DictReader
from sys import argv, exit
sequences = {}
#validate input
if len(argv) < 3:
print("Usage:", "python dna.py data.csv sequence.txt")
exit(1);
@ndiecodes
ndiecodes / dictionary.c
Created Jun 13, 2020
cs50 Problem Set 5 - Speller Solution
View dictionary.c
// Implements a dictionary's functionality
#include <stdbool.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <strings.h>
#include <stdint.h>
#include <ctype.h>
#include "dictionary.h"
@ndiecodes
ndiecodes / recover.c
Created Jun 13, 2020
cs50 Problem Set 4 - Recover Solution
View recover.c
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
//eliminate magic numbers
#define BLOCK_SIZE 512
typedef uint8_t BYTE;
int main(int argc, char *argv[])
@ndiecodes
ndiecodes / helpers.c
Created Jun 13, 2020
cs50 Problem Set 4 - Filter (more) Solution
View helpers.c
#include "helpers.h"
#include <math.h>
// Convert image to grayscale
void grayscale(int height, int width, RGBTRIPLE image[height][width])
{
float rgbGray;
for (int i = 0; i < height; i++)
{
for (int j = 0; j < width; j++) {
@ndiecodes
ndiecodes / helpers.c
Last active Jun 13, 2020
cs50 Problem Set 4 - Filter (less) Solution
View helpers.c
#include "helpers.h"
#include <math.h>
// Convert image to grayscale
void grayscale(int height, int width, RGBTRIPLE image[height][width])
{
float rgbGray;
for (int i = 0; i < height; i++)
{
for (int j = 0; j < width; j++) {
View calculator.c
#include <stdio.h>
int main(void)
{
int num1 = -1, num2 = -1;
int result;
char key;
printf("Enter two numbers: ");
scanf("%d,%d", &num1, &num2);
@ndiecodes
ndiecodes / tideman.c
Created Apr 29, 2020
cs50 Problem Set 3 - Tideman Solution
View tideman.c
#include <cs50.h>
#include <stdio.h>
#include <string.h>
// Max number of candidates
#define MAX 9
// preferences[i][j] is number of voters who prefer i over j
int preferences[MAX][MAX];
@ndiecodes
ndiecodes / runoff.c
Created Apr 26, 2020
CS50 Problem Set 3 - Runoff
View runoff.c
#include <cs50.h>
#include <stdio.h>
#include <string.h>
// Max voters and candidates
#define MAX_VOTERS 100
#define MAX_CANDIDATES 9
// preferences[i][j] is jth preference for voter i
int preferences[MAX_VOTERS][MAX_CANDIDATES];
@ndiecodes
ndiecodes / plurality.c
Created Apr 19, 2020
CS50's Problem Set 3 - Plurality
View plurality.c
#include <cs50.h>
#include <stdio.h>
#include <string.h>
// Max number of candidates
#define MAX 9
// Candidates have name and vote count
typedef struct
{
You can’t perform that action at this time.