Install, build and debug a react native app in WSL2 (Windows Subsystem for Linux) and Ubuntu.
If you're here just for the section on vscode working with Python on WSL, jump here.
Windows is now a development environment that can compete with Mac and Linux. Windows Subsystems for Linux lets you have an Ubuntu (or other Linux flavor) installation that works near seemlessly inside of Windows. Hyper Terminal running WSL's Bash and Visual Studio Code feel really nice to code in. These are instructions for getting set up and smoothing out most of the remaining rough edges. I've included a section on getting vscode to work well with Python and WSL, but the general pattern should be usable for any unsupported language (as of now, I believe it's only Node.js that has WSL support in vscode).
# http://scikit-learn.org/stable/modules/generated/sklearn.metrics.pairwise.cosine_similarity.html | |
import numpy as np | |
from sklearn.metrics.pairwise import cosine_similarity | |
# The usual creation of arrays produces wrong format (as cosine_similarity works on matrices) | |
x = np.array([2,3,1,0]) | |
y = np.array([2,3,0,0]) | |
# Need to reshape these | |
x = x.reshape(1,-1) |
import config from '../config' | |
let components = {} | |
//For each component in the config fiel into an object | |
for (var i = config.length - 1; i >= 0; i--) { | |
components[config[i].name] = require(config[i].path).default | |
} | |
export default components |
/* HOC fundamentally is just a function that accepts a Component and returns a Component: | |
(component) => {return componentOnSteroids; } or just component => componentOnSteroids; | |
Let's assume we want to wrap our components in another component that is used for debugging purposes, | |
it just wraps them in a DIV with "debug class on it". | |
Below ComponentToDebug is a React component. | |
*/ | |
//HOC using Class | |
//it's a function that accepts ComponentToDebug and implicitly returns a Class | |
let DebugComponent = ComponentToDebug => class extends Component { |
All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.
Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.
elem.offsetLeft
,elem.offsetTop
,elem.offsetWidth
,elem.offsetHeight
,elem.offsetParent
/** | |
* AuthController | |
* | |
* @description :: Server-side logic for managing auths | |
* @help :: See http://links.sailsjs.org/docs/controllers | |
*/ | |
module.exports = { | |
index: function (req, res) { | |
var email = req.param('email'); |