This file contains hidden or 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
| //arr.find((char) => arr.indexOf(char) === arr.lastIndexOf(char)) | |
| function getUniqueChar(str){ | |
| aLoop: | |
| for(let i = 0; i < str.length; i++){ | |
| for(let j = 0; j < str.length; j++){ | |
| if(i !== j && str[i] === str[j]) | |
| continue aLoop | |
| } | |
| return i | |
| } |
This file contains hidden or 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 Methods = { | |
| scope: {}, | |
| isInteger(number){ | |
| return this.EQ(Math.floor(Number(number)), number) | |
| }, | |
| isFloat(number){ | |
| return this.EQ(Number(number), number) && this.NEQ(number % 1, 0) | |
| }, | |
| isBoolean(value){ | |
| return this.EQ(Boolean(value), value) |
This file contains hidden or 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 watch(callback, deps) { | |
| let cleanup = null | |
| function apply() { | |
| if (cleanup) cleanup() | |
| cleanup = callback() | |
| } | |
| if (deps) { | |
| let values = [] |
This file contains hidden or 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 checkIfObjectTypeof(obj){ | |
| return obj === "object" | |
| } | |
| class EventEmitter { | |
| constructor(){ | |
| this.events = {} | |
| } | |
| on(event, listener){ |
This file contains hidden or 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
| interface IDepartment { | |
| id: string | |
| name: string | |
| createdAt: Date | |
| updatedAt: Date | |
| } | |
| interface DepartmentMethods<in out T> { | |
| getDepartment(): T | |
| removeDepartment(department: T): void |
This file contains hidden or 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 audioContext = new (window.AudioContext || window.webkitAudioContext)(); | |
| const audioURL = "./sample4.wav"; | |
| let newAudio; | |
| // load audio by url | |
| async function loadAudio(url) { | |
| const response = await fetch(url, { | |
| mode: "no-cors", |
This file contains hidden or 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 machine = { | |
| state: "GREEN", | |
| prevState: "YELLOW", | |
| transitions: { | |
| RED: { | |
| execute(){ | |
| this.changeState("YELLOW", "RED") | |
| } | |
| }, | |
| YELLOW: { |
This file contains hidden or 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 arr = [20, 10, 5, 1, 2, 3, 4, 11, 80, 1809, 34340, 2341, 5657] | |
| function linearSearch(list, key){ | |
| for(let i = 0; i < list.length; i++){ | |
| if(list[i] === key){ | |
| return [list[i], i] | |
| } | |
| } | |
| return null | |
| } |
This file contains hidden or 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: | |
| def __init__(self, x): | |
| self.data = x | |
| self.left = None | |
| self.right = None | |
| self.count = 0 | |
| def insert(root, x): | |
| if root == None: | |
| return Node(x) |
This file contains hidden or 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 persons = [ | |
| {name: 'Peter', profession: 'teacher', age: 20, maritalStatus: 'married'}, | |
| {name: 'Michael', profession: 'teacher', age: 50, maritalStatus: 'single'}, | |
| {name: 'Peter', profession: 'teacher', age: 20, maritalStatus: 'married'}, | |
| {name: 'Anna', profession: 'scientific', age: 20, maritalStatus: 'married'}, | |
| {name: 'Rose', profession: 'scientific', age: 50, maritalStatus: 'married'}, | |
| {name: 'Anna', profession: 'scientific', age: 20, maritalStatus: 'single'}, | |
| {name: 'Anna', profession: 'politician', age: 50, maritalStatus: 'married'} | |
| ]; |