View cookie-clicker.ino
View 1 - install chocolatey.cmd
@echo off
echo Administrative permissions required. Detecting permissions...
net session >nul 2>&1
if %errorLevel% == 0 (
echo Success: Administrative permissions confirmed.
) else (
echo Failure: Current permissions inadequate.
pause
exit 1
View mixin.js
// This mixin might be used to extend a class with or without its
// own "foo" method
const mixin = Base => class extends Base {
foo() {
// Only call super.foo() if it exists!
if (super.foo) {
super.foo();
}
console.log('mixin');
View index.js
// npm install && npm run build
// In output.js, spreadTest(...args) is converted to ES5
function spreadTest(...args) {
return args;
}
console.log(spreadTest(1, 2, 3));
// But the ...args inside of this lib's "audit" function is NOT converted to ES5
import 'react-axe';
View good-times.js
this.OnClickOutside = this.onClickOutside;
View objects-vs-tuples.js
// This function returns 2 separate values via an object with 2 properties.
function returnTwoValuesObj(str) {
const length = str.length;
const hasSpaces = str.indexOf(' ') !== -1;
return {length, hasSpaces};
}
// This function returns 2 separate values via an array (effectively a tuple) with 2 items.
function returnTwoValuesTuple(str) {
const length = str.length;
View query.sql
-- This is the result I want:
--
-- foo | bar | description
-- -----+-----+-------------
-- 3 | 4 | two
-- 1 | 2 | four
-- 5 | 6 | five
--
-- Which I can get with this query, but can I do it
-- more simply?
View promise-batch-arrays.js
import Promise from 'bluebird';
function getBatches(arr, length) {
let i = 0;
const result = [];
while (i < arr.length) {
result.push(arr.slice(i, i + length));
i += length;
}
return result;