Skip to content

Instantly share code, notes, and snippets.

View romanoffs's full-sized avatar
🎯
Focusing

Денис romanoffs

🎯
Focusing
View GitHub Profile
@romanoffs
romanoffs / moment.js
Created June 16, 2018 22:03
get RU localization
/**
* Customize locale Moment JS
* @description Enables Moment.js plugin
*/
(function() {
function plural(word, num) {
var forms = word.split('_');
return num % 10 === 1 && num % 100 !== 11 ? forms[0] : (num % 10 >= 2 && num % 10 <= 4 && (num % 100 < 10 || num % 100 >= 20) ? forms[1] : forms[2]);
}
@romanoffs
romanoffs / Security Headers (nginx)
Last active June 16, 2018 22:08
Security Headers
add_header X-XSS-Protection "1; mode=block";
add_header X-Frame-Options "SAMEORIGIN";
add_header Referrer-Policy "strict-origin-when-cross-origin";
add_header X-Download-Options "noopen";
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
add_header X-Content-Type-Options "nosniff";
add_header Content-Security-Policy-Report-Only "";
@romanoffs
romanoffs / init.example.php
Created October 13, 2017 10:30
Makes the first letter of the line in the capital
<?php
/**
* Makes the first letter of the line in the capital
* @return string
*/
function upFirstLetter($str, $encoding = 'UTF-8')
{
return mb_strtoupper(mb_substr($str, 0, 1, $encoding), $encoding)
. mb_substr($str, 1, null, $encoding);
}
@romanoffs
romanoffs / common.js
Created August 10, 2017 17:14
Background 100%
function heightDetect() {
$(".main_head").css("height", $(window).height());
};
heightDetect();
$(window).resize(function() {
heightDetect();
});
@romanoffs
romanoffs / common.js
Created August 10, 2017 16:56
preloader
#loader {
background: none repeat scroll 0 0 #ffffff;
bottom: 0;
height: 100%;
left: 0;
position: fixed;
right: 0;
top: 0;
width: 100%;
z-index: 9999;
@romanoffs
romanoffs / common.js
Created August 10, 2017 16:12
от перетаскивания картинок
$("img, a").on("dragstart", function(event) { event.preventDefault(); });
@romanoffs
romanoffs / common.js
Created August 10, 2017 16:11
защита от копирования
document.ondragstart = noselect;
document.onselectstart = noselect;
// document.oncontextmenu = noselect;
function noselect() {return false;}
@romanoffs
romanoffs / youtube.js
Last active December 12, 2018 16:37
youtube embeded
"use strict";
$(function() {
$(".youtube").each(function() {
$(this).css('background-image', 'url(//i.ytimg.com/vi/' + this.id + '/sddefault.jpg)');
$(this).append($('<div/>', {'class': 'play'}));
$(document).delegate('#'+this.id, 'click', function() {
var iframe_url = "https://www.youtube.com/embed/" + this.id + "?autoplay=1&autohide=1";
if ($(this).data('params')) iframe_url+='&'+$(this).data('params');
@romanoffs
romanoffs / scroll.js
Created July 31, 2017 13:34
scroll.js
$('a[href^="#"]').bind('click.smoothscroll',function (e) {
e.preventDefault();
var target = this.hash,
$target = $(target);
$('html, body').stop().animate({
'scrollTop': $target.offset().top
}, 500, 'swing', function () {
window.location.hash = target;
@romanoffs
romanoffs / gist:5609a4228ae5109bb0a8d8316d5c953e
Last active June 16, 2018 22:11
disabled access wget user agent (apache2)
RewriteCond %{HTTP_USER_AGENT} wget [NC]
RewriteRule .* - [F]