Skip to content

Instantly share code, notes, and snippets.

View VoloshchenkoAl's full-sized avatar
🇺🇦

Alex VoloshchenkoAl

🇺🇦
View GitHub Profile
function max(a,b,c){
var maxValue = Number.NEGATIVE_INFINITY;
for(var i = 0; i<arguments.length; i++)
if(maxValue < arguments[i])
maxValue = arguments[i];
return maxValue;
};
var scroll = function( srollFromEl, srollToEl ){
srollFromEl.click(function( e ){
e.preventDefault();
$('html, body').stop().animate({
'scrollTop': srollToEl.offset().top
}, 900, 'swing');
});
function isNumeric(n) {
return !isNaN(parseFloat(n)) && isFinite(n);
};
function buildString(){
var args = Array.prototype.slice.call(arguments).join('');
return args;
}
$browser-context: 18px;
@function em($pixels, $context: $browser-context) {
@return ($pixels / $context) * 1em;
}
var arr = [[3,1,1,1],
[1,1,1,1],
[1,1,1,1],
[1,1,1,1]];
var sum = arr.reduce(function(prev,cur,i){
return prev+cur[i]+cur[arr.length-1-i];
},0);
function isInteger(num) {
return (num ^ 0) === num;
}
<?php
if(isset($_POST) && is_array($_POST) && count($_POST) > 0){
$ajaxResp = [];
if(isset($_POST['email']) && filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)){
$ajaxResp['status'] = 1;
$ajaxResp['email'] = $_POST['email'];
echo json_encode($ajaxResp);
} else {
$ajaxResp['status'] = 0;
function Animal(voice){
this.voice = voice || 'grunt';
}
Animal.prototype.speak = function(){
console.log(this.voice);
}
function Cat(name, color){
Animal.call(this, 'Meow');
this.name = name;
function getCurrentPositionUsGeoAndIp(){
var D = $.Deferred();
try{
//using navigator geolocation
if( navigator.geolocation ){
navigator.geolocation.getCurrentPosition( foundCordsUseGeoSuccess, foundCordsUseGeoFail );