Skip to content

Instantly share code, notes, and snippets.

View roose's full-sized avatar
🐢
Looking for a job

roose roose

🐢
Looking for a job
View GitHub Profile
@ivo-ivanov
ivo-ivanov / delete-acf-data-after-field-removal.php
Last active August 15, 2024 14:17
Delete all data from WP database when an ACF field is deleted. #wordpress #acf
/*Deleting content when an ACF field is deleted is easy, relatively. Please note that the use of this function cannot be undone and it will erase all traces of content for any ACF field that is deleted.
Please be sure that this is something that you want to do before implementing this and I would strongly suggest that this is only enabled during development and not on a live site. Should a client go into ACF for some reason and delete a field, there is nothing that you’d be able to do to recover form it. */
// this action is run by ACF whenever a field is deleted
// and is called for every field in a field group when a field group is deleted
add_action('acf/delete_field', 'delete_acf_content_on_delete_field');
function delete_acf_content_on_delete_field($field) {
// runs when acf deletes a field
//! v.1.2.1, http://ilyabirman.net/projects/emerge/
if (jQuery) {
!function($) {
$(function() {
/**
* @param {Element} obj
* @return {?}
*/
$.expr[":"].uncached = function(obj) {
if (!$(obj).is('img[src!=""]')) {
//! v.1.2.1, http://ilyabirman.net/projects/emerge/
jQuery&&(!function(t){t(function(){t.expr[":"].uncached=function(a){if(!t(a).is('img[src!=""]'))return!1;var e=new Image;return e.src=a.src,!e.complete};var a=[],e=500,i=!1,r=!1,o=["backgroundImage","borderImage","borderCornerImage","listStyleImage","cursor"],n=/url\(\s*(['"]?)(.*?)\1\s*\)/g,s=0,d=function(t,a,e,i,r){var o="emergeRotate"+ ++s;return'<div style="position: absolute; transition: opacity '+r+'ms ease-out"><div style="position: absolute; left: 50%; top: 50%; margin: -'+t+'px"><svg xmlns="http://www.w3.org/2000/svg" width="'+2*t+'" height="'+2*t+'"viewBox="0 0 24 24" style="-webkit-animation: '+o+" "+i+"ms linear infinite;animation: "+o+" "+i+'ms linear infinite"><path fill="'+a+'" d="M17.25 1.5c-.14-.06-.28-.11-.44-.11-.55 0-1 .45-1 1 0 .39.23.72.56.89l-.01.01c3.2 1.6 5.39 4.9 5.39 8.71 0 5.38-4.37 9.75-9.75 9.75S2.25 17.39 2.25 12c0-3.82 2.2-7.11 5.39-8.71v-.02c.33-.16.56-.49.56-.89 0-.55-.45-1-1-1-.16 0-.31.05-.44.11C2.9 3.43.25 7.4.25 12c0 6.4
@Tblue
Tblue / mozlz4a.py
Last active September 19, 2024 02:18
MozLz4a compression/decompression utility
#!/usr/bin/env python3
# vim: sw=4 ts=4 et tw=100 cc=+1
#
####################################################################################################
# DESCRIPTION #
####################################################################################################
#
# Decompressor/compressor for files in Mozilla's "mozLz4" format. Firefox uses this file format to
# compress e. g. bookmark backups (*.jsonlz4).
#
@lukehedger
lukehedger / ffmpeg-compress-mp4
Last active October 7, 2024 21:57
Compress mp4 using FFMPEG
$ ffmpeg -i input.mp4 -vcodec h264 -acodec mp2 output.mp4
@beshur
beshur / hsb.scss
Created November 14, 2014 09:45
Sass: HSB to HSL converter
// Simple HSB to HSL converter by Alexander Futekov (@futekov)
// http://www.sitepoint.com/hsb-colors-with-sass/
//
@function hsb($h-hsb, $s-hsb, $b-hsb, $a: 1) {
@if $b-hsb == 0 {
@return hsla(0, 0, 0, $a)
} @else {
$l-hsl: ($b-hsb/2) * (2 - ($s-hsb/100));
$s-hsl: ($b-hsb * $s-hsb) / if($l-hsl < 50, $l-hsl * 2, 200 - $l-hsl * 2);
@return hsla($h-hsb, $s-hsl, $l-hsl, $a);
@fabrizim
fabrizim / acf-customizer-patch.php
Last active January 17, 2024 02:30
Plugin to allow for Advanced Custom Fields to be used in widgets within the Customizer
<?php
/*
Plugin Name: ACF Customizer Patch
Plugin URI: https://gist.github.com/fabrizim/9c0f36365f20705f7f73
Description: A class to allow acf widget fields to be stored with normal widget settings and allow for use in customizer.
Author: Mark Fabrizio
Version: 1.0
Author URI: http://owlwatch.com/
*/
class acf_customizer_patch

Moved

Now located at https://github.com/JeffPaine/beautiful_idiomatic_python.

Why it was moved

Github gists don't support Pull Requests or any notifications, which made it impossible for me to maintain this (surprisingly popular) gist with fixes, respond to comments and so on. In the interest of maintaining the quality of this resource for others, I've moved it to a proper repo. Cheers!

@jtriley
jtriley / terminalsize.py
Created July 26, 2011 21:58
Get current terminal size on Linux, Mac, and Windows
#!/usr/bin/env python
import os
import shlex
import struct
import platform
import subprocess
def get_terminal_size():
""" getTerminalSize()
@bueltge
bueltge / post-process.php
Created June 24, 2011 21:08
WordPress Custom Post Type: Insert post via Frontend
<?php
/**
* post-process.php
* make sure to include post-process.php in your functions.php. Use this in functions.php:
*
* get_template_part('post-process');
*
*/
function do_insert() {
if( 'POST' == $_SERVER['REQUEST_METHOD']