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
| // fn to generate the selector for BEM-compliant elements. | |
| @function bem($block, $element:null, $modifiers:null){ | |
| $selector: '.#{$block}'; | |
| @if($element != null){ | |
| $selector: $selector + '--#{$element}'; | |
| } | |
| @if($modifiers != 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
| const checkedAllLetters = (a, b) => Math.abs(a - b) <= 2 | |
| , isAlphaNumeric = char => /^[a-z0-9]+$/i.test(char) | |
| const isPalindrome = s => { | |
| const leftEqualsRight = (a, b) => s[a].toLowerCase() === s[b].toLowerCase() | |
| , pastMidpoint = n => n >= ((s.length -1)/2) | |
| let left = 0 | |
| , right = s.length - 1 |
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
| import threading | |
| from queue import Queue | |
| import time | |
| print_lock = threading.Lock() # special lock we're using to make sure each worker won't pring until it's done with it job | |
| def exampleJob(worker): | |
| time.sleep(0.5) # let's say a job takes .5s to finish | |
| with print_lock: # with the lock, print some info. when that's done, release the lock so another worker can print with it |
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
| type ArrayElement<ArrayType> = ArrayType extends (infer ElementType)[] ? ElementType : never; | |
| type ResolveType<T> = T extends Promise<infer R> ? R : T; | |
| type Wait = <T>( | |
| promises: | |
| T extends number ? T : | |
| T extends ArrayElement<T>[] ? (Promise<ArrayElement<T>> | ArrayElement<T>)[] : | |
| T | Promise<T>, | |
| minimumWaitTime?: T extends number ? never : number | |
| ) => Promise< |
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
| auto close tag | |
| auto rename tag | |
| better comments | |
| bracket pair colorizer | |
| night owl | |
| vetur | |
| prettier | |
| code runner | |
| Space Block Jumper | |
| https://marketplace.visualstudio.com/items?itemName=kamikillerto.vscode-colorize |
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 NoverlapConfig { | |
| hash?: (...args:any[]) => any | |
| comparator?: (hash:any, existingKey:any) => boolean | |
| wait?: number | |
| start?: (...args:any[]) => any | |
| queue?: (...args:any[]) => any | |
| beforeFinish?: (...args:any[]) => any | |
| success?: (result:any, ...args:any[]) => any | |
| fail?: (result:Error, ...args:any[]) => any | |
| finish?: (result:any, ...args:any[]) => any |
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
| type ArrayElement<ArrayType> = | |
| ArrayType extends (infer ElementType)[] ? ElementType : | |
| ArrayType extends ReadonlyArray<infer ElementType> ? ElementType : | |
| never; | |
| type Flatten<T> = T extends Array<infer U> ? U : T; |
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
| <template> | |
| <div class="loader" :class="{ 'loader--done': succeeded || errored }"> | |
| <template v-if="succeeded"> | |
| <slot name="success" :response="response"> | |
| <template v-if="showSuccessMessage"> | |
| <slot name="successIcon" :response="response"><i | |
| class="fa" | |
| :class="{ | |
| [successIconClass]: successIconClass, | |
| [`fa-${successIcon}`]: successIcon, |
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
| export const deepCloneVuexModule module => ({ | |
| ...module, | |
| state: JSON.parse(JSON.stringify(module.state)), | |
| modules: Object.entries(module.modules || {}) | |
| .map(([moduleName, module]) => [moduleName, deepCloneVuexModule(module)]) | |
| .reduce((acc, [moduleName, module]) => ({ ...acc, [moduleName]: module }), {}), | |
| }); |
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
| module.exports = (endpoint, query = {}) => { | |
| const queryEntries = Object.entries(query || {}).filter(([key, value]) => value || typeof value === 'boolean'); | |
| return queryEntries.length | |
| ? `${endpoint}?${queryEntries | |
| .map(pair => pair.map(encodeURIComponent).join('=')) | |
| .join('&')}` | |
| : endpoint; | |
| }; |
OlderNewer