Skip to content

Instantly share code, notes, and snippets.

View Maxondria's full-sized avatar
🏠
Working from home

Maxon Tayebwa Maxondria

🏠
Working from home
View GitHub Profile
@prof3ssorSt3v3
prof3ssorSt3v3 / reflect.js
Created September 27, 2020 19:01
How to use the Reflect object in JavaScript to intercept JS object operations
// Reflect Object - built-in object that provides methods for interceptable JavaScript operations
// All methods are static
// has no constructor cannot use `new`
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect
const log = console.log;
let alex = {
name: 'Alex',
id: 93,
hello: function (a, b) {
@Maxondria
Maxondria / custom-node-event-emitter.js
Created May 14, 2019 19:22
Custom Node Event Emitter
//emitter.js
const Emitter = function(){
this.events = {}
}
Emitter.prototype.on = function(type, callback){
this.events[type] = this.events[type] || [];
this.events[type].push(callback);
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Cookies</title>
<style>
html {
@NigelEarle
NigelEarle / Knex-Migrations-Seeding.md
Last active February 17, 2025 18:17
Migration and seeding instructions using Knex.js!

Migrations & Seeding

What are migrations??

Migrations are a way to make database changes or updates, like creating or dropping tables, as well as updating a table with new columns with constraints via generated scripts. We can build these scripts via the command line using knex command line tool.

To learn more about migrations, check out this article on the different types of database migrations!

Creating/Dropping Tables

// inherit-compose.js
// Inheritance vs Composition
//INHERITANCE
// Character > Human > Sam
// Character > Robot > x73
// Character > Cyborg > Dolph
const Character = {
talk: function(...msg){