Skip to content

Instantly share code, notes, and snippets.

@Atinux
Atinux / last-digit-ean13.js
Last active November 29, 2019 18:07
Get last digit of an EAN/GTIN 13 in JavaScript
function getLastEan13Digit(ean) {
if (!ean || ean.length !== 12) throw new Error('Invalid EAN 13, should have 12 digits')
const multiply = [1, 3]
let total = 0
ean.split('').forEach((letter, index) => {
total += parseInt(letter, 10) * multiply[index % 2]
})
@milon87
milon87 / login.js
Created August 24, 2017 09:27
x-www-form-urlencoded post in react native
getLoginAPI = () => {
let details = {
'username': 'username',
'password': 'demo'
};
let formBody = [];
for (let property in details) {
let encodedKey = encodeURIComponent(property);
@PurpleBooth
PurpleBooth / README-Template.md
Last active July 25, 2024 13:33
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites