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 = { | |
// ... | |
optimization: { | |
minimizer: [ | |
new SwcJsMinimizerRspackPlugin({ | |
compress: { | |
// prevents it from combining a bunch of statements with ","s so it is easier to set breakpoints | |
sequences: false, | |
// these are all things that terser does by default but we turn |
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
// Which of the 3 of these options is more readable / is easier to understand? | |
// OPTION 1: .forEach with .push | |
const subqueries = [] | |
Object.entries(SPECIAL_SUBQUERY_FIELDS).forEach(([field, subquery]) => { | |
if (fieldRequested(field, info)) | |
subqueries.push(`(${subquery} LIMIT 1) AS ${field}`) | |
}) | |
// OPTION 2: .map with .filter |
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 PickByValue<T, V> = Pick< | |
T, | |
{ [K in keyof T]: T[K] extends V ? K : never }[keyof T] | |
> | |
type Entries<T> = { | |
[K in keyof T]: [keyof PickByValue<T, T[K]>, T[K]] | |
}[keyof T][] | |
/** | |
* A better Object.entries _BUT ONLY FOR OBJECTS YOU KNOW DON'T HAVE EXTRA PROPERTIES_, |
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
blueprint: | |
name: Lamp Follows Swicth | |
description: Turn on or aff a lamp every time a switch state changes | |
domain: switch | |
input: | |
master_switch: | |
name: the Master Switch | |
description: This sensor will be synchronized with the light. | |
selector: | |
entity: |
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
function sum(...nums) { | |
return nums.reduce((a, b) => a + b, 0) | |
} | |
function largestSum(array) { | |
let largestSumSoFar | |
for (let i = 0; i < array.length; i++) { | |
for (let j = i; j < array.length; j++) { | |
let subArray = array.slice(i, j + 1) | |
let test = sum(...subArray) |
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
!(function(t) { | |
var e = {}; | |
function n(r) { | |
if (e[r]) return e[r].exports; | |
var o = (e[r] = { i: r, l: !1, exports: {} }); | |
return t[r].call(o.exports, o, o.exports, n), (o.l = !0), o.exports; | |
} | |
(n.m = t), | |
(n.c = e), | |
(n.d = function(t, e, r) { |
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
var styles = { | |
componentId: 'bavIU', | |
template: function template(theme) { | |
return "/* imported from styles.css */\n\n.bavIU_922a,a.bavIU_922a,button.bavIU_922a,button.bavIU_922a[type=button],button.bavIU_922a[type=reset],button.bavIU_922a[type=submit]{-moz-appearance:none;-moz-user-select:none;-ms-user-select:none;-webkit-appearance:none;-webkit-user-select:none;appearance:none;background:none;border-style:".concat(theme.borderStyle || 'none', ";border-width:").concat(theme.borderWidth || 'none', ";box-sizing:border-box;direction:inherit;display:inline-block;font-family:").concat(theme.fontFamily || 'none', ";font-weight:").concat(theme.fontWeight || 'none', ";height:auto;letter-spacing:").concat(theme.letterSpacing || 'none', ";margin:0;max-width:100%;overflow:visible;padding:0;position:relative;text-decoration:none;text-transform:").concat(theme.textTransform || 'none', ";touch-action:manipulation;transform:").concat(theme.transform || 'none', ";transition:background 0.2s,transform 0.2s;user-select:n |
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
// bad: manual binding in constructor | |
class Foo extends React.Component { | |
// this is a lot of boilerplate that does not really give us any insight into | |
// what we are intending to do with our code | |
constructor(props) { | |
super(props) | |
this.updateCounter = this.updateCounter.bind(this) | |
this.state = { | |
counter:0 |
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
function initCustomTinyMCEStuff (tinyMCE) { | |
console.log('here is where you would run your callback that does custom tinyMCE stuff. in the case of your minified code, it is the function called "r"', tinyMCE) | |
} | |
//this will keep checking for the rceModule to be ready and call your | |
// callback that does all of your customizations once it is. | |
var waitForRCSServiceToBeReadyPollInterval = setInterval(function(){ | |
if (typeof RceModule === 'undefined') return | |
initCustomTinyMCEStuff(tinyRCE) | |
clearTimeout(waitForRCSServiceToBeReadyPollInterval); |
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
// if someone requires 'timezone', I want it to get this file | |
// and then based on some info in a global variable 'window.ENV' | |
// at runtime fetch a json file with a bunch of data specific to | |
// that timezone and then export the 'timezone' object, with | |
// that zone's data preloaded. in requireJS, I had a loader that | |
// looked something like this | |
// in timezone.js | |
define(['timezone_core'], function(timezone) { | |
//see: http://requirejs.org/docs/plugins.html#apiload for the specifics of how this api works |
NewerOlder