Skip to content

Instantly share code, notes, and snippets.

Michael mdahlke

Block or report user

Report or block mdahlke

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mdahlke
mdahlke / arrow.scss
Created Jan 11, 2017
Create arrows quickly with a SCSS mixin Raw
View arrow.scss
@mixin arrow($direction: 'up', $size: 5px, $color: black) {
width: 0;
height: 0;
@if ($direction == 'up') {
border-left: $size solid transparent;
border-right: $size solid transparent;
border-bottom: $size solid $color;
} @else if ($direction == 'down') {
border-left: $size solid transparent;
@mdahlke
mdahlke / best-fit-image.php
Created Jan 10, 2017
Find the image that best fits a particular area of the page
View best-fit-image.php
<?php
$knownBestFits = [];
/**
* Find the smallest image to use in a given space with the minimal dimensions provided
* If width is the main decider, leave the height set at 0, and vice versa if the height is the main decider
* You may use both if a minimum height/width is needed
*
* @param $imageObj WP Image Object
* @param int $minWidth Minimum width the image needs to be
@mdahlke
mdahlke / implode-associative-array.php
Created Jan 10, 2017
Implode an associative array on specified key
View implode-associative-array.php
function implode_aa( $glue, $array, $key ) {
$keep = array();
foreach ( $array as $firstKey ) {
foreach ( $firstKey as $k => $v ) {
if ( $k === $key ) {
$keep[] = $v;
}
@mdahlke
mdahlke / vertical-flow.scss
Last active Jan 10, 2017
Create consistent vertical with classic bootstrap style selectors
View vertical-flow.scss
/*scss/SCSS-Mixins-Functions/_mixin-vertical-flow.scss*/
// @function explode() -- split a string into a list of strings
// {string} $string: the string to be split
// {string} $delimiter: the boundary string
// @return {list} the result list
@function explode($string, $delimiter) {
$result: ();
@if $delimiter == "" {
@for $i from 1 through str-length($string) {
@mdahlke
mdahlke / wp-custom-pagination__archive.php
Created Jan 9, 2017
Create custom pagination for custom WP queries
View wp-custom-pagination__archive.php
<?php
$paged = (int) ( get_query_var( 'result-page' ) ?: 1 );
$postsPerPage = get_option('posts_per_page');
$args = array(
'post_type' => 'news',
'posts_per_page' => $postsPerPage,
'paged' => $paged,
'orderby' => receive( 'news_orderby', 'date' ),
View responsive-bootstrap-gutters.scss
$breakpoints: (
'xs': 0px,
'sm': 768px,
'md': 992px,
'lg': 1200px,
);
$gutters: (
'no': 0,
View responsive-headings.scss
@function px2em($px, $unit: 'em'){
@return #{$px / $baseFontSize}#{$unit};
}
@function first($list) {
@if type-of($list) == 'list' {
@return nth($list, 1);
} @else {
@return $list;
}
You can’t perform that action at this time.