Dev Cheatsheet Mar 02, 2019 A collection of useful commands that I use frequently Git Managing profiles There is a neat way to manage multiple git profiles, mainly the email address. git config --global alias.work 'config user.email "roy@work"' git config --global alias.personal 'config user.email "roy@home"' Then within a project, run git work or git personal to set the local git profile. Bash Vim Spell Checking Enable spell checking with: :se spell Spelling corrections will be underlined, to fix a spelling error, move the cursor over it and press z=, then select the option from the list. ...
Hashbangs Mar 02, 2019 Making scripts executable in Linux is as easy as setting a line at the top of the script, below is a list of common ones: File Type Line Python #!/usr/bin/env python3 Node #!/usr/bin/env node Shell #!/usr/bin/env bash Once the hashbang is added to the top of the file, make the file executable by doing chmod +x your_file. ...
React Performance Mar 02, 2019 Below is a dot point list of performance tips for React, will be turned into a proper post when I have time… From the React Docs Virtualize long lists (a.k.a react-window) Avoid Reconciliation Highlight Updates in React Dev Tools Use PureComponent to prevent unnecessary updates (shallow prop and state comparison) Prevent parent components from unnecessarily updating child components Avoid mutating data Mutating data means that the UI rerenders (reconciliation) Use immutable data structures Immutable data structures makes tracking changes cheap, as we can do shallow comparison of objects Structural sharing? ...
Setting up CORS with Python Mar 02, 2019 What is CORS? CORS (Cross Origin Resource Sharing) allows access to resources from other domains, a good use case for this is a web app trying to fetch data from an API on another domain. CORS is only required when trying to fetch data from a browser, as browsers by default will block requests to different origins (domains). CORS uses HTTP headers to tell the browser if it has permission to fetch the resources. ...