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
const http = require('http') | |
const fs = require('fs') | |
const mime = require('mime') | |
const server = http.createServer().listen(3000) | |
server.on('request', (req, res)=>{ | |
const filePath = __dirname + req.url | |
fs.stat(filePath, (err, stat)=>{ |
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
body { | |
} | |
.slider{ | |
margin: auto; | |
width: 400px; | |
overflow: hidden; | |
position: relative; | |
} |
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
const fs = require('fs') | |
const txtFetcherInDir = (dirname, callback)=>{ | |
fs.readdir(dirname, (err, files) => { | |
if (err) throw err; | |
const endWithtxt= files.filter((file)=>{ | |
const lastDot = file.lastIndexOf('.') + 1 | |
return file.substring(lastDot) === 'txt' | |
}) | |
callback(endWithtxt) |
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
const createStudentCalsses = function(...classes){ | |
console.log(classes.length) | |
if(classes[0].length < 1) throw new Error("You should enroll in at least two classes") | |
const privateObj = {} | |
privateObj.classes = classes; | |
const studentClasses = { | |
getClasses(){ return privateObj.classes} |
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
const net = require('net') | |
const tcp = net.createServer() | |
tcp.maxConnections = 2 | |
const notTheSame = (sender, receiver) => sender !== receiver | |
const messageOthers = (sockets,sender,callback)=>{ | |
sockets.forEach((receiver,i)=>{ |
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
class NodeTree{ | |
constructor(data, leftNode, rightNode){ | |
this.data = data; | |
this.leftNode = leftNode; | |
this.rightNode = rightNode; | |
} | |
display(){ | |
return this.data | |
} |
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
class Set{ | |
constructor(){ | |
this.data = new Array(); | |
} | |
_exist(ele){ | |
return this.data.indexOf(ele) >= 0 | |
} | |
add(ele){ |
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
let LinkedList = require('./linked_list'); | |
class HashTable{ | |
constructor(size){ | |
this.table = new Array(size); | |
} | |
_setup(key, index,head){ | |
let obj = {}; | |
obj[key] = head; |
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
class Dictionary{ | |
constructor(){ | |
this.data = new Array(); | |
} | |
add(key, val){ | |
this.data[key] = val; | |
} | |
remove(key){ |
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
class Node{ | |
constructor(val){ | |
this.val = val; | |
this.next = null | |
} | |
} | |
class LinkedList{ | |
constructor(valOfHead){ |
NewerOlder