Skip to content

Instantly share code, notes, and snippets.

View krybinski's full-sized avatar

Kamil Rybiński krybinski

  • Gdansk
View GitHub Profile
@krybinski
krybinski / gist:e549354507fbb1fd53c62b42307a1718
Created July 30, 2024 12:54
Remove last commit from git and push to the epo
git reset --hard HEAD^
git push origin -f
@krybinski
krybinski / js-polyfills
Created November 9, 2020 09:56
JavaScript Polyfills
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function(obj, start) {
for (var i = (start || 0), j = this.length; i < j; i++) {
if (this[i] === obj) { return i; }
}
return -1;
}
}
// TIL a CSS trick to handle that annoying mobile viewport bug with `100vh` in WebKit (iOS Safari)!
body {
min-height: 100vh;
/* mobile viewport height fix */
min-height: -webkit-fill-available;
}
// Prevent body scroll when modal is opened
body.modal-open {
const inBrowser = typeof window !== 'undefined'
// get user agent
const UA = inBrowser && window.navigator.userAgent.toLowerCase()
// detect browser
const isIE = UA && /msie|trident/.test(UA)
const isIE9 = UA && UA.indexOf('msie 9.0') > 0
const isEdge = UA && UA.indexOf('edge/') > 0
const isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge
@krybinski
krybinski / helpers.js
Last active March 26, 2020 14:39
Helpful vanilla JS helper functions
/**
* Check if element is in screen viewport
*/
export const isInViewport = (elem) => {
const distance = elem.getBoundingClientRect();
return (
distance.top >= 0 &&
distance.left >= 0 &&
distance.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
@krybinski
krybinski / google-map.css
Created March 12, 2020 15:09
Disable Google Map logo
// Disable logo and text bar
a[href^="http://maps.google.com/maps"] {
display: none !important;
}
a[href^="https://maps.google.com/maps"] {
display: none !important;
}
.gmnoprint a,
class CookiesBar {
constructor(element) {
this.NAME = 'COOKIE_NAME';
this.VALUE = 'ACCEPT';
this.HIDDEN_CLASS = 'd-none';
this.cookiesBar = element;
}
setCookie(cname, cvalue, exdays) {
const d = new Date();
@krybinski
krybinski / placeholder.css
Created January 31, 2020 17:57
Hide placeholder on focus - css only
input:focus::-webkit-input-placeholder { opacity: 0; }
input:focus:-moz-placeholder { opacity: 0; }
input:focus::-moz-placeholder { opacity: 0; }
input:focus:-ms-input-placeholder { opacity: 0; }
input:focus::placeholder { opacity: 0; }
textarea:focus::-webkit-input-placeholder { opacity: 0; }
textarea:focus:-moz-placeholder { opacity: 0; }
textarea:focus::-moz-placeholder { opacity: 0; }
textarea:focus:-ms-input-placeholder { opacity: 0; }
@krybinski
krybinski / patterns.js
Last active August 20, 2019 07:30
js validation patterns module
export const EMAIL_PATTERN = /^[a-zA-Z0-9._-]+[a-zA-Z0-9._-]+@[a-z0-9._-]+\.[a-z.]{2,10}$/;
export const PHONE_PATTERN = /^(?:\(?\+?[0-9]{2})?(?:[-\.\(\)\s]*(\d)){9}\)?/;
export const POSTAL_CODE_PATTERN =/^[0-9]{2}-[0-9]{3}$/;
@krybinski
krybinski / _base.scss
Last active December 16, 2019 05:34
Base styles file
*,
*::before,
*::after {
box-sizing: border-box;
}
html,
body {
height: 100%;
}