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 / .htaccess
Last active August 17, 2018 17:13
.htaccess file for Laravel project
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
@krybinski
krybinski / _mixins.sass
Last active May 5, 2020 07:08
Helpful SASS mixins
/** Placeholder */
@mixin placeholder {
&.placeholder { @content; }
&:-moz-placeholder { @content; }
&::-moz-placeholder { @content; }
&:-ms-input-placeholder { @content; }
&::-webkit-input-placeholder { @content; }
}
/** Placeholder autofill */
@krybinski
krybinski / index.html
Last active December 16, 2019 05:35
HTML file template
<!DOCTYPE html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0" />
<meta name="format-detection" content="telephone=no" />
<title>Title</title>
<meta name="description" content="" />
<meta name="author" content="" />
@krybinski
krybinski / scrolling.js
Last active April 29, 2023 16:59
Disable and enable scrolling in JS
const keys = {37: 1, 38: 1, 39: 1, 40: 1};
function preventDefault(e) {
e.preventDefault();
}
function preventDefaultForScrollKeys(e) {
if (keys[e.keyCode]) {
preventDefault(e);
return false;
@krybinski
krybinski / _base.scss
Last active December 16, 2019 05:34
Base styles file
*,
*::before,
*::after {
box-sizing: border-box;
}
html,
body {
height: 100%;
}
@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 / 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; }
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 / 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,
@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) &&