Skip to content

Instantly share code, notes, and snippets.

View arthurvasconcelos's full-sized avatar
🖖
Live long and prosper.

Arthur Vasconcelos arthurvasconcelos

🖖
Live long and prosper.
View GitHub Profile
@deadkff01
deadkff01 / divideWithLogarithms.js
Last active April 18, 2018 18:50
JavaScript divide function without using "/"
// Multiplication and division rules... ((+)*(+)=+) ((-)*(-)=+) ((+)*(-)=-) ((-)*(+)=-)
const multiply = (x, y) => {
let r = Math.exp(Math.log(Math.abs(x)) + Math.log(Math.abs(y))).toFixed(2)
return Number((x < 0 && y < 0) ? r : (x < 0 || y < 0) ? -r : r)
}
const divide = (x, y) => {
return (x === 0) ? 0 : multiply(((multiply(x, y) < 0) ? -1.0 : 1.0), Math.exp(Math.log(Math.abs(x)) - Math.log(Math.abs(y))))
}
@odedw
odedw / .eslintrc.yaml
Last active March 8, 2022 05:27 — forked from cletusw/.eslintrc
ESLint Reset - A starter .eslintrc file that resets all rules to off and includes a description of what each rule does. From here, enable the rules that you care about by changing the 0 to a 1 or 2. 1 means warning (will not affect exit code) and 2 means error (will affect exit code).
# http:#eslint.org/docs/rules/
ecmaFeatures:
binaryLiterals: false # enable binary literals
blockBindings: false # enable let and const (aka block bindings)
defaultParams: false # enable default function parameters
forOf: false # enable for-of loops
generators: false # enable generators
objectLiteralComputedProperties: false # enable computed object literal property names
objectLiteralDuplicateProperties: false # enable duplicate object literal properties in strict mode
objectLiteralShorthandMethods: false # enable object literal shorthand methods
@ghostwords
ghostwords / .eslintrc
Last active February 13, 2024 07:35 — forked from cletusw/.eslintrc
{
// http://eslint.org/docs/rules/
"ecmaFeatures": {
"arrowFunctions": false, // enable arrow functions
"binaryLiterals": false, // enable binary literals
"blockBindings": false, // enable let and const (aka block bindings)
"classes": false, // enable classes
"defaultParams": false, // enable default function parameters
"destructuring": false, // enable destructuring
@cletusw
cletusw / .eslintrc
Last active February 29, 2024 20:24
ESLint Reset - A starter .eslintrc file that resets all rules to off and includes a description of what each rule does. From here, enable the rules that you care about by changing the 0 to a 1 or 2. 1 means warning (will not affect exit code) and 2 means error (will affect exit code).
{
// http://eslint.org/docs/rules/
"ecmaFeatures": {
"binaryLiterals": false, // enable binary literals
"blockBindings": false, // enable let and const (aka block bindings)
"defaultParams": false, // enable default function parameters
"forOf": false, // enable for-of loops
"generators": false, // enable generators
"objectLiteralComputedProperties": false, // enable computed object literal property names
@mathewbyrne
mathewbyrne / slugify.js
Created October 12, 2011 04:34
Javascript Slugify
function slugify(text)
{
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}