This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See github repo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir testrepo && cd testrepo | |
git clone git@bitbucket.org:vielhuber/testrepo.git . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
if( $(window).width() < 1200 && $('.localhost').length > 0 ) { | |
var path_1 = $('head link[href*="style.css"]').attr('href'); | |
var path_2 = $('head link[href*="px2rem.css"]').attr('href'); | |
setInterval(function() { | |
$('head link[href*="style.css"]').attr('href',path_1+'?rand='+(~~(Math.random()*999)+100)); | |
$('head link[href*="px2rem.css"]').attr('href',path_2+'?rand='+(~~(Math.random()*999)+100)); | |
}, 5000); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// variant 2 | |
var markers = []; // array with markers inside | |
var bounds = new google.maps.LatLngBounds(); | |
for (var i = 0; i < markers.length; i++) { | |
bounds.extend(markers[i].getPosition()); | |
} | |
map.fitBounds(bounds); | |
// min/max zoom | |
if(map.getZoom() > 15) { map.setZoom(15); } | |
if(map.getZoom() < 3) { map.setZoom(3); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var debug = ["var1", "var2", "var3"]; | |
window.setInterval(function() { | |
$('#debug').remove(); | |
$('body').append('<div id="debug" style="position:fixed;top:0;left:0;"></div>'); | |
for(var item of debug) { | |
$('#debug').append(item+": "+eval(item)+"<br/>"); | |
} | |
},1000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// When a function returns another function, the returning function holds its environment (in a closure) | |
// example #1 | |
// here the function "inner" uses the variable var1 from outside its scope in its closure | |
var outer = function(var1) { | |
var inner = function(var2) { | |
return var1 + var2; | |
} | |
return inner; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// js has auto semicolon insertion | |
BEFORE | |
var x = 1 | |
var y = 2 | |
AFTER | |
var x = 1; | |
var y = 2; | |
BEFORE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// every object has a property called "prototype" where you can add methods and/or other properties to it | |
// when you create other objects from this object the newly created object will inherit those properties | |
// without cloning but with referencing | |
/* newer way */ | |
const cat = { | |
makeSound: function() { | |
console.log(this.sound); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<a href="file.pdf" class="print">Print file!</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
(function ($) { | |
window.customFunction() = function() { | |
alert('FOO'); | |
} | |
})(jQuery); |
OlderNewer