Skip to content

Instantly share code, notes, and snippets.

View lmartins's full-sized avatar

Luis Martins lmartins

  • Goodwin Media, Multiweb
  • Portugal
View GitHub Profile
@barneycarroll
barneycarroll / increase-specificity.scss
Created April 3, 2014 18:03
Generic mixin to increase the specificity of the contents rules
// Increase class-level specificity of a rule without functionaly modifying the selector
@mixin increase-specificity( $depth: 1 ) {
$sel : '';
@while($depth > 0) {
$sel : $sel + ':nth-child(n)';
$depth : $depth - 1;
}
&#{$sel} {
@toddmotto
toddmotto / qsa.js
Last active August 29, 2015 14:02
104 bytes jQuery-like wrapper, $('.class') returns NodeList, $('.class:first') returns first Node only, optional scoping $('.class', '.parent')
function $(a,b){return(b||document)['querySelector'+(b=/\:first$/,b.test(a)?'':'All')](a.replace(b,''))}
@DanHulton
DanHulton / gist:993415
Created May 26, 2011 15:58 — forked from hashmal/gist:803816
Playing with CoffeeScript, do funny things with mixins.
# Swappable Mixins in CoffeeScript
# ================================
# Many thanks to Hashmal, who wrote this to start.
# https://gist.github.com/803816/aceed8fc57188c3a19ce2eccdb25acb64f2be94e
# Usage
# -----
# class Derp extends Mixin
@fffabs
fffabs / Preferences.sublime-text.json
Created December 20, 2013 17:26
SublimeText 3 User Preferences
{
//
// Fonts
"font_face": "Monaco",
"font_options":"subpixel_antialias",
"font_size": 11.0,
"bold_folder_labels":true,
"line_padding_bottom":1,
"line_padding_top":1,
"word_separators": "./\\()\"'-:,.;<>~!@$%^&*|+=[]{}`~?", // Remove '#'
@studiopress
studiopress / category-1.php
Last active October 27, 2017 00:10
Genesis body class.
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
//* Add custom body class to the head
add_filter( 'body_class', 'sp_body_class' );
function sp_body_class( $classes ) {
if ( is_category( '1' ) )
$classes[] = 'custom-class';
return $classes;
@pwenzel
pwenzel / google-maps-oembed-wordpress.php
Created February 1, 2013 22:45
Faux Google Maps oEmbed for Wordpress
<?php
/* Faux Google Maps oEmbed
* Embed google maps in a nicer iframe without using their provided embed code
* @usage Paste a Google Maps link in your post and it will be replaced with an iframe when published
* @link http://bigsaturday.net/oembed-google-maps-wordpress/
*/
wp_embed_register_handler( 'google_map', '#https://maps\.google\.com/maps(.*)#i', 'embed_google_map' );
function embed_google_map( $matches ) {
$query = parse_url($matches[0]);
(function($) {
acf.add_action('ready', function( $el ){
//Identify the field you want to check against.
//Use a class to handle scenarios involving repeater / flexible content where multiple instances exist
var $field = $('.example input');
$field.on('change', function (evt) {
@gregrickaby
gregrickaby / echo-an-image.php
Last active November 26, 2018 01:41
Get a WordPress post image, no matter what. Must be used in a loop.
<?php
/**
* Echo an image, no matter what.
*
* @param string $size the image size you want to echo
*/
function wds_do_post_image( $size = 'thumbnail' ) {
// If featured image is present, use that
if ( has_post_thumbnail() ) {
<?php
/**
* Get post image.
*/
function wds_get_post_image( $size = 'thumbnail' ) {
// If featured image is present, use that
if ( has_post_thumbnail() ) {
return get_the_post_thumbnail( $size );
anonymous
anonymous / gulpfile.js
Created December 18, 2014 15:25
var gulp = require("gulp");
var sass = require("gulp-sass");
var autoprefix = require("gulp-autoprefixer");
var filter = require('gulp-filter');
var browserSync = require('browser-sync');
var reload = browserSync.reload;
/**
* Start BrowserSync
*/