Skip to content

Instantly share code, notes, and snippets.

@agragregra
agragregra / jQuery HTML Loader
Last active Oct 21, 2021
jQuery HTML Loader (Development feature)
View jQuery HTML Loader
$('.loader').each(function() {
let loadContent = `parts/${ $(this).text() }`
$(this).load(loadContent)
})
<div class="loader">part.html</div>
@agragregra
agragregra / lazyload.js
Created Feb 13, 2020
Lazy loading img & background images using intersection observer
View lazyload.js
// Lazy loading img & background images using intersection observer
// Reference: https://developers.google.com/web/fundamentals/performance/lazy-loading-guidance/images-and-video/
// Using example: <img class="lazy" src="thumb.gif" data-src="real-img.jpg" data-srcset="real-img@1x.jpg 1x, real-img@2x.jpg 2x">
// Background image class usign example: <div class="lazy-background"> with added class ".visible" for styling
// Background image style attribute lazy loading example: <div data-bg="image.jpg">
// delete window.IntersectionObserver; // Fallback Testing
document.addEventListener('DOMContentLoaded', function() {
@agragregra
agragregra / macOS-Read-only.sh
Created Jan 10, 2020
macOS Read-only file system FIX
View macOS-Read-only.sh
sudo mount -uw /
@agragregra
agragregra / macOS-Safari-Web-Inspector-Font-Size.css
Last active Jun 1, 2021
macOS Safari Web Inspector Font Size
View macOS-Safari-Web-Inspector-Font-Size.css
/*
1. Reboot & hold Cmd+R
2. Open Terminal Utility
3. Type "csrutil disable", reboot
4. Add lines to end of file: /System/Library/PrivateFrameworks/WebInspectorUI.framework/Versions/Current/Resources/Main.css
4.1 For Safari 14+: /Library/Apple/System/Library/StagedFrameworks/Safari/WebInspectorUI.framework/Versions/A/Resources/Main.css
5. Enable csrutil at reboot - "csrutil enable"
*/
View AppleScript.Translate.txt
on run {input, parameters}
set phrase to input as string
set phrase to quoted form of phrase
set ui_lang to "ru"
set from_lang to "auto"
set to_lang to "ru"
do shell script "open 'https://translate.google.com/?hl='" & ui_lang & "'&sl='" & from_lang & "'&tl='" & to_lang & "'&text='" & phrase
end run
@agragregra
agragregra / hash-change.js
Last active May 5, 2021
CSS Target Without Jumping | Hash Change Without Jump
View hash-change.js
// Original
var hashLinks = document.querySelectorAll("a[href^='#']");
[].forEach.call(hashLinks, function (link) {
link.addEventListener("click", function (event) {
event.preventDefault();
history.pushState({}, "", link.href);
history.pushState({}, "", link.href);
history.back();
});
});
@agragregra
agragregra / nodejs-gulp-install.txt
Last active Jun 11, 2021
Node.js + Gulp installation (Ubuntu) one line command
View nodejs-gulp-install.txt
1. Simple (Node.js LTS, Gulp, rimraf, NCU):
sudo apt-add-repository -y ppa:brightbox/ruby-ng; sudo apt-get update; sudo apt-get -y install curl; curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -; sudo apt-get -y install nodejs; sudo npm i -g gulp rimraf npm-check-updates bower; sudo chown -R $USER:$(id -gn $USER) /home/$USER/.config
2. Advanced (Node.js LTS, Gulp, rimraf, NCU, Ruby, Jekyll, Jekyll paginate)
sudo apt-add-repository -y ppa:brightbox/ruby-ng; sudo apt-get update; sudo apt-get -y install curl ruby2.5 ruby2.5-dev gcc make g++ libffi-dev; curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -; sudo apt-get -y install nodejs; sudo gem i jekyll; sudo gem i jekyll-paginate-v2; sudo npm i -g gulp rimraf npm-check-updates bower; sudo chown -R $USER:$(id -gn $USER) /home/$USER/.config
3. Длинна командной строки (добавить PROMPT_DIRTRIM=3 в конец и сохранить файл):
sudo nano ~/.bashrc
PROMPT_DIRTRIM=3
@agragregra
agragregra / Main.css
Last active Jul 16, 2018
How to Change Safari Web Inspector Font
View Main.css
/*
1. Reboot & hold Cmd+R at the chimes
2. Open Terminal Utility
3. Type csrutil disable; reboot
4. Add lines to end of file: /System/Library/PrivateFrameworks/WebInspectorUI.framework/Versions/Current/Resources/Main.css
*/
.tree-outline.dom li.parent{line-height:21px}
@agragregra
agragregra / rsync-backup.sh
Last active Jun 3, 2019
Backup Files/Folders to External Hard Drive (Rsync)
View rsync-backup.sh
rsync -aP --delete --exclude=node_modules --exclude=Thumbs.db --exclude=.DS_Store /Users/alex/Work/ /Volumes/BACKUP/Work/
@agragregra
agragregra / install
Last active Jun 3, 2019
Fast Install Node.js, Gulp & Jekyll into Windows 10/Ubuntu/Mint
View install
sudo apt-add-repository -y ppa:brightbox/ruby-ng; sudo apt-get update; sudo apt-get -y install curl ruby2.5 ruby2.5-dev gcc make g++ libffi-dev; curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -; sudo apt-get -y install nodejs; sudo gem i jekyll -v 3.7.2; sudo gem i jekyll-paginate-v2; sudo npm i -g gulp rimraf npm-check-updates; sudo chown -R $USER:$(id -gn $USER) /home/$USER/.config