Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Debugging

Ndifreke Friday ndiecodes

:octocat:
Debugging
View GitHub Profile
View ViewService.ts
import { Edge } from 'edge.js'
import path from 'path'
import { LooseObject } from '../types'
export default class ViewService {
public constructor(
public view: string,
private data: LooseObject | null = null
) {}
public get path(): string {
@ndiecodes
ndiecodes / buildspec.yaml
Created Jun 26, 2022
Buildspec for typescript project on AWS CodeBuild
View buildspec.yaml
version: 0.2
phases:
install:
runtime-versions:
nodejs: 14.x
commands:
- npm install -g typescript
- npm install
pre_build:
commands:
@ndiecodes
ndiecodes / 20190417131115_test-setup.ts
Created Oct 22, 2021 — forked from jukkatupamaki/20190417131115_test-setup.ts
How to use Knex.js in a TypeScript project
View 20190417131115_test-setup.ts
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');
View ecosystem.config.js
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,
@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 Dec 19, 2021
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 Jul 11, 2022
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++) {