#1: You're responsible for code quality.
#2: Use meaningful names.
#3: Write code that expresses intent.
#4: Code should speak for itself. Less comments = less maintenance.
#5: Leave the code better than you found it.
| #!/bin/bash | |
| STARTFOLDER="./" | |
| MARKER="converted" | |
| echo -n "Finding candidate files .." | |
| FILELIST=$(find "$STARTFOLDER" -type f -name '*.mp4') | |
| echo ".. "$(echo -e "$FILELIST" | wc -l)" found" | |
| while read FILEPATH; do |
| var root = document.querySelector(':root'); | |
| var rootStyles = getComputedStyle(root); | |
| var red = rootStyles.getPropertyValue('--red'); | |
| console.log('red: ', red); | |
| root.style.setProperty('--red', 'green') |
| getCursorPosition(editableDiv) { | |
| editableDiv = editableDiv || this.element; | |
| let caretOffset = 0; | |
| if (window.getSelection) { | |
| const range = window.getSelection().getRangeAt(0); | |
| const preCaretRange = range.cloneRange(); | |
| preCaretRange.selectNodeContents(editableDiv); | |
| preCaretRange.setEnd(range.endContainer, range.endOffset); | |
| caretOffset = preCaretRange.toString().length; |
| /** | |
| * This is ported from Rangy's selection save and restore module and has no dependencies. | |
| * Copyright 2019, Tim Down | |
| * Licensed under the MIT license. | |
| * | |
| * Documentation: https://github.com/timdown/rangy/wiki/Selection-Save-Restore-Module | |
| * Use "rangeSelectionSaveRestore" instead of "rangy" | |
| */ | |
| var rangeSelectionSaveRestore = (function() { | |
| var markerTextChar = "\ufeff"; |
| // time and time end | |
| console.time("This"); | |
| let total = 0; | |
| for (let j = 0; j < 10000; j++) { | |
| total += j | |
| } | |
| console.log("Result", total); | |
| console.timeEnd("This"); | |
| // Memory |
| // Some elements will cause a horizontal scroll bar to appear, due to the width of those elements | |
| [].forEach.call($$("*"), function(a) { | |
| a.style.outline = | |
| "1px solid #" + (~~(Math.random() * (1 << 24))).toString(16); | |
| }); | |
| // https://gist.github.com/addyosmani/fd3999ea7fce242756b1 |
| function getWatchers(root) { | |
| root = angular.element(root || document.documentElement); | |
| var watcherCount = 0; | |
| function getElemWatchers(element) { | |
| var isolateWatchers = getWatchersFromScope(element.data().$isolateScope); | |
| var scopeWatchers = getWatchersFromScope(element.data().$scope); | |
| var watchers = scopeWatchers.concat(isolateWatchers); | |
| angular.forEach(element.children(), function (childElement) { | |
| watchers = watchers.concat(getElemWatchers(angular.element(childElement))); |
| async function loadFonts(fontName) { | |
| let fontName = fontName || 'myfont'; | |
| const font = new FontFace(fontName, `url(${fontName}.woff)`); | |
| await font.load(); | |
| document.fonts.add(font); | |
| document.body.classList.add('fonts-loaded'); | |
| } |
| import { Directive, ElementRef, OnInit, Output, EventEmitter } from '@angular/core'; | |
| declare var google:any; | |
| @Directive({ | |
| selector: '[google-place]' | |
| }) | |
| export class GooglePlacesDirective implements OnInit { | |
| @Output() onSelect: EventEmitter<any> = new EventEmitter(); | |
| private element: HTMLInputElement; |
#1: You're responsible for code quality.
#2: Use meaningful names.
#3: Write code that expresses intent.
#4: Code should speak for itself. Less comments = less maintenance.
#5: Leave the code better than you found it.