Skip to content

Instantly share code, notes, and snippets.

View micc83's full-sized avatar

Alessandro Benoit micc83

View GitHub Profile
@micc83
micc83 / gist:5875231
Created June 27, 2013 09:37
Current page url
<?php
/**
* RITORNA L'URL CORRENTE
*/
function curPageURL() {
$pageURL = 'http';
if ( isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") $pageURL .= "s";
$pageURL .= "://";
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
@micc83
micc83 / iframe-height.js
Created June 23, 2014 17:01
Set iframe height based on content
jQuery('iframe.inpagedemo').load(function () {
var iframe = jQuery(this);
jQuery(window).resize(function() {
iframe.height(iframe[0].contentWindow.document.body.scrollHeight + 40);
});
jQuery(window).trigger('resize');
});
@micc83
micc83 / create_admin.php
Created July 2, 2013 14:11
Create a new admin user in WordPress
<?php
// ADD NEW ADMIN USER TO WORDPRESS
// ----------------------------------
// Put this file in your Wordpress root directory and run it from your browser.
// Delete it when you're done.
require_once('wp-blog-header.php');
require_once('wp-includes/registration.php');
// CONFIG
@micc83
micc83 / index.html
Last active January 4, 2019 07:15
Multifile uploader with images preview
<form method="post" id="tiribi" enctype="multipart/form-data">
<input id="fileuploader" type="file" name="file[]" multiple="" >
<ul class="filelist"></ul>
<input type="submit" class="button" name="multi_post_submit" value="Upload files" id="submit_button" />
</form>
@micc83
micc83 / gist:5964192
Last active January 4, 2019 07:14
WordPress Gists embed Shortcode
<?php
/**
* WordPress Gists Shortcode
*
* To include a Gist you have different possibilities:
* [gists id="5964192"]
* [gists]https://gist.github.com/micc83/5964192[/gists]
* [gists id="5964192" file="index.html"]
* [gists file="index.html"]https://gist.github.com/micc83/5964192[/gists]
@micc83
micc83 / .htaccess
Created October 31, 2016 16:36
.htaccess for javascript app routing
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(.*) /conf/index.html [NC,L]
@micc83
micc83 / snapshot.php
Last active January 4, 2019 07:09
PHPUnit Assertion that asserts the response content match a previous taken snapshot
<?php
/**
* Assert the response content match a previous taken snapshot.
* If the snapshot doesn't exists on the first run it gets
* created and the test is marked as incomplete.
*/
private function seeSnapshot()
{
$testName = debug_backtrace()[1]['function'];
$filename = "snapshots/{$testName}.json";
@micc83
micc83 / .htaccess
Created January 30, 2018 14:44
Maintenance mode through .htaccess
# Create file maintenance.html then
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !/maintenance.html$ [NC]
RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif) [NC]
RewriteRule .* /maintenance.html [R=302,L]
</IfModule>
@micc83
micc83 / bosh.sh
Created December 20, 2018 08:51
Tail for commands on Mac
botch() {
while true; do
(echo -en '\033[H'
CMD="$@"
bash -c "$CMD" | while read LINE; do
echo -n "$LINE"
echo -e '\033[0K'
done
echo -en '\033[J') | tail -r | tail -r
sleep 2
@micc83
micc83 / .zshrc
Created November 13, 2018 10:17
Laradock bash aliases
alias ld-up="(cd laradock;docker-compose up -d apache2 mariadb)"
alias ld-down="(cd laradock;docker-compose down)"
alias ld-ssh="(cd laradock;docker-compose exec workspace bash)"