Skip to content

Instantly share code, notes, and snippets.

@neilbo
neilbo / medicare_card.js
Created April 17, 2023 20:55 — forked from Ugrend/medicare_card.js
Random Medicare Card Generator
//Reference: http://www.clearwater.com.au/code/provider
const randomMedicareNumber = ()=>{
let sum = Math.floor(Math.random() * 5) +2;
const weights = [1, 3, 7, 9, 1, 3, 7, 9];
let num = [sum]
for(let i = 0 ; i < 7 ; i++){
let n = Math.floor(Math.random()*10)
sum += n * weights[i+1];
/**
* Custom submit directive that will only submit when all the validation has passed
* for all the fields. This extends on the ng-submit directive provided by AngularJS.
*
* This directive will also remove the 'pristine' flag from all the fields when
* hitting submit, allowing the form to display no errors until the submit button
* is clicked/enter is pressed.
*
* The variable 'app' is the instance of a module.
* E.g. var app = angular.module('my-app', []);
@neilbo
neilbo / ngEnter.js
Last active August 29, 2015 14:06 — forked from EpokK/ngEnter.js
app.directive('ngEnter', function() {
return function(scope, element, attrs) {
element.bind("keydown keypress", function(event) {
if(event.which === 13) {
scope.$apply(function(){
scope.$eval(attrs.ngEnter);
});
event.preventDefault();
}