Skip to content

Instantly share code, notes, and snippets.

View kruzyk's full-sized avatar
🕵️‍♂️
a day is too short

Jacek Krużycki kruzyk

🕵️‍♂️
a day is too short
View GitHub Profile
@kruzyk
kruzyk / viewportCalc.js
Created January 29, 2019 12:30
Debugger that shows view port size. Helps when making responsive designs.
// -----------
// Debugger that shows view port size. Helps when making responsive designs.
// -----------
function showViewPortSize(display) {
if(display) {
var height = window.innerHeight;
var width = window.innerWidth;
jQuery('body').prepend('<div id="viewportsize" style="z-index:9999;position:fixed;bottom:0px;left:0px;color:#fff;background:#000;padding:10px">Height: '+height+'<br>Width: '+width+'</div>');
jQuery(window).resize(function() {
height = window.innerHeight;
@kruzyk
kruzyk / media.css
Last active March 1, 2019 10:35
Detect device with CSS
/* smartphones, touchscreens */
@media (hover: none) and (pointer: coarse) {
/* ... */
}
/* stylus-based screens */
@media (hover: none) and (pointer: fine) {
/* ... */
}
@kruzyk
kruzyk / README.md
Created January 30, 2019 13:33 — forked from joyrexus/README.md
Vanilla JS equivalents of jQuery methods

Sans jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})

Polecenia konsoli Linux

Operacje na plikach i katalogach

  • pwd - aktualny katalog
  • ls -la - listuje wszystkie dostępne pliki
  • ls -lat - listuje wszystkie dostępne pliki posortowane według czasu modyfikacji
  • cp -r {nazwa pliku/katalogu} {miejsce docelowe} - kopiuje plik lub cały katalog z zawartością we wskazane miejsce
  • mv {nazwa pliku/katalogu} {miejsce docelowe} - przenosi plik lub cały katalog z zawartością we wskazane miejsce (jeśli lokalizacja pliku docelowego jest taka sama jak pliku do przeniesienia, zmienia nazwę)
  • du -sh - pokazuje zajętość całego katalogu
  • du -sh * - pokazuje rozmiar poszczególnych plików i katalogów
@kruzyk
kruzyk / polecenia_git.md
Last active September 20, 2019 09:58 — forked from cytrowski/polecenia_git.md
Polecenia GIT

Przydatne polecenia GIT

  • git init - inicjalizuje repozytorium GIT w katalogu
  • git clone {adres repozytorium} - klonuje repozytorium do katalogu
  • git status - pokazuje status repozytorium (pokazuje informację o zmodyfikowanych, nowych, usuniętych oraz nie należące do repozytorium plikach)
  • git remote add {jakaś nazwa} {adres repozytorium} - dodaje repozytorium innego użytkownika (git remote add upstream https://github.com/bluetree-service/idylla.git)
  • git remote -v lista wszystkich zewnetrznych repozytoriów
  • git remote rm {nazwa dla remota} - usuwa zewnętrzne repozytorium
  • git fetch {nazwa remota} - pobiera listę zmian z innego repozytorium (w tym pokazuje nowe gałęzie)
  • git branch - lista gałęzi w repozytorium
@kruzyk
kruzyk / npm_commands.md
Last active March 12, 2019 21:28
npm commands

Check outdated npm packages:

  • npm outdated

Install npm-check-updates and update all npm packages:

  • npm i -g npm-check-updates && ncu -u && npm i
@kruzyk
kruzyk / smoothScroll.js
Created September 16, 2019 12:06
smooth scroll for all # (id) internal links
$('a[href^=#]:not([href=#])').on('click', function () {
var element = $($(this).attr('href'));
$('html,body').animate({ scrollTop: element.offset().top },'normal', 'swing');
return false;
});
@kruzyk
kruzyk / mediaQueries.js
Last active September 20, 2019 09:54
adjust the appearance and behavior depending on the width of the screen (CSS media queries in JS)
function handleProperDevice(x) {
if (x.matches) {
// If media query matches
} else {
// If media query doesn't match
}
}
var x = window.matchMedia("(max-width: 768px)");
@kruzyk
kruzyk / pre-commit
Last active October 22, 2019 12:06
GIT pre-commit
#!/bin/sh
# Redirect output to stderr.
exec 1>&2
# enable user input
exec < /dev/tty
consoleregexp='console'
# CHECK
if test $(git diff --cached | grep $consoleregexp | wc -l) != 0
then
@kruzyk
kruzyk / del-console.sh
Created October 31, 2019 12:55 — forked from houkanshan/del-console.sh
Clear "console.log" before `git commit`, and recover them after `git commit`, add them to git-hooks file: pre-commit & post-commit ~
#!/bin/sh
debug_rex='/console.log/'
debug_print_rex=$debug_rex'p'
debug_del_rex=$debug_rex' d'
add_debug_patch='.add-debug.patch'
del_debug_patch='.del-debug.patch'
git_work_dir="$(git rev-parse --show-toplevel)"
fake_file="$git_work_dir/.fake_file"
cur_dir="$(pwd)"