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 / featured-thumbnail-column.php
Created October 17, 2015 14:41
Show the featured image from each post on Wordpress dashboard.
@brunomonteiro3
brunomonteiro3 / get-attachments.php
Created October 20, 2015 13:02
List all attachments of a post or page in Wordpress.
<?php
$attachments = get_posts( array(
'post_type' => 'attachment',
'posts_per_page' => -1,
'post_parent' => $post->ID,
'exclude' => get_post_thumbnail_id(),
'orderby' => 'menu_order',
'order' => 'ASC'
) );
@brunomonteiro3
brunomonteiro3 / base64-black-color-pixel.txt
Created November 18, 2015 13:09
Base64 1x1 black color pixel with opacity.
75% opacity:
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAACnej3aAAAAAXRSTlPCNYx7+gAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=
@brunomonteiro3
brunomonteiro3 / seo-url.php
Last active April 6, 2016 16:10
SEO friendly URL. "Löng Strîng" will be converted to > "long-string".
<?php
function seoUrl($string, $separator = '-') {
$accents_regex = '~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i';
$special_cases = array( '&' => 'and', "'" => '');
$string = mb_strtolower( trim( $string ), 'UTF-8' );
$string = str_replace( array_keys($special_cases), array_values( $special_cases), $string );
$string = preg_replace( $accents_regex, '$1', htmlentities( $string, ENT_QUOTES, 'UTF-8' ) );
$string = preg_replace("/[^a-z0-9]/u", "$separator", $string);
$string = preg_replace("/[$separator]+/u", "$separator", $string);
return $string;
#element{
-webkit-transition: all 350ms ease;
-moz-transition: all 350ms ease;
-o-transition: all 350ms ease;
transition: all 350ms ease;
}
@brunomonteiro3
brunomonteiro3 / gist:b28d958471be9cc577236f1564014649
Created September 3, 2016 14:58
jQuery - Do something after X pixels.
$(window).scroll(function () {
if ($(this).scrollTop() > 100) {
...
} else {
...
}
});
@brunomonteiro3
brunomonteiro3 / transition.less
Created September 19, 2016 16:53
MIXIN - LESS - Transitions
.transition (@transition) {
-webkit-transition: @transition;
-moz-transition: @transition;
-ms-transition: @transition;
-o-transition: @transition;
}
@brunomonteiro3
brunomonteiro3 / query-template.php
Created September 26, 2016 18:23
Query posts with specific template
<?php
/*
Template Name: List
*/
?>
<style>
td, tr{
border: 1px solid grey;
padding: 10px;
@brunomonteiro3
brunomonteiro3 / current-date.js
Created November 7, 2016 13:38
Current date in pure JS + jQuery
$(document).ready(function(){
var today = new Date();
var day = today.getDate();
var month = today.getMonth()+1; //January is 0!
var year = today.getFullYear();
if(day < 10) {
day = '0' + day
}
@brunomonteiro3
brunomonteiro3 / between.js
Created November 10, 2016 09:09
Check if value is between X or Y
function between(x, min, max) {
return x >= min && x <= max;
}