Skip to content

Instantly share code, notes, and snippets.

View peacefulseeker's full-sized avatar

Alexey Vorobyov peacefulseeker

View GitHub Profile
@peacefulseeker
peacefulseeker / .htaccess_require_ip_for_accessing_the_page
Last active July 19, 2017 12:11
Htaccess require ip for access the pages
<RequireAll>
Require ip <ip1> <ip2>
</RequireAll>
@peacefulseeker
peacefulseeker / .htaccess_restrict_file_access_filtered_by_ip
Last active July 19, 2017 12:00
Htaccess restrict access to files with certain IP accessibility filter
<Files pphinfo.php>
Order deny,allow
Deny from all
Allow from <ip1> <ip2>
</Files>
@peacefulseeker
peacefulseeker / .htaccess_deflate_enable
Created July 12, 2017 15:12
Htaccess Deflate Enable
<IfModule deflate_module>
<IfModule filter_module>
AddOutputFilterByType DEFLATE text/plain text/html
AddOutputFilterByType DEFLATE text/xml application/xml application/xhtml+xml application/xml-dtd
AddOutputFilterByType DEFLATE application/rdf+xml application/rss+xml application/atom+xml image/svg+xml
AddOutputFilterByType DEFLATE text/css text/javascript application/javascript application/x-javascript
AddOutputFilterByType DEFLATE font/otf font/opentype application/font-otf application/x-font-otf
AddOutputFilterByType DEFLATE font/ttf font/truetype application/font-ttf application/x-font-ttf
</IfModule>
</IfModule>
@peacefulseeker
peacefulseeker / .htaccess_browser_cache_enable
Created July 12, 2017 15:11
Htaccess Browser Cache Enable
<ifModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 5 seconds"
ExpiresByType image/x-icon "access plus 1 month"
ExpiresByType image/jpeg "access plus 4 weeks"
ExpiresByType image/png "access plus 30 days"
ExpiresByType image/gif "access plus 43829 minutes"
ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds"
ExpiresByType text/css "access plus 604800 seconds"
ExpiresByType text/javascript "access plus 604800 seconds"
@peacefulseeker
peacefulseeker / .htaccess_deny_from_except_ip
Last active July 19, 2017 12:12
Htaccess Deny from All except IP OLD Version
order deny,allow
deny from all
allow from <ip goes here>
@peacefulseeker
peacefulseeker / php_dumper.php
Last active November 27, 2017 16:19
PHP - Dumper by Koterov Dmitriy
<?php ## Функция для вывода содержимого переменной.
// Распечатывает дамп переменной на экран.
function dumper( $obj ) {
echo
"<pre>",
htmlspecialchars( dumperGet( $obj ) ),
"</pre>";
}
// Возвращает строку - дамп значения переменной в древовидной форме
@peacefulseeker
peacefulseeker / .htaccess_https_and_www_force
Last active November 30, 2017 13:31
Htaccess HTTPS and WWW. force in URL
# Taken from here : https://simonecarletti.com/blog/2016/08/redirect-domain-http-https-www-apache/
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [L,NE,R=301]
@peacefulseeker
peacefulseeker / .htaccess_rewrite_folder_in_url
Last active November 27, 2017 15:47
Htaccess rewrite folder path and redirect
<IfModule mod_rewrite.c>
# IMPORTANT TO PLACE IT BEFORE OTHER REWRITE RULES. REDIRECTS ONE FOLDER PATH TO ANOTHER
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteRule ^produkte/(.*)$ /pm_produkte/$1 [L,NC,R=302]
</IfModule>
@peacefulseeker
peacefulseeker / jQuery_InfiniteScrollDown_OnajaxComlplete.js
Last active November 27, 2017 16:21
jQuery - Infinite Scroll Down on dynamic ajax content loaded
/* Test here: http://www.meinpraktikum.de/praktikum/suchen?utf8=%E2%9C%93&q=&location=*/
(function( $ ) {
$(document).ajaxComplete(function(){
$("html, body").animate({ scrollTop: $(document).height() }, "slow");
console.log($(".search-result-vacancies-box").length);
})
})(jQuery);
@peacefulseeker
peacefulseeker / JavaScript_getSelected.js
Last active November 27, 2017 16:24
JavaScript - return the current selection
function getSelected() {
if (window.getSelection) {
return window.getSelection().toString();
} else if (document.getSelection) {
return document.getSelection().toString();
} else {
var selection = document.selection && document.selection.createRange();
if (selection.text) {
return selection.text.toString();
}