😀 :grinning:
😃 :smiley:
😄 :smile:
😁 :grin:
😆 :laughing:
| var noble = require('noble'); | |
| noble.on('stateChange', function (state) { | |
| console.log('state:', state); | |
| if (state === 'poweredOn') { | |
| console.log('scanning...'); | |
| noble.startScanning(); | |
| } else { | |
| noble.stopScanning(); |
| var MIN = 1; | |
| var MAX = 3999; | |
| var CHARS = 'IVXLCDM '; | |
| function toRomanNumeral (input) { | |
| if (input > MAX || input < MIN) { | |
| throw new Error('Cannot convert number'); | |
| } | |
| var offset = CHARS.length - 3; |
| function dec2hex (dec) { | |
| hex = dec.toString(16); | |
| if (hex.length < 2) { | |
| hex = "0" + hex; | |
| } | |
| return hex; | |
| } | |
| function toLittleEndian (number, dontPad) { | |
| var power = Math.floor((Math.log(number) / Math.LN2) / 8) * 8; |
| # Super simple templating engine | |
| tmpl = (template, namespace) -> | |
| fn = (existing, fieldName) -> | |
| content = namespace[fieldName] | |
| content ?= existing | |
| return content | |
| template.replace(/\{\{([a-z0-9_]*)\}\}/ig, fn) | |
| find . -iname '*.js' -not -path "*/__tests__/*" -exec wc -l {} \; | ag -o \\d+ | paste -sd+ - | bc |
| var successPromise = new Promise(function (resolve, reject) { | |
| setTimeout(resolve, 1000); | |
| }); | |
| successPromise.then(function () { console.log('this should succeed') }); | |
| var failingPromise = new Promise(function (resolve, reject) { | |
| setTimeout(reject, 1000); | |
| }); |
| snap | audience | |
|---|---|---|
| 0 | 100 | |
| 1 | 95 | |
| 2 | 82 | |
| 3 | 78 | |
| 4 | 61 | |
| 5 | 59 | |
| 6 | 42 | |
| 7 | 30 | |
| 8 | 29 |
😀 :grinning:
😃 :smiley:
😄 :smile:
😁 :grin:
😆 :laughing:
| function! Dab() | |
| let [line_start, column_start] = getpos("'<")[1:2] | |
| let [line_end, column_end] = getpos("'>")[1:2] | |
| if line_end - line_start > 0 | |
| " collapse | |
| normal va{J | |
| else | |
| " expand | |
| normal va{ | |
| s/[{,]/\0 |
| interface BinaryTreeNodeJSON<Value> { | |
| value: Value, | |
| left?: BinaryTreeNodeJSON<Value>, | |
| right?: BinaryTreeNodeJSON<Value>, | |
| } | |
| class BinaryTreeNode<Value> { | |
| static from<Value> (json: BinaryTreeNodeJSON<Value>): BinaryTreeNode<Value> { | |
| const { value, left, right } = json | |
| const leftNode = left != null ? BinaryTreeNode.from(left) : undefined |