Skip to content

Instantly share code, notes, and snippets.

@Xaz16
Xaz16 / cloudSettings
Last active July 30, 2020 12:37
Sync gist
{"lastUpload":"2020-07-30T12:37:18.930Z","extensionVersion":"v3.4.3"}
@Xaz16
Xaz16 / checkIsogram.js
Created March 15, 2018 21:39
An isogram is a word that has no repeating letters, consecutive or non-consecutive.
function isIsogram(str){
return !/(\w).*\1/i.test(str)
}
@Xaz16
Xaz16 / Retina mixins with banner width
Created November 29, 2017 13:33
Retina mixins with banner width
@mixin bg2x($path, $ext) {
background-image: url($path + '.' + $ext);
@media(-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
background-image: url($path + '@2x.' + $ext);
}
}
@mixin retinaBg($urlimage, $ext) {
background-position: center;
@Xaz16
Xaz16 / app.js
Last active November 13, 2019 15:57
Check useragent or platform of client navigator and apply it on body
var platform = {
ipad: /iPad/.test(navigator.userAgent) && !window.MSStream,
ios: /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream,
safari: navigator.userAgent.indexOf('Safari') !== -1 && navigator.userAgent.indexOf('Chrome') === -1 && !window.MSStream,
mac: navigator.platform.toLowerCase().indexOf('mac') >= 0 && !window.MSStream,
android: /(android)/i.test(navigator.userAgent) || navigator.platform.toLowerCase().indexOf("android") > -1 && !window.MSStream,
firefox: navigator.userAgent.toLowerCase().indexOf('firefox') > -1 && !window.MSStream,
windows: navigator.platform.indexOf('Win') > -1 && !window.MSStream,
ie: !!window.MSInputMethodContext && !!document.documentMode && !window.MSStream
};
@Xaz16
Xaz16 / gist:289ed1a9c76510c56ef137133e51aefe
Last active June 2, 2017 23:07
Return biggest sum of element in subarray
function largestOfFour(arr) {
var summs = [];
var index = 0;
for(var i = 0; i < arr.length; i++) {
summs.push(arr[i].reduce(function(prev, current, index) {
return prev + current;
}));
}
for(var j = 0; j < summs.length; j++) {
index = j !== 0 ? summs[j] > summs[j-1] ? j : summs[0] : summs[j];
@Xaz16
Xaz16 / randomInRange.js
Last active March 15, 2018 21:42
Random in range
Math.floor(Math.random() * (max - min + 1)) + min
@Xaz16
Xaz16 / script.js
Created November 23, 2016 14:54
Show/hide pass from input
$('.show-pass').on('click', function() {
($(this).siblings('input').attr('type') == 'text') ?
$(this).siblings('input[type="text"]').attr('type', 'password') :
$(this).siblings('input[type="password"]').attr('type', 'text');
});