This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var colors = { | |
ALICEBLUE: '#F0F8FF', | |
ANTIQUEWHITE: '#FAEBD7', | |
AQUA: '#00FFFF', | |
AQUAMARINE: '#7FFFD4', | |
AZURE: '#F0FFFF', | |
BEIGE: '#F5F5DC', | |
BISQUE: '#FFE4C4', | |
BLACK: '#000000', | |
BLANCHEDALMOND: '#FFEBCD', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
char read_input_char() | |
{ | |
char c; | |
c = getch(); | |
if (c == '\033') { // if the first value is esc | |
c = getch(); // skip the [ | |
switch(c = getch()) { // the real value | |
case 'A': | |
// code for arrow up | |
return 'w'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This should be an external database in real development. This is just for simplified demonstration. | |
const memoryDB = { | |
users: {}, | |
usersCount: 0 | |
} | |
const express = require('express') | |
const obsidian = require('obsidian-js') | |
const bodyParser = require('body-parser') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HashTable.prototype.add = function(key, value) { | |
var index = key.hashCode(); | |
var tuple = [key, value]; | |
var bucket = this._storage.get(index); | |
if (bucket) { | |
for (var i = 0; i < bucket.length; i++) { | |
if (bucket[i][0] === key) { | |
bucket[i][1] = value; | |
} else { | |
bucket.push(tuple); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var arraySum = function(array) { | |
var total = 0; | |
if(array.length === 0) { | |
return 0; | |
} | |
var popped = array.pop(); | |
if(Array.isArray(popped)) { | |
total += arraySum(popped); | |
return total += arraySum(array); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var delegationObjects = { | |
Employee: (name) => Object.assign({ | |
name, | |
hello: () => console.log(`Hi, I'm ${name}`) | |
}), | |
Fulltime: (name, role) => Object.assign(delegationObjects.Employee(name), { | |
role, | |
weeklyHours: 40 | |
}), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var subclasses = { | |
Employee: function(name, role) { | |
this.name = name; | |
this.sayHi = function() { | |
console.log(this.name + ": I work " + this.weeklyHours + "hrs/week"); | |
}; | |
if(role === "manager" || role === "salesman") return subclasses.Fulltime(name, role); | |
else if(role === "temporary" || role === "traveling") return subclasses.Parttime(name, role); | |
}, | |
Fulltime: function(name, role) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Employee() { | |
this.name = ''; | |
this.dept = 'general'; | |
} | |
function Manager() { | |
Employee.call(this); | |
this.reports = []; | |
} | |
Manager.prototype = Object.create(Employee.prototype); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from random import randint | |
board = [] | |
for x in range(5): | |
board.append(["O"] * 5) | |
def print_board(board): | |
for row in board: | |
print " ".join(row) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var findLeft = function(grid, row, col) { | |
if(col > 0) { | |
return grid[row][col - 1]; | |
} else { | |
return undefined; | |
} | |
}; | |
var findRight = function(grid, row, col) { | |
if(col < grid[row].length-1) { |
NewerOlder