Skip to content

Instantly share code, notes, and snippets.

View vincentorback's full-sized avatar
🌻

Vincent Orback vincentorback

🌻
View GitHub Profile
.Grid {
--Grid-cell-width: 5em; /* Change this */
--Grid-gutter: 0.5em;
display: flex;
flex-wrap: wrap;
margin: calc(var(--Grid-gutter) * 0.5);
}
.Grid > * {
@vincentorback
vincentorback / image-sizes.php
Created March 15, 2018 14:22
Update and force image sizes in WordPress
<?php
add_action( 'switch_theme', function ()
{
update_option('thumbnail_size_w', 500);
update_option('thumbnail_size_h', 500);
update_option('thumbnail_size_cropt', 0);
update_option('medium_size_w', 1000);
update_option('medium_size_h', 1000);
@vincentorback
vincentorback / makegif.sh
Last active May 12, 2017 10:23
Make high quality gif
# Usage:
# <movie_file> <start_time> <duration> <output_name>
# ./makegif.sh movie.mp4 00:00 10 output.gif
#
# Check if ffmpeg is installed
if ! which ffmpeg >/dev/null; then
printf "\n\033[0;31mYou need to install ffmpeg to use this! Visit: https://ffmpeg.org/download.html\033[0m\n\n"
exit 1
fi
@vincentorback
vincentorback / levenshtein.js
Last active April 6, 2017 10:50
Levenshtein Distance
var levDist = function(s, t) {
var d = []; //2d matrix
// Step 1
var n = s.length;
var m = t.length;
if (n == 0) return m;
if (m == 0) return n;
:root {
--font-bold: 600;
}
html {
height: 100%;
box-sizing: border-box;
}
*,
export function randomHex() {
return '#' + (Math.random() * 0xFFFFFF << 0).toString(16)
}
@vincentorback
vincentorback / hideIdleCursor.js
Last active March 4, 2017 12:49
hideIdleCursor.js
const targetEl = document.querySelector('.js-target')
const hideMouse = false
const idleTime = 3000
let idleMouseTimer
targetEl.addEventListener('mousemove', (e) => {
if (!hideMouse) {
targetEl.style.cursor = ''
clearTimeout(idleMouseTimer)
@vincentorback
vincentorback / object-fit-cover-polyfill.js
Last active February 21, 2017 14:17
Replace object-fit elements with a div using background-size: cover
/*
Demo:
http://codepen.io/vincentorback/pen/ZLLJbB
*/
export function objectFit (el) {
let objectElReplacement = `<div
class="${el.classList}"
style="
background-image:url(${el.getAttribute('src')});
@vincentorback
vincentorback / duplicate-posts.php
Last active January 18, 2017 19:30
Adds and action in the WordPress admin to duplicate pages and posts
<?php
/**
* Function creates post duplicate as a draft and redirects then to the edit post screen
*/
function duplicate_post_as_draft() {
global $wpdb;
if (!(isset($_GET['post']) || isset($_POST['post']) || (isset($_REQUEST['action']) && 'duplicate_post_as_draft' == $_REQUEST['action']))) {
wp_die('No post to duplicate has been supplied!');
@vincentorback
vincentorback / getScrollPosition.js
Created January 8, 2017 11:36
getScrollPosition.js
/**
* Get scroll position
* @param {Object} rootElement
* @return {Object}
*/
export function getScrollPosition (rootElement) {
return {
y: rootElement ? rootElement.scrollTop : window.pageYOffset,
x: rootElement ? rootElement.scrollLeft : window.pageXOffset
}