Skip to content

Instantly share code, notes, and snippets.

View crazyyy's full-sized avatar

Vitalii Antoniuk crazyyy

View GitHub Profile
@crazyyy
crazyyy / scroll-to-element.js
Last active January 5, 2019 17:58
#js #jquery || slow scroll to top / to element
$("a[href*='#']:not([href='#'])").click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
}
@crazyyy
crazyyy / load external content into block.js
Last active January 5, 2019 18:29
#js #jquery || load external content into block
$("#content").load("somefile.html", function(response, status, xhr) {
// error handling
if (status == "error") {
$("#content").html("An error occured: " + xhr.status + " " + xhr.statusText);
}
});
@crazyyy
crazyyy / _readme.md
Last active June 26, 2021 20:33
#git || favorite scripts

GIT

Clean big files

Removes large or troublesome blobs like git-filter-branch does, but faster. And written in Scala

cd git-repo
# https://rtyley.github.io/bfg-repo-cleaner/
wget https://repo1.maven.org/maven2/com/madgag/bfg/1.14.0/bfg-1.14.0.jar
java -jar bfg-1.14.0.jar --strip-blobs-bigger-than 50M
@crazyyy
crazyyy / resize.js
Last active January 5, 2019 18:27
#js #jquery || get browser width and height on window resize
// get browser width and height on window resize
var headerEl = document.getElementById('header');
// when window size changed - resize first block
window.addEventListener('resize', setWindowSize);
function setWindowSize() {
if (typeof(window.innerWidth) == 'number') {
myWidth = window.innerWidth;
myHeight = window.innerHeight;
setheight(myHeight);
@crazyyy
crazyyy / asolute.url.js
Last active January 5, 2019 18:26
#js || get an absolute URL
var getAbsoluteUrl = (function() {
var a;
return function(url) {
if (!a) a = document.createElement('a');
a.href = url;
return a.href;
};
})();
@crazyyy
crazyyy / header.html
Last active January 5, 2019 18:25
#js #jquery || width of screen on mobile
<meta content="user-scalable=yes, maximum-scale=1.6, width=device-width, initial-scale=1, target-densitydpi=device-dpi" name="viewport">
@crazyyy
crazyyy / new_gist_file_0
Last active January 5, 2019 18:30
#js #debug || Превращаем браузер в текстовый редактор
document.body.contentEditable=true
@crazyyy
crazyyy / body.scss
Last active January 5, 2019 18:18
#html #scss #css #js || another modal window for contact form
body {
&.modal-opened {
overflow: hidden;
padding-right: 17px;
}
}
@crazyyy
crazyyy / imacros-cheatsheet.js
Last active January 5, 2019 18:17 — forked from LeCoupa/imacros-cheatsheet.js
#imacros || iMacros CheatSheet.
// More: http://journal.gentlenode.com/imacro-1-ultimate-cheatsheet/
// iMacro CheatSheet - Command Reference
// http://wiki.imacros.net/Command_Reference
// iMacros supports 3 types of variables:
// * The macro variables !VAR0 thru !VAR9. They can be used with the SET and ADD command inside a macro.
// * Built-in variables. They contain certain values set by iMacros.
// * User-defined variables. They are defined in-macro using the SET command.
@crazyyy
crazyyy / footer.php
Last active January 5, 2019 18:15
#html #scss #css #js || modal window for contact form