Skip to content

Instantly share code, notes, and snippets.

View brunomonteiro3's full-sized avatar

Bruno Monteiro brunomonteiro3

  • Empiricus Research
  • São Paulo, Brazil
View GitHub Profile
@brunomonteiro3
brunomonteiro3 / jquery-script.js
Created November 16, 2016 15:42
jQuery script sample
;(function ($) {
console.log('your-code');
})(jQuery);
@brunomonteiro3
brunomonteiro3 / img_p_class_content_filter.php
Created December 7, 2016 23:44
Add class to every image inside a <p> on the_content
<?php
add_filter( 'the_content', 'img_p_class_content_filter', 20);
function img_p_class_content_filter($content) {
$content = preg_replace("/(<p[^>]*)(\>.*)(\<img.*)(<\/p>)/im", "\$1 class='content-img-wrap'\$2\$3\$4", $content);
return $content;
}
@brunomonteiro3
brunomonteiro3 / page_status_checker.php
Created February 14, 2017 23:50
PHP - Page status checker. Based on a cURL request, this script will check if an element is rendered on the requested URL and if it's not found, fire an e-mail alert.
<?php
/*
Author: Monteiro, Bruno
E-mail: [email protected]
*/
// Simple cURL settings to retrive all data from the submitted URL
function page_status_checker( $url ) {
$user_agent='Mozilla/5.0 (Windows NT 6.1; rv:8.0) Gecko/20100101 Firefox/8.0';
@brunomonteiro3
brunomonteiro3 / php-array-multiple-attributes.php
Created February 27, 2017 18:53
PHP array with multiple attributes
<?php
$items = array();
$items[] = array(
'attr1' => 'value1',
'attr2' => 'value2'
);
foreach ($items as $item) :
echo $item['attr1'];
@brunomonteiro3
brunomonteiro3 / random-number.js
Created May 10, 2017 01:34
Generate random number between two numbers in JavaScript
function randomIntFromInterval(min,max){
return Math.floor(Math.random()*(max-min+1)+min);
}