Skip to content

Instantly share code, notes, and snippets.

View yratof's full-sized avatar
🍊
Eating an orange

Andrew yratof

🍊
Eating an orange
View GitHub Profile
@yratof
yratof / compare.js
Created May 31, 2016 09:28
ACF Compare dates to and from in repeating row, affect the row accordingly
jQuery( function( $ ) {
var update_row_colours = function() {
// Change [data-name="schedule"] to the corresponding acf group
jQuery('[data-name="schedule"] .acf-table .acf-row').each( function() {
var from = $( this ).find('[data-name="from"] input');
var to = $( this ).find('[data-name="to"] input');
var from_date = new Date( from.val() );
var to_date = new Date( to.val() );
var now = ( new Date() ).getTime();
/* Allow objects to extend past their boundries */
.overhang{
margin-left: calc(-50vw + 50%);
margin-right: calc(-50vw + 50%);
@at-root body{
overflow-x: hidden;
}
}
@yratof
yratof / wiggle.js
Created May 29, 2016 20:24
Single Axis Wiggling
x = transform.position[0]; // x.axis
y = transform.position[1]; // y.axis
w = wiggle( 3, 200 ); // Move ~200px 3 times per second
[w[0], y]; // Apply to X
@yratof
yratof / jitter.js
Created May 29, 2016 19:03
Jittery time in After Effects
n = 5; // play every 5th frame
m = 2; // play each frame twice
f = timeToFrames();
p = Math.floor( f / m );
framesToTime( p * n )
@yratof
yratof / love.svg
Last active May 27, 2016 07:44
Love thy code
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yratof
yratof / links.php
Created May 24, 2016 12:48
Woocommerce links
@yratof
yratof / remove_media.sh
Last active February 6, 2019 14:12
PNG JPG -> Wordpress remove all media generated by wordpress
# Go to your uploads folder
cd /wp-content/uploads
# Remove all images that wordpress created
find -E . -type f -iregex '.*[0-9]{2,3}x[0-9]{2,3}.*\.(jpg|jpeg|png|eps|gif)' -exec rm {} \;
# ZIP all original images incase things go wrong on this next bit
find . -type f | egrep -vi '.*[0-9]{2,3}x[0-9]{2,3}.*\.(jpg|jpeg|png|eps|gif)' | zip images.zip -@
# Convert what is left from png to jpg with white in place of transparency
@yratof
yratof / chip-ga.py
Last active May 7, 2016 18:52
C.H.I.P to GA
# Google analytics on the C.H.I.P
# Importing GPIO pins
import urllib2
import CHIP_IO.GPIO as io
pir_pin = "CSID0"
io.setup(pir_pin, io.IN)
def hitGA():
@yratof
yratof / run_these.sh
Created May 3, 2016 13:40
Fixing your C.H.I.P
wget https://dl.dropbox.com/u/8850924/fixpackage
chmod +x ./fixpackage
sudo ./fixpackage
@yratof
yratof / gist:9c6efef6764852d8794303ad725b9173
Last active May 22, 2016 13:58
No img? No problem. replace the src and srcset of the image with some white image in norwegian
jQuery( function( $ ) {
// No images? No problem.
// Replace source of missing images
$('img').error( function(){
// Show a nice white image @ 1440x1000 that is only 1kb
$(this).attr( 'src', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABaAAAAPoAQMAAAAStcuwAAAABlBMVEXu7u7h4eEQJSZcAAAFk0lEQVR4AezBgQAAAACAoP2pF6kCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgNmzbxg7diuM4x9xoKUj6RzHM32nksVgb185u76lSzpPsd7LC6Xupf6959p94U5HcOnQFw7HuRPoPIKvhiZnNq9zpID5KxBi9cPBEa9W+1fSuJVBqXmx0B1Kxy8W2qLU4z/buh4BL14a/6tW9B18A28DPoF85uMOgPflSyyXVab3b377gA3TtNUH4GNTJwYpdNLofHmQOtGUfjUhiU5iJ6BLu2hU4l1s9E70VCv6WerUr6N9OXYd0L35LKN/IcPY6HJZK1pOtWLfkvQ6oCMZDAWOdxs9X1a60wUbXKPEUUBmOptPQaPD0KhaJ809BbgeMsxoduYc7Vy9aFfQDtErRqO4N8SIGV0ua0bfGbPP04x2RkWc1I3el/XYFPQuzejGqoQN1z3p4CikC3TZaey4iwU91IpW7Gj/uzLUL7+GZadhhcbqd/oel9fDA8tOAxF99Tt9r7zT8QzdWMCjKehe1bvTBd0qGQqaynqcoxuqeT3CYEkchXnShuC3M7rTNU+aR53kWIdlp4ljnHfapop3ev/HkSbp0vJ6WJVkNxa0nipej336Fg5iJyzvtEq8iQWtxjrRpMKHFE7fBYga