Skip to content

Instantly share code, notes, and snippets.

View Moriort's full-sized avatar
🏠
Working from home

Moriort

🏠
Working from home
View GitHub Profile
var minimumDeviation = function(nums) {
nums.sort((a,b) => a - b)
let diff = nums[nums.length-1] - nums[0]
let diffExt = nums[0] !== nums[nums.length-1]
let canOperate = nums[0] % 2 !== 0 || nums[nums.length-1] % 2 === 0
while (diffExt && canOperate && diff > 1) {
console.log(nums, diff)
let oper = false
if (nums[0] % 2 !== 0) {
oper = true
@Moriort
Moriort / README.md
Created January 15, 2023 19:57 — forked from chrisvanpatten/README.md
WordPress Admin Tabs

Huh?

Believe it or not, WordPress doesn't have a fully-fleshed out common tab style for plugins or theme authors to use in metaboxes.

The style exists for categories, but it hasn't been fully adapted for the half-complete wp-tab setup. Trac ticket #17959 has a solution that not only fleshes the style but it also adds a global JavaScript file to give the wp-tab HTML some action. Until that ticket is accepted into core, this Gist adapts that code so it's available to use independently in your theme or plugin.

How?

Just enqueue the CSS and JavaScript in the admin_enqueue_scripts script hook and drop the tab HTML in a metabox. It will automatically adapt to the normal and side column widths, much like category tabs.