Skip to content

Instantly share code, notes, and snippets.

View kovtunos's full-sized avatar

Andrey Kovtun kovtunos

View GitHub Profile
@kovtunos
kovtunos / full-width.css
Last active February 28, 2018 19:04
Full width section inside fixed width container #css
/* Variant 1 */
.full-width {
margin-left: calc(-50vw + 50%);
margin-right: calc(-50vw + 50%);
}
/* Variant 2 */
.full-width {
width: 100vw;
margin-left: -50vw;
@kovtunos
kovtunos / .htaccess
Last active September 29, 2017 14:19
Remove trailing slash #htaccess
RewriteBase /
# Remove trailing slash
RewriteRule ^(.*)/$ $1 [R=301,L]
@kovtunos
kovtunos / target-blank.js
Created February 18, 2017 07:36
Add target="_blank" to external links #js #jquery
$('a[href^="http://"], a[href^="https://"]').not('a[href*=mydomainname]').attr('target','_blank');
@kovtunos
kovtunos / http-to-https.js
Created February 18, 2017 06:49
HTTP to HTTPS with #jquery #js
// var 1
$('a[href^="http://"]').attr('href', function(i, oldhref){
oldhref.replace("http://","https://")
});
// var 2
$('a[href^="http://"]').each(function(){
$(this).attr('href', $(this).attr('href').replace("http://","https://"))
});
@kovtunos
kovtunos / .htaccess
Last active September 29, 2017 14:10
Redirect to HTTPS #drupal #htaccess
# Redirect to HTTPS
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Redirect to HTTPS
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www.example\.com*
RewriteRule ^(.*)$ https://example.com/$1 [L,R=301]
@kovtunos
kovtunos / .htaccess
Last active September 29, 2017 14:19
Redirect to new domain #htaccess
RewriteEngine on
RewriteRule ^(.*)$ http://newdomain.com/$1 [R=301,L]
@kovtunos
kovtunos / random_quote.js
Created February 8, 2017 09:22
Random quote #js #jquery
var quotes = [{
quote: "It's not a faith in technology. It's faith in people.",
author: "Steve Jobs"
},
{
quote: "The first rule of any technology used in a business is that automation applied to an efficient operation will magnify the efficiency. The second is that automation applied to an inefficient operation will magnify the inefficiency.",
author: "Bill Gates"
}
];
@kovtunos
kovtunos / grayscale.scss
Last active February 7, 2017 20:05
Grayscale image with color hover #css #js
// CSS
.grayscale {
filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); /* Firefox 10+, Firefox on Android */
filter: gray; /* IE6-9 */
-webkit-filter: grayscale(100%); /* Chrome 19+, Safari 6+, Safari 6+ iOS */
}
// JS
$('.image-list img').addClass('grayscale');
$('.image-list a').hover(function() {
@kovtunos
kovtunos / placeholder.scss
Created January 28, 2017 15:28
Input placeholder #sass
input[type='search'] {
&::-webkit-input-placeholder {
color: #666;
}
&::-moz-placeholder {
color: #666;
}
&:-ms-input-placeholder {
color: #666;
}
@kovtunos
kovtunos / _center.scss
Created January 12, 2017 08:59
Center element with positin absolute #sass
.box {
position: relative;
&::after {
position: absolute;
content: '';
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}