Skip to content

Instantly share code, notes, and snippets.

View dmcleish91's full-sized avatar

Dwight McLeish Jr dmcleish91

View GitHub Profile
@dmcleish91
dmcleish91 / messagebus.ts
Created November 20, 2024 22:12
An example implementation of a simple message bus in TypeScript using the publish-subscribe pattern
type MessageHandler = (message: any) => void;
class MessageBus {
private subscribers: Map<string, MessageHandler[]> = new Map();
// Subscribe to a specific message type
subscribe(messageType: string, handler: MessageHandler): void {
if (!this.subscribers.has(messageType)) {
this.subscribers.set(messageType, []);
}

Deploy Go to ubuntu snippets

Login to Ubuntu VPS

ssh [email protected]

Update packages

apt-get update
@dmcleish91
dmcleish91 / grokking_to_leetcode.md
Created March 17, 2023 01:54 — forked from tykurtz/grokking_to_leetcode.md
Grokking the coding interview equivalent leetcode problems

GROKKING NOTES

I liked the way Grokking the coding interview organized problems into learnable patterns. However, the course is expensive and the majority of the time the problems are copy-pasted from leetcode. As the explanations on leetcode are usually just as good, the course really boils down to being a glorified curated list of leetcode problems.

So below I made a list of leetcode problems that are as close to grokking problems as possible.

Pattern: Sliding Window

package com.company;
import java.util.ArrayList;
import java.util.Scanner;
public class user {
private String userName;
private String passWord;
private String name;
private double hoursWorked[] = new double[5];
package com.company;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int testScore = 0;
int answer;
package com.company;
public class Main {
public static void main(String[] args) {
//Default Values
double wallSpace = 115;
double gallonsOfPaint = 1;
double hoursOfLabor = 8;
double dollarCostPerHour = 20;
@dmcleish91
dmcleish91 / node.cpp
Last active September 30, 2016 01:05
// Practice.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
using namespace std;
struct node //stores an integer and a pointer to the
{ //next node
#include <iostream>
#include <string>
using namespace std;
void change(string* change_first, string* change_last) // in this function we created a pointer
{
*change_first = "Master"; // this allows us to change the variable because we know its memory address
*change_last = "piece";
#include <iostream>
using namespace std;
void change(int* x) // essential we made a new pointer and pointed it to the same address as p
{
*x = 20; // this dereferences our pointer so we can change the variable. remember this is pointing to the memory on the heap
}
int main()
#include "stdafx.h"
#include <string> // to cout a string you need this library
#include <iostream>
using namespace std;
void setName(string *x, string *y) // this doesnt return anything it just modifies the memory address
{
*x = "Dwight";
*y = "Sucks";