// Node.js | |
const fs = require('fs'); | |
const sum = (a, b) => { | |
return Number(a) + Number(b); | |
}; | |
const fileContent = fs.readFileSync("input.txt", "utf8"); | |
const [a, b] = fileContent.toString().split(' '); | |
const result = sum(a, b); |
// Node.js | |
const sum = (a, b) => { | |
return Number(a) + Number(b); | |
}; | |
process.stdin.on('data', (data) => { | |
const [a, b] = data.toString().split(' '); | |
const result = sum(a, b); | |
process.stdout.write(result.toString()); | |
process.exit(0); |
When first confronted with node.js, you are not only presented with a completely new programming environment. You also encounter what is often referred to as callback hell accompanied by weird unfamiliar programming patterns. One of these is the way node treats callback functions.
The following post explains the conventions that node.js uses for its callback patterns (referred to as Continuation-passing style) and how you should implement them in order to comply.
Node expects - almost - all callback functions to accept an Error object as the first argument. If no error occurred, the first argument should be null. If you use inline anonymous functions, this is a typical code snippet that you will encounter using node:
// include the filesystem module
var fs = require('fs');
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
html, body, div, form, fieldset, legend, label { margin: 0; padding: 0; } | |
table { border-collapse: collapse; border-spacing: 0; } | |
th, td { text-align: left; vertical-align: top; } | |
h1, h2, h3, h4, h5, h6, th, td, caption { font-weight:normal; } | |
img { border: 0; } |
// Node.js | |
const readline = require('readline'); | |
const rl = readline.createInterface({ | |
input: process.stdin, | |
output: process.stdout, | |
}); | |
rl.on('line', (input) => { | |
if (input === 'ping') { |
These sites provide infrastructure for the organization, finding, and downloading of varying datasets.
- Papers with Code: https://paperswithcode.com/datasets
- UCI Machine Learning Repository: https://archive.ics.uci.edu/ml/datasets.php
- Kaggle: https://www.kaggle.com/datasets
- Hugging Face: https://huggingface.co/datasets
- Google dataset search https://datasetsearch.research.google.com/
#!/bin/sh | |
# Husky hook to prepend commit message with a branch prefix, examples: | |
# 1. AB-12345_feature -> AB-12345 Add feature | |
# 2. chore_misc -> Chore Misc | |
# 3. fix_bug -> Fix Bug | |
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD) | |
# Exit if the commit is a merge commit or we're in a detached head state or |