Skip to content

Instantly share code, notes, and snippets.

View adatg's full-sized avatar

Ada Gilad adatg

View GitHub Profile
@adatg
adatg / flex.less
Created August 1, 2019 16:04 — forked from codler/flex.less
Prefix flex for IE10 and Safari / iOS in LESS
/*! Prefix flex for IE10 and Safari / iOS in LESS
* https://gist.github.com/codler/2148ba4ff096a19f08ea
* Copyright (c) 2014 Han Lin Yap http://yap.nu; MIT license */
.display(@value) when (@value = flex) {
display: -ms-flexbox; // IE10
display: -webkit-flex; // Safari / iOS
}
.display(@value) when (@value = inline-flex) {
@adatg
adatg / select-change.html
Created July 9, 2019 14:54 — forked from willhalling/select-change.html
Simple jQuery function to change class of labels when radio buttons are selected.
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<title>Select/Change option</title>
<style type="text/css">
.red {color: red;}
.black {color: black;}
@adatg
adatg / replacerepeatedelement
Last active November 5, 2018 20:37
Remove repeated elements and return a string
//set -> accepts a string or an array of letters and numbers
function removeRepeated(el) {
return Array.from(new Set(el)).join('');
}
//for loop -> accepts a string or an array of letters and numbers
function removeRepeated(el){
let arr = []
for(let i = 0;i < el.length; i++){
if(arr.indexOf(el[i]) == -1){
@adatg
adatg / reversenumber
Created November 1, 2018 14:52
Reverse a number and convert it to an array of digits
function reverseNum(n) {
var result = [];
var reversed = n.toString().split('').reverse().join('');
for (var i = 0; i < reversed.length; i++) {
result.push(+reversed.charAt(i));
}
return result;
}
@adatg
adatg / calculatefactorial
Created October 29, 2018 18:27
Calculate Factorial
function factorial(x) {
if (x === 0) {
return 1; }
return x * factorial(x-1);
}
@adatg
adatg / calculatefactorial
Created October 29, 2018 18:25
Calculate factorial
function factorial(num) {
var result= 1;
for (var i = 2; i <= num; i++) {
result *= i;
}
return result;
}
@adatg
adatg / emptyinput
Last active October 29, 2018 18:29
Empty input
function test(value) {
//test for an empty or null input and return null
if(value === null || !value.length) {
return null;
}
}
@adatg
adatg / comparearrays
Last active October 29, 2018 17:42
Compare two arrays and return unique values
var removeVowels = function(str){
var vowels = [ "a", "e", "i", "o", "u"];
var newStr = [];
for (var i in str) {
if(!vowels.includes(str[i])) newStr.push(str[i]);
}
return newStr;
}
@adatg
adatg / comparearrays
Last active October 29, 2018 18:02
Compare two arrays and return common values
var compareVowels = function(str){
var vowels = [ "a", "e", "i", "o", "u"];
var newStr = [];
for(var i = 0;i<str.length;i++){
for(var j = 0; j<vowels.length;j++) {
if(str[i] === vowels[j]) {
newStr.push(str[i]);
}