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
| func main() { | |
| gen := func(ctx context.Context) <-chan int { | |
| dst := make(chan int) | |
| n := 1 | |
| go func() { | |
| for { | |
| select { | |
| case <-ctx.Done(): | |
| fmt.Println("done", ctx.Err()) | |
| os.Exit(0) |
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 swap(firstNumber, secondNumber) { | |
| // put your code here, so that firstNumber is the secondNumber and secondNumber and is the firstNumber | |
| // -------------- DO NOT TOUCH BELOW HERE ----------------------------- | |
| console.log(firstNumber) // should be 6 | |
| console.log(secondNumber) // should be 5 | |
| } | |
| swap(5,6) |
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
| // The chinese remainder theorem finds the number that | |
| // satisfies a set of equations where the divisors are pairwise coprime | |
| // (where the highest common factor between the divisors is 1) and the remainder is own. | |
| // Eg. x = 2 (mod 3) = 3 (mod 5) = 2 (mod 7). Where 3,5, and 7 are pairwise coprime. | |
| package main | |
| import "fmt" | |
| // Eg. x = b1(mod n1) = b2(mod n2) = b3(mod n3) |
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 str = "i am a boy and i am happy to be in your midst" | |
| const final = {} | |
| str.split(" ").map((s, index, arr) => { | |
| // remove the commas | |
| // make lowercase | |
| // console.log({s}) | |
| if(s == "am") { | |
| if(!final[s]) { |
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 IEdge { | |
| key: string | |
| from: string | |
| to: string | |
| } | |
| interface IVertex { | |
| key: string | |
| label: string | |
| } |
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
| /******************** HELPER FUNCTION **********************/ | |
| //Filter array for any distinct values --- STACKOVERFLOW | |
| function isDistinct(array) { | |
| return new Set(array).size === array.length; | |
| } | |
| // Use combination sum to get all the possible combinations | |
| function combinationSum(candidates, target) { | |
| var result = []; |
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 https = require("https"); | |
| const monthNames = [ | |
| "January", | |
| "February", | |
| "March", | |
| "April", | |
| "May", | |
| "June", | |
| "July", |
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 { expect } = require('chai') | |
| const createCategoryFactory = require('../create-category') | |
| const ProductCategory = require('./mocks/product-category.mock') | |
| const req = require('./mocks/req.mock') | |
| const res = require('./mocks/res.mock') | |
| describe('create-category', () => { | |
| const createCategory = createCategoryFactory({ ProductCategory }) | |
| beforeEach(() => { |
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 newCategory = { | |
| Thumbnail: undefined, | |
| checkFile (category, file) { | |
| file ? | |
| category.categoryThumbnail = {name: file.public_id, url: file.url} | |
| : category.categoryThumbnail = null | |
| this.Thumbnail = category.categoryThumbnail; | |
| return this; | |
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 typeDefs = gql` | |
| scalar Date | |
| # Make a type user | |
| type User { | |
| email: String! | |
| password: String! | |
| data: [Graph!] | |
| } |
NewerOlder