Skip to content

Instantly share code, notes, and snippets.

View ptiswitz's full-sized avatar
🐻

Julien Léger ptiswitz

🐻
  • Nurun
  • Montreal
View GitHub Profile
@spyesx
spyesx / positive_negative.js
Last active October 26, 2022 14:29
Several methods to get a random positive or negative number
// Math.random() will give you a random decimal number between 0 and 1
// Just check if the number is greater than 0.5
// And apply -1 or 1 depending on the result
Math.random() < 0.5 ? -1 : 1;
// Math.random() will give you a random decimal number between 0 and 1
// Math.rand() of a Math.random() will give you an integer 0 or 1
// Use 0 or 1 as a result of a condition to use -1 or 1
Math.round(Math.random()) ? -1 : 1;
// /!\ NOTE : Can be used for any other values like 9 or 37 ; -2 or 2...
@langhard
langhard / form-fields.js
Last active December 21, 2015 08:19
AngularJS (1.1.5) - Directives - Dynamic Template URL
'use strict';
angular.module('clientApp')
.directive('formFields', function () {
return {
templateUrl: function (tElement, tAttrs) {
return tAttrs.templateUrl;
},
restrict: 'E'
};