Skip to content

Instantly share code, notes, and snippets.

View MichaelSitter's full-sized avatar
🇨🇦

Michael Sitter MichaelSitter

🇨🇦
View GitHub Profile
@MichaelSitter
MichaelSitter / trie.js
Last active January 22, 2018 17:41
JS Data structures - trie
function Trie() {
this.children = {}
this.value = null
}
Trie.prototype.isLeaf = function() {
return Object.keys(this.children).length === 0
}
Trie.prototype.isFree = function() {
@MichaelSitter
MichaelSitter / fib.js
Last active January 19, 2018 00:59
Memoized fib
function fib(n) {
var res = {}
function step(t) {
if (res[t]) {
return res[t]
}
if (t <= 1) {
res[t] = t
} else {
@MichaelSitter
MichaelSitter / binaryTree.js
Last active January 21, 2018 23:29
JS data structures - Binary Tree
function Node(item) {
this.value = item
this.left = null
this.right = null
}
function BinaryTree() {
this.root = null
}
@MichaelSitter
MichaelSitter / queue.js
Last active January 16, 2018 23:10
JS data structures - queue
'use strict';
function Node(item) {
this.value = item;
this.next = null;
}
function Queue() {
this.head = null;
this.tail = null;
@MichaelSitter
MichaelSitter / stack.js
Created January 16, 2018 22:48
JS data structures - Stack
'use strict';
function Node(item) {
this.value = item;
this.next = null;
}
function Stack() {
this.items = null;
}
@MichaelSitter
MichaelSitter / doubleLinkedList.js
Last active January 16, 2018 22:47
JS data structures - Doubly Linked List
'use strict';
function Node(v) {
this.value = v;
this.next = null;
this.prev = null;
}
function DoubleLinkedList() {
this.length = 0;
@MichaelSitter
MichaelSitter / singleLinkedList.js
Last active January 14, 2018 01:22
JS data structures - Singly Linked List
function Node(v) {
this.value = v;
this.next = null;
}
function LinkedList() {
this.length = 0;
this.head = null;
}
@MichaelSitter
MichaelSitter / hashTable.js
Last active January 14, 2018 01:23
JS data structures - Hash Table
function HashTable() {
var table = {};
this.set = function (key, value) {
table[key] = value;
};
this.get = function (key) {
return table[key];
};
this.clear = function () {
table = {};
@MichaelSitter
MichaelSitter / example_componentWithMixin.js
Created May 5, 2017 18:45
Vue testing question - spy on mixin methods
// Component
export default {
mixins: [NotificationMixin],
methods: {
okNotification() {
this.showNotification('OK')
}
}
}
@MichaelSitter
MichaelSitter / TryToTestMe.vue
Created April 20, 2017 18:15
Sample component for test exercise
<template>
<div class="team-management">
<div v-if="!hasPermission('account:write')">
Please contact your team administrator.
</div>
<div v-if="hasPermission('account:write')">
Team Administration
</div>
<button :disabled="!hasPermission('user:create')">Add Team Member</button>
<button :disabled="!hasPermission('user:delete')">Remove Team Member</button>