Dynamically load google fonts after page has loaded

Check out the WebFont.load command in this github repo: https://github.com/typekit/webfontloader You can load whatever font you want dynamically: <script src=”http://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js”></script> <script> WebFont.load({ google: { families: [‘Droid Sans’, ‘Droid Serif’] } }); </script>

string concatenation with property binding in angular2

I found out that you can use this kind of syntax using square brackets: <li *ngFor=”#course of courses; #i = index” [id]=”‘someselector-‘+i”>{{course}}</li> For more information, please have a look to this interesting article from Pascal Precht: http://blog.thoughtram.io/angular/2015/08/11/angular-2-template-syntax-demystified-part-1.html

React useEffect is not triggering on route change

The useEffect is not triggered because the App component is not re-rendered, nothing changed in that component (no state or props update). If you want the App component to re-render when the route change, you can use the withRouter HOC to inject route props, like this : import { Switch, Route, withRouter } from ‘react-router-dom’; … Read more

Javascript addEventListener – using to create a mouseover effect?

You will need to setup a similar event to handle mouseout. Inside the mouseout event function, you can change the color back to the original color. var item = document.getElementById(“button”); item.addEventListener(“mouseover”, func, false); item.addEventListener(“mouseout”, func1, false); function func() { // not needed since item is already global, // I am assuming this is here just … Read more

Saving a Uint8Array to a binary file

These are utilities that I use to download files cross-browser. The nifty thing about this is that you can actually set the download property of a link to the name you want your filename to be. FYI the mimeType for binary is application/octet-stream var downloadBlob, downloadURL; downloadBlob = function(data, fileName, mimeType) { var blob, url; … Read more

How do you run eslint for only a specific rule or set of rules – command line only

I don’t know if this is the best way, but I was able to get this working: $ eslint helpme.js –no-eslintrc –env “es6” –env “node” –parser-options “{ecmaVersion: 2018}” –rule “{some-important-rule: error}” Note: With this method (ignoring .eslintrc completeley) you still have to add some stuff from .eslintrc like your environment and parser options.

Exporting Objects with the Exports Object

This is the way I create modules: myModule.js var MyObject = function() { // This is private because it is not being return var _privateFunction = function(param1, param2) { … return; } var function1 = function(param1, callback) { … callback(err, results); } var function2 = function(param1, param2, callback) { … callback(err, results); } return { … Read more