Skip to content

Instantly share code, notes, and snippets.

View voidnerd's full-sized avatar
:octocat:
Debugging

Ndifreke Friday voidnerd

:octocat:
Debugging
View GitHub Profile
@voidnerd
voidnerd / tideman.c
Created April 29, 2020 13:37
cs50 Problem Set 3 - Tideman Solution
#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];
#include <stdio.h>
int main(void)
{
int num1 = -1, num2 = -1;
int result;
char key;
printf("Enter two numbers: ");
scanf("%d,%d", &num1, &num2);
@voidnerd
voidnerd / helpers.c
Last active August 25, 2022 12:13
cs50 Problem Set 4 - Filter (less) Solution
#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++) {
@voidnerd
voidnerd / helpers.c
Created June 13, 2020 01:29
cs50 Problem Set 4 - Filter (more) Solution
#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++) {
@voidnerd
voidnerd / recover.c
Created June 13, 2020 01:31
cs50 Problem Set 4 - Recover Solution
#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[])
@voidnerd
voidnerd / dictionary.c
Created June 13, 2020 01:32
cs50 Problem Set 5 - Speller Solution
// 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"
@voidnerd
voidnerd / dna.py
Last active September 29, 2022 10:27
CS50 Problem Set 6 - DNA Solution
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);
@voidnerd
voidnerd / Mail.js
Last active July 17, 2020 03:57
Email Templating Nodejs Helper
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 */
module.exports = {
apps: [
{
name: 'nuxtapp',
exec_mode: 'cluster',
instances: 'max', // Or a number of instances
script: './node_modules/nuxt/bin/nuxt.js',
args: 'start',
watch: '.',
watch_delay: 3000,
@voidnerd
voidnerd / 20190417131115_test-setup.ts
Created October 22, 2021 18:48 — forked from jukkatupamaki/20190417131115_test-setup.ts
How to use Knex.js in a TypeScript project
import { Knex } from 'knex'
export async function up(knex: Knex): Promise<any> {
await knex.schema.createTable('test_setup', (table: Knex.TableBuilder) => {
table.integer('foobar');
});
}
export async function down(knex: Knex): Promise<any> {
await knex.schema.dropTable('test_setup');