Skip to content

Instantly share code, notes, and snippets.

View caelinsutch's full-sized avatar
🕶️
locked in

Caelin Sutch caelinsutch

🕶️
locked in
View GitHub Profile
@caelinsutch
caelinsutch / sockets.ts
Last active December 30, 2019 22:15
Socket.io Authentication
// SERVER CODE
import io from "socket.io";
import { IGb, model as Gb } from "../models/gb"; // My mongoose schema
const server = io.listen(8000);
/**
* Server auth using username and password of Gb
*/
@caelinsutch
caelinsutch / Book.ts
Created November 18, 2020 18:54
Book Class Example
class Book {
function getTitle() {
return "Book Name";
}
function getAuthor() {
return "Author Name";
}
@caelinsutch
caelinsutch / Book.ts
Last active November 18, 2020 19:14
Book Refactored with PageStyle
interface BookStyle {
function pageStyle(): string;
}
class Book implements Bookstyle {
function getTitle() {
return "A Great Book";
@caelinsutch
caelinsutch / Book.ts
Created November 18, 2020 19:16
Book SRP
interface BookStyle {
function pageStyle(): string;
}
class Book implements Bookstyle {
function getTitle() {
return "A Great Book";
@caelinsutch
caelinsutch / PasswordReminder.ts
Created November 18, 2020 19:45
Password Reminder
class PasswordReminder {
private dbConnection;
constructor(MySQLConnection dbConnection) {
this.dbConnection = dbConnection;
}
}
@caelinsutch
caelinsutch / PasswordReminder.ts
Created November 18, 2020 19:45
Password Reminder Modified
class MySQLConnection implements DBConnectionInterface {
public function connect() {
return "Connection"
}
}
class PasswordReminder {
private dbConnection;
constructor(DBConnectionInterface dbConnection) {
this.dbConnection = dbConnection;
@caelinsutch
caelinsutch / simple.js
Created December 21, 2020 02:39
Simple useEffect example
import React, { useEffect } from 'react';
function Simple() {
useEffect(() => {
console.log("Use Effect!")
})
return (
<div>
@caelinsutch
caelinsutch / wrapper.js
Created December 21, 2020 02:44
Rerendering Simple
import React, { useState } from 'react';
import Simple from './simple'
function Wrapper() {
const [count, setCount] = useState(0);
const updateCount = () => setCount(count + 1);
return (
<div>
@caelinsutch
caelinsutch / wrapper.js
Created December 21, 2020 02:47
Wrapper modified
import React, { useState } from 'react';
import Simple from './simple'
function Wrapper() {
const [count, setCount] = useState(0);
const updateCount = () => setCount(count + 1);
return (
<div>
@caelinsutch
caelinsutch / simple.js
Created December 21, 2020 02:50
useEffect with Unmount
import React, { useEffect } from 'react';
function Simple() {
useEffect(() => {
console.log("Use Effect!")
return () => {
console.log("Unmount")
}
})