Skip to content

Instantly share code, notes, and snippets.

View ajaegers's full-sized avatar

Arnaud JAEGERS ajaegers

View GitHub Profile
@ajaegers
ajaegers / .htaccess
Created July 15, 2015 07:30
.htaccess Transparent redirect in subfolder
RewriteEngine On
RewriteRule ^$ public/ [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f # if file doesn't exists
RewriteCond %{REQUEST_FILENAME} !-d # if file doesn't exists
RewriteCond %{REQUEST_URI} !^/public # if url without '/public'
RewriteRule ^(.*)$ public/$1 [QSA,L]
@ajaegers
ajaegers / simple-iframe-cross-domain.html
Created July 9, 2015 13:08
Simple HTML iframe cross domain and immediately accessible
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<iframe name="preview" id="preview" src="javascript:var d=document.open();d.domain='example.com';d.close();void(0);" frameborder="0" height="100%" width="100%" allowfullscreen="true" allowtransparency="true"/>
</body>
</html>
@ajaegers
ajaegers / git-move-files-in-subfolder.md
Last active March 16, 2025 18:34
Git: move files in an subfolder keeping history

Change structure of project folder with Git

I have this structure:

 project-folder/
     .git
     wp-admin/
     wp-content/
     wp-includes/

.htaccess

@ajaegers
ajaegers / update-wp-cli.sh
Created May 25, 2015 15:57
Updating local wp-cli
echo '1. Updating WP-CLI in /usr/local/bin/' \
&& echo '2. Current version: ' \
&& wp --version \
&& cd /usr/local/bin \
&& curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar \
&& chmod +x wp-cli.phar \
&& echo '3. WP-CLI test...' \
&& php wp-cli.phar --version \
&& echo '4. Replacing...' \
&& sudo mv wp-cli.phar wp \
@ajaegers
ajaegers / inf-install-wp-cli.sh
Last active August 29, 2015 14:20
One command to install WP-CLI on hosting using alias (if you cannot move wp-cli.phar in PATH)
echo '1. Downloading WP-CLI in ~/bin/...' \
&& cd ~ && mkdir bin && cd bin \
&& curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar \
&& chmod +x wp-cli.phar \
&& echo '2. WP-CLI test...' \
&& php wp-cli.phar --info \
&& echo '3. Making wp alias...' \
&& echo "alias wp='php ~/bin/wp-cli.phar'" >> ~/.bash_aliases \
&& source ~/.bash_aliases \
&& echo '4. Making bash wp alias to be available on each login...' \
@ajaegers
ajaegers / keyboard-navigation-debug.js
Created May 7, 2015 11:25
Debugging keyboard navigation
// Debugging keyboard navigation:
document.addEventListener('keyup', function () {
console.log(document.activeElement)
})
@ajaegers
ajaegers / style.css
Created April 23, 2015 11:31
CSS3 : Inverse dom elements with flex
/**
* Inverse dom elements for mobile display
* @link with the help of http://www.alsacreations.com/tuto/lire/1493-css3-flexbox-layout-module.html
*/
.media-inverse {
display: flex;
flex-wrap: wrap-reverse;
}
.media-inverse > div {
width: 100%;
@ajaegers
ajaegers / wordpress_global_variables.php
Last active August 29, 2015 14:19
Wordpress common global variables phpDoc declaration for easiest development
/** @var WP $wp */
/** @var wpdb $wpdb */
/** @var WP_Locale $wp_locale */
/** @var WP_Query $wp_query */
/** @var WP_Query $wp_the_query */
/** @var WP_Rewrite $wp_rewrite */
/** @var WP_Roles $wp_roles */
/** @var WP_Widget_Factory $wp_widget_factory */
/** @var WP_Post $post */
/** @var WP_Embed $wp_embed */
@ajaegers
ajaegers / git forget
Created April 4, 2015 15:10
Making git forget a file that was tracked but is now in .gitignore
git rm -r --cached .
git add .
git commit -am "Remove ignored files"
@ajaegers
ajaegers / .htaccess
Created March 5, 2015 10:16
Maintenance page with whitelist ip
# banvhost begin
RewriteEngine On
RewriteCond %{REMOTE_ADDR} !^NUM\.NUM\.NUM\.NUM\.
#RewriteRule ^.* http://example.com/maintenance.html [P,L]
RewriteCond %{REQUEST_URI} !^/maintenance/
RewriteRule ^.* /maintenance/ [R,L]
# banvhost end