eg. 02 6555 1234
0 - trunk prefix
2 - Area code for New South Wales
6555 - STD code for a specific telephone exchange
1234 - Telephone Exchange specific extension.
| // From here: | |
| // https://stackoverflow.com/questions/1420881/how-to-extract-base-url-from-a-string-in-javascript/26708573#26708573 | |
| const parseUrl = (string, prop) => { | |
| const a = document.createElement('a'); | |
| a.setAttribute('href', string); | |
| const {host, hostname, pathname, port, protocol, search, hash} = a; | |
| const origin = `${protocol}//${hostname}${port.length ? `:${port}`:''}`; | |
| return prop ? eval(prop) : {origin, host, hostname, pathname, port, protocol, search, hash} | |
| } |
| /* | |
| Timer | |
| - utilises animation frames (with a fallback to setTimeout when using the polyfill, below) | |
| - returns remaining (or running) time | |
| - pass a callback [fn], with an optional duration [ms] and autotart [bool], to the constructor or 'init' method | |
| eg. new Timer(foo, 1000) *or* (new Timer()).init(foo, 0, true) | |
| - for uniform x-browser support combine with the requestAnimationFrame polyfill from Erik Möller, et. al. | |
| [https://github.com/darius/requestAnimationFrame] | |
| */ |
| // My preferred method | |
| let obj = {"one" : 1, "two" : 2, "three": 3 } | |
| for (let k of Object.keys(obj)) { | |
| console.log(k, obj[k]) | |
| } |
| cd /path/to/directory/ | |
| /System/Library/Automator/Combine\ PDF\ Pages.action/Contents/Resources/join.py --output collated.pdf *.pdf |
Flow charts (Also coming soon is Wireframes and Stickies)
| Name Character Entity | |
| Copyright © © | |
| Registered ® ® | |
| Trademark ™ ™ | |
| Curly Open Double Quote “ “ | |
| Curly Closed Double Quote ” ” | |
| Curly Open Single Quote ‘ ‘ | |
| Curly Closed Single Quote ’ ’ | |
| Big Bullet/Dot • • |
| // LOOP ARRAY KEYS and INDEXES | |
| let myArray = ['fruit', 'fish', 'seahorses', 'mudslides']; | |
| for (let [index, value] of myArray.entries()) { | |
| console.log(index, value); | |
| } | |
| /* | |
| 0 "fruit" | |
| 1 "fish" |
| const truncate = function(fullStr, strLen, separator) { | |
| if (fullStr.length <= strLen) return fullStr; | |
| separator = separator || '…'; | |
| const sepLen = separator.length; | |
| const charsToShow = strLen - sepLen; | |
| const frontChars = Math.ceil(charsToShow/2); | |
| const backChars = Math.floor(charsToShow/2); |