Skip to content

Instantly share code, notes, and snippets.

View ReekenX's full-sized avatar
💻
React, Vue, Rails, Python

Remis Jarmalavicius ReekenX

💻
React, Vue, Rails, Python
View GitHub Profile
@ReekenX
ReekenX / get_real_ip.php
Created March 19, 2014 04:57
GET real IP address (under proxy)
<?php
function get_real_ip() {
$proxy_headers = array(
'CLIENT_IP',
'FORWARDED',
'FORWARDED_FOR',
'FORWARDED_FOR_IP',
'HTTP_CLIENT_IP',
'HTTP_FORWARDED',
@ReekenX
ReekenX / prestashop_fix_for_apache
Created May 9, 2014 03:43
Prestashop 1.6 fix for Apache 2.4 (only for dev mode!)
find -iname '.htaccess' -exec sed 's/Deny from all//' -i {} \;
@ReekenX
ReekenX / pomodoro.bash
Created March 18, 2014 06:43
Pomodoro Bash
#!/bin/bash
# Public domain license
# Not original author: Remigijus Jarmalavičius
#
# Usage:
# pomodoro "title for work"
filename="/home/remigijus/Kodas/smelio-deze/`date '+%Y-%m-%d'`.log"
@ReekenX
ReekenX / mysql_grant_access.sql
Created March 20, 2012 15:11
Mysql: Grant access to single database
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER, LOCK TABLES, INDEX ON db_name.* TO db_username@localhost IDENTIFIED BY 'super duper secret password';
@ReekenX
ReekenX / .htaccess
Created March 19, 2014 05:09
Universal redirect to www
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
@ReekenX
ReekenX / .htaccess
Created March 19, 2014 05:09
Redirect to maintenance except custom IP's
RewriteEngine on
RewriteCond %{REQUEST_URI} !/maintenance.html$
RewriteCond %{REMOTE_ADDR} !^123\.123\.123\.123
RewriteRule $ /maintenance.html [R=302,L]
@ReekenX
ReekenX / .htaccess
Created March 19, 2014 05:08
Prevent hotlinking
RewriteEngine On
#Replace ?mysite\.com/ with your blog url
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?mysite\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
#Replace /images/nohotlink.jpg with your "don't hotlink" image url
RewriteRule .*\.(jpe?g|gif|bmp|png)$ /images/nohotlink.jpg [L]
@ReekenX
ReekenX / .htaccess
Created March 19, 2014 05:08
Deny access to some files
<FilesMatch "(install\.sql|config\.php|config\.php\.sample)$">
deny from all
</FilesMatch>
@ReekenX
ReekenX / .htaccess
Created March 19, 2014 05:07
Custom Error pages
ErrorDocument 400 /errors/badrequest.html
ErrorDocument 401 /errors/authreqd.html
ErrorDocument 403 /errors/forbid.html
ErrorDocument 404 /errors/notfound.html
ErrorDocument 500 /errors/serverr.html
@ReekenX
ReekenX / .htaccess
Created March 19, 2014 05:07
Cache file extensions
FileETag MTime Size
<ifmodule mod_expires.c>
<filesmatch "\.(jpg|gif|png|css|js)$">
ExpiresActive on
ExpiresDefault "access plus 1 year"
</filesmatch>
</ifmodule>