Skip to content

Instantly share code, notes, and snippets.

View mikehins's full-sized avatar

Mike Hins mikehins

  • Trinary
  • Mont-Tremblant
  • 21:05 (UTC -04:00)
View GitHub Profile
@mikehins
mikehins / filter_float.php
Last active January 6, 2020 20:15
Real filter float helper
<?php
$data = array(
0 => '1,000.214525844156$', // 1000.21
1 => '1,250.2525698', // 1250.25
2 => '10', // 10.00
3 => 100.21236985, // 100.21
4 => '1,10', // 1.10
5 => '1,000,000,01' // 1000000.01
);
@mikehins
mikehins / routine.md
Last active September 15, 2020 14:03
Forcer les https dans wordpress et opencart

HTACCESS

<ifModule mod_headers.c>
Header set X-XSS-Protection "1; mode=block"
Header always append X-Frame-Options SAMEORIGIN
Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" env=HTTPS
</ifModule>

# Enlever les www (si nécéssaire pour le seo)
@mikehins
mikehins / multi_array_unique.php
Last active March 4, 2019 16:20
Make a multidimensionnal array unique by key
$unique = array_intersect_key($array, array_unique(array_column($array, 'email')));
@mikehins
mikehins / defer iframe video
Last active July 2, 2019 17:05
function init() { var vidDefer = document.getElementsByTagName('iframe'); for (var i=0; i<vidDefer.length; i++) { if(vidDefer[i].getAttribute('data-src')) { vidDefer[i].setAttribute('src',vidDefer[i].getAttribute('data-src')); } } } window.onload = init;
<style>
.resp-container {
position: relative;
overflow: hidden;
padding-top: 56.25%;
}
.resp-iframe {
position: absolute;
top: 0;
left: 0;
@mikehins
mikehins / HouseKeeping.php
Last active July 15, 2019 13:31
Remove unecessary stuff from wordpress
<?php
/**
* Created by PhpStorm.
* User: mikeh
* Date: 2018-12-19
* Time: 10:28 AM
*/
class HouseKeeping
{
@mikehins
mikehins / wp-remove-404
Created March 27, 2019 15:18
Remove 404 from wordpress for debug purposes
remove_action( 'template_redirect', 'maybe_redirect_404' );
add_filter( 'pre_handle_404', function() {
return false;
});
@mikehins
mikehins / HasManyThrough.php
Last active October 2, 2020 14:09
Visual aid
// https://www.laravelhasmanythrough.com/
public function offices()
{
/*
* SQL Query
*
SELECT
`offices`.*,
`office_user`.`user_id` ($1)
@mikehins
mikehins / wc-orders.php
Last active October 16, 2020 14:50
Helpers for woocommerce orders helpers
// https://www.businessbloomer.com/
// Get Order ID
$order->get_id();
// Get Order Totals $0.00
$order->get_formatted_order_total();
$order->get_cart_tax();
$order->get_currency();
$order->get_discount_tax();
@mikehins
mikehins / mikehins-scanner.php
Last active July 26, 2022 17:41
wp attack scanner
<?php
error_reporting(-1);
ini_set('display_errors', 1);
class MikeScan
{
private $delete;
private $i;
private $results = [];
private $object;
User-agent: *
Crawl-delay: 20
Allow: .js
Allow: .css
Allow: /wp-admin/admin-ajax.php
Disallow: /*&brand_tabletpc
Disallow: /*&cat
Disallow: /*&color
Disallow: /*&color_default
Disallow: /*&create=1