Skip to content

Instantly share code, notes, and snippets.

@Rarst
Rarst / headings.less
Created Jul 14, 2017
Less mixin to calculate vertical rhythm styling for headings [in Bootstrap]. Don’t ask me how this works because I don’t remember and this made my brain hurt enough.
View headings.less
.heading-line-height( @line-height ) when ( @line-height < 1 ) {
line-height: unit(@line-height * 2, em);
}
.heading-line-height( @line-height ) when ( @line-height >= 1 ) {
line-height: unit(@line-height, em);
}
.heading-rhythm ( @font-size-base, @font-size-increase ) {
@heading-font-size: @font-size-base * @font-size-increase;
@markjaquith
markjaquith / readme.md
Last active Jun 11, 2017
For WordPress, a method to re-index a multi-dimensional array by the (unique) value of a given array key
View readme.md

Okay, so, let's say you have some data like this:

$things = [
  0 => [ 'id' => 123, 'title' => '123 Title', 'content' => '123 Content' ],
  1 => [ 'id' => 456, 'title' => '456 Title', 'content' => '456 Content' ],
  2 => [ 'id' => 789, 'title' => '789 Title', 'content' => '789 Content' ],
];
@claygriffiths
claygriffiths / resize_local_machine.sh
Last active Nov 6, 2020 — forked from joost/resize_boot2docker.sh
Resize Local by Flywheel VirtualBox image
View resize_local_machine.sh
# Steps we will take:
# 1. Change Local (Docker Machine) image type (this will take a bit)
# 2. Resize image
# 3. Resize partion
#
# Also see: https://docs.docker.com/articles/b2d_volume_resize/
# IMPORTANT: Make sure Local is not running!
VM_NAME="local-by-flywheel"
NEW_DISK_SIZE=50000
@spivurno
spivurno / gw-edd-could-not-copy-file-fix-for-windows-servers.php
Created Feb 2, 2017
Easy Digital Downloads: "Could not copy file" Fix For Windows Servers
View gw-edd-could-not-copy-file-fix-for-windows-servers.php
<?php
/**
* Easy Digital Downloads provides packages URLs that look something like this:
*
* http://mysite.com/edd-sl/package_download/MTQ4NjA1NTA0NjphMDA5MTkzZjQ0NGRiNmVmMzczY2JhNTFiZWIxMWZiYzo0NzM3MzphM2Q5ZDA3NDQwMjZjZDFmOWVhYTBiNzBjMjVlZjI0YjpodHRwQC8vbXVzaWNmZXN0aXZhbC5zY2hvb2wubno
*
* This generates a temporary filename for the update process that look something like this:
*
* MTQ4NjA1NTA0NjphMDA5MTkzZjQ0NGRiNmVmMzczY2JhNTFiZWIxMWZiYzo0NzM3MzphM2Q5ZDA3NDQwMjZjZDFmOWVhYTBiNzBjMjVlZjI0YjpodHRwQC8vbXVzaWNmZXN0aXZhbC5zY2hvb2wubno.tmp
*
@kellenmace
kellenmace / add-unfiltered_html-capability-to-admins-or-editors.php
Last active Sep 6, 2020
Add unfiltered_html Capability to Admins or Editors in WordPress Multisite
View add-unfiltered_html-capability-to-admins-or-editors.php
<?php
/**
* Enable unfiltered_html capability for Editors.
*
* @param array $caps The user's capabilities.
* @param string $cap Capability name.
* @param int $user_id The user ID.
* @return array $caps The user's capabilities, with 'unfiltered_html' potentially added.
*/
@mgratch
mgratch / sideload-gf-images.php
Created Jun 7, 2016
sideload images from gf multi-upload
View sideload-gf-images.php
<?php
add_filter( 'gform_save_field_value', 'save_field_value', 10, 4 );
function save_field_value( $value, $lead, $field, $form ) {
$output_ids = array();
global $files_to_sideload;
if(!isset($files_to_sideload) || empty($files_to_sideload)){
$files_to_sideload = array();
}
//if not the form with fields to encode, just return the unaltered value without checking the fields
@zackkatz
zackkatz / fix-checkboxes.php
Created May 17, 2016
Use UTF-8 checkmark instead of Dashicon .dashicons-yes icon font
View fix-checkboxes.php
<?php
add_filter( 'gravityview_field_tick', 'convert_gravityview_field_tick' );
/**
* Convert <span> to ✓
* @param string $existing_tick HTML span with `dashicons dashicons-yes` class
* @return string HTML entity checkmark character (✓)
*/
function convert_gravityview_field_tick( $existing_tick ) {
View pagination for GravityView
/**
* Get single entry pagination links
* to use: call anagram_entry_pagintion();
*
*/
function anagram_entry_pagintion() {
global $gravityview_view;
$criteria['paging'] = array(
'offset' => 0,
@stevenschobert
stevenschobert / load_remote_content_mail_dot_app.scpt
Last active Mar 31, 2021
Apple Script to click the "Load Remote Content" button. I like to disable all remote content in Mail.app, and then bind this script to a keyboard shortcut using Keyboard Maestro. https://www.keyboardmaestro.com
View load_remote_content_mail_dot_app.scpt
tell application "System Events" to tell process "Mail"
set mainWindow to a reference to the first window
set rootSplitter to a reference to the first splitter group of the mainWindow
set firstSplitter to a reference to the last splitter group of the rootSplitter
set scrollArea to a reference to the last scroll area of the firstSplitter
set scrollGroup to a reference to the first group of the scrollArea
if number of groups of the scrollGroup is greater than 1 then
set maybeRemoteContentGroup to a reference to the first group of the scrollGroup
@gmazzap
gmazzap / AutoPaginatedQuery.php
Last active Apr 8, 2016
`WP_Query` subclass that takes a non-paginated query and split into different paginated queries offering a transparent interface to "standard loop" usage.
View AutoPaginatedQuery.php
<?php
namespace GM;
/**
* `WP_Query` subclass that takes a non-paginated query and split into different
* paginated queries offering a transparent interface to "standard loop" usage.
*
* The class is not 100% transparent:
* - the var `$posts` and the method `get_posts()`, that are not used directly
* in standard loop usage, here don't return array of all posts, but only posts