This file contains 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
/** | |
* Calculates the employee national insurance contribution based on annual net salary. | |
* @param {number} annual net salary. | |
* @return The employee national insurance contribution based on annual net salary | |
* @customfunction | |
*/ | |
function EMPLOYEE_NATIONAL_INSURANCE(income) { | |
/** | |
* If you're an employee you start paying National Insurance when you earn more than £242 a week (2023/24). The National Insurance rate you pay depends on how much you earn, and is made up of: 12% of your weekly earnings between £242 and £967 (2023/24) 2% of your weekly earnings above £967. | |
*/ |
This file contains 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 checkWinner(codeList, shoppingCart) { | |
if (codeList.length === 0) return 1; | |
if (shoppingCart.length === 0) return 0; | |
function canMatch(group, fromIndex) { | |
// if cart has no enough items to match the group | |
if (fromIndex + group.length > shoppingCart.length) return false; | |
for (let groupItemIndex = 0; groupItemIndex < group.length; groupItemIndex++) { | |
// if items don't match, and we don't have a wildcard, then fail immediately |
This file contains 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
alias ghome="gwip && gpsup --no-verify" | |
alias gfire="ghome --force" |
This file contains 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
'camelCaseStyle' | |
.split(/([a-z][A-Z])/g) | |
.reduce((words, group, index) => (index % 2 ? `${words}${group[0]} ${group[1]}` : `${words}${group}`), '') |
This file contains 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
import React, { Component } from 'react'; | |
import PropTypes from 'prop-types'; | |
import classnames from 'classnames'; | |
import { withStyles } from 'material-ui/styles'; | |
import Grid from 'material-ui/Grid'; | |
import Loading from '~/Components/Loading'; | |
import styles from './styles'; | |
@withStyles(styles) | |
class Form extends Component { |
This file contains 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
/* | |
It's often we have a bunch of modules that we need to just forward | |
from a single entry point | |
as following: | |
-- src | |
---- utils | |
------ isFunction.js | |
------ isString.js | |
------ isArray.js |
This file contains 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
/* | |
In case you have tens of files with '2 spaces' indentation that you need to convert to '4 spaces' | |
1. Install 'recursive-readdir-sync', do not add the --save label. | |
2. cd to the root of the directory you want to process | |
3. Place this script. | |
3. Run the script, commit, push, enjoy! | |
*/ | |
let fs = require('fs'); | |
let recursiveReadSync = require('recursive-readdir-sync'); |
This file contains 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 asyncOperation() { | |
// returns promise | |
} | |
var promises = []; | |
for (var i=0; i<=10; i++) { | |
var promise = asyncOperation(); | |
promises.push(promise); | |
} |
This file contains 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 func5() {} // depends on the results of async4() and | |
function async4() {} // depends on the results of async3() and | |
function async3() {} // depends on async2() | |
function async2() {} // depends on async1() |
This file contains 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 uploadFile(data) { | |
// we can send notification one or more time as following: | |
defer.notify(percentageUploaded); | |
// returns promise | |
} | |
uploadFile() | |
.then(function() { | |
// fine |
NewerOlder