Skip to content

Instantly share code, notes, and snippets.

@treetrum
treetrum / previous-next-post-looped.php
Last active August 25, 2021 10:30
Get Next or Previous Post (Looped). Will continue working once end of posts reached.
<?php
/**
* Gets the next post in the current post type, even if is last post
* Inspired from https://gist.github.com/banago/5603826
*
* @method get_next_post_looped
* @return WordPress Post Object
*/
function get_next_post_looped() {
$post_type = get_post_type();
@monkeymonk
monkeymonk / Notice.php
Last active December 17, 2020 09:53
Wordpress Admin Notice Helper Class #wordpress
<?php
/**
* Helper to work with Wordpress admin notices
*
* @example
* Notice::success('All is good!');
*
* @example
* Notice::warning('Do something please.', true);
@fabricelejeune
fabricelejeune / Efficient font stack with Sass.md
Last active March 16, 2023 23:52
Efficient font stack with Sass

Efficient font stack with Sass

The strength of Sass is the mixins and functions. Being able to automate many of the repetitive coding for CSS is both amazing in building and maintaining a clean and efficient code. I often find many developers creating complex systems for simple tasks, such as managing a font stack. This can be tedious to set up and employ. In this article, I will explain how I automate this system.

The font stack is one of those problems which are often solved by simple variables. In this instance, it makes a lot of sense and is easy enough to work with. But when you work with our (beloved) designers from Dogstudio, you can be sure of having to use lot of font variants. It quickly happens that I do not remember all the properties of each variants. And when I say "use lot of font variants", I mean at least 15 in most cases.

Sass maps to the rescue

Instead of simply define variables, I will ceate a font stack map and a mixin to use the map easily.

@ghaiklor
ghaiklor / iterm-fish-fisherman-meslo-osx.md
Last active December 5, 2022 11:14
iTerm 2 + fish + fisherman + Material Design + Meslo
@squarism
squarism / iterm2.md
Last active May 27, 2024 17:04
An iTerm2 Cheatsheet

Tabs and Windows

Function Shortcut
New Tab + T
Close Tab or Window + W (same as many mac apps)
Go to Tab + Number Key (ie: ⌘2 is 2nd tab)
Go to Split Pane by Direction + Option + Arrow Key
Cycle iTerm Windows + backtick (true of all mac apps and works with desktops/mission control)
@paulirish
paulirish / what-forces-layout.md
Last active May 26, 2024 09:59
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@lkwdwrd
lkwdwrd / Customfile
Created September 15, 2015 02:20
VVV Customfile for Hyper-V compatibility
# Hyper-V only overrides
config.vm.provider :hyperv do |v, override|
# Update memory and CPUs to match VVV config.
v.memory = 1024
v.cpus = 1
# Use a Hyper-V compatible base box
override.vm.box = "ericmann/trusty64
# Change all the folder to use SMB instead of Virtual Box shares
@jtsternberg
jtsternberg / colliding.js
Last active October 31, 2022 18:43 — forked from JayWood/colliding.js
Detect if two elements are colliding/overlapping
/**
* Detects if two elements are colliding
*
* Credit goes to BC on Stack Overflow, cleaned up a little bit
*
* @link http://stackoverflow.com/questions/5419134/how-to-detect-if-two-divs-touch-with-jquery
* @param $div1
* @param $div2
* @returns {boolean}
*/
@IceCreamYou
IceCreamYou / percentile.js
Last active November 17, 2022 01:54
Utility functions to calculate percentiles and percent ranks in a JavaScript array.
// Returns the value at a given percentile in a sorted numeric array.
// "Linear interpolation between closest ranks" method
function percentile(arr, p) {
if (arr.length === 0) return 0;
if (typeof p !== 'number') throw new TypeError('p must be a number');
if (p <= 0) return arr[0];
if (p >= 1) return arr[arr.length - 1];
var index = (arr.length - 1) * p,
lower = Math.floor(index),
@lonekorean
lonekorean / gist:1b9a17bbf235a7557a0e
Created June 10, 2015 20:39
Checkbox trickery, ordering with flexbox
.items {
display: flex;
flex-direction: column;
}
.done {
order: 1;
}
input:checked + label {