Skip to content

Instantly share code, notes, and snippets.

@yumyo
yumyo / index.html
Created May 15, 2019 10:21
simple-landing
<div class="img"></div>
<div class="hatch"></div>
@yumyo
yumyo / post-receive
Last active May 17, 2019 17:24
WP Dev/Test/Live ENV post-receive hook #devops
# The PROD directory
PROD="/var/www/main.domain/"
# The TEST directory
TEST="/var/www/test.domain/"
# The DEV directory
DEV="/var/www/dev.domain/"
# A temporary directory for deployment
TEMP="/home/[server_user]/temp-deploy/"
# The Git repo
REPO="/home/[server_user]/git-domain-bare/"
<?php
/*
The MIT License (MIT)
Copyright (c) 2015 Twitter Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@yumyo
yumyo / WP Objects
Created July 4, 2018 13:05
List of WP Objects structure (WP_Post, WP_Post_Type, WP_Term)
WP_Post Object
(
[ID] => 50491
[post_author] => 520
[post_date] => 2016-10-18 19:00:46
[post_date_gmt] => 2016-10-18 18:00:46
[post_content] =>
[post_title] => Home
[post_excerpt] =>
[post_status] => publish
@yumyo
yumyo / gist:89d34fffe3e862ba13ed98556e4ad1f9
Created January 31, 2018 12:32
WP The Grid item output
(
[ID] => 2849
[date] => 1505489663
[post_type] => post
[sticky] =>
[format] => image
[url] => http://mysite/mypost
[url_target] => _self
[title] => Lorem Ipsum is not simply random text.
[excerpt] => Contrary to popular belief, Lorem Ipsum is not simply random text.
@yumyo
yumyo / what-forces-layout.md
Created October 9, 2017 07:35 — forked from paulirish/what-forces-layout.md
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.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@yumyo
yumyo / translate-service
Created August 14, 2017 11:23
WordReference as a Service AppleScript
on run {input, parameters}
set phrase to input as string
set phrase to quoted form of phrase
set from_lang to "en"
set to_lang to "it"
do shell script "open 'https://www.wordreference.com/'" & from_lang & to_lang & "'/'" & phrase
end run
@yumyo
yumyo / SCSS.md
Created July 19, 2017 16:23 — forked from jareware/SCSS.md
Advanced SCSS, or, 16 cool things you may not have known your stylesheets could do

⇐ back to the gist-blog at jrw.fi

Advanced SCSS

Or, 16 cool things you may not have known your stylesheets could do. I'd rather have kept it to a nice round number like 10, but they just kept coming. Sorry.

I've been using SCSS/SASS for most of my styling work since 2009, and I'm a huge fan of Compass (by the great @chriseppstein). It really helped many of us through the darkest cross-browser crap. Even though browsers are increasingly playing nice with CSS, another problem has become very topical: managing the complexity in stylesheets as our in-browser apps get larger and larger. SCSS is an indispensable tool for dealing with this.

This isn't an introduction to the language by a long shot; many things probably won't make sense unless you have some SCSS under your belt already. That said, if you're not yet comfy with the basics, check out the aweso

@yumyo
yumyo / wp-meta_cache.php
Last active June 21, 2017 13:27
An alternative to transient and object-cache
$cache_key = '_ssr-schedule';
$cache = get_post_meta( $frag_ID, $cache_key, true );
if ( empty( $cache ) || $cache['expires'] < time() ) {
$var = '[path]';
$url = '[path]' . $var;
$request = wp_remote_get( $url, array( 'timeout' => 120, ) );
if( is_wp_error( $request ) ) { return false; }
$response = wp_remote_retrieve_body( $request );
$data = json_decode( $response, true ); // `true` translate into an array instead of an object
@yumyo
yumyo / archive-conditionals.php
Created June 6, 2017 09:49 — forked from allysonsouza/archive-conditionals.php
WordPress Archive Title conditionals to correct display
<?php
function archive_title() {
//Conditionals to Title Display in WordPress Archive Templates
if( is_archive() ) {
$queried_object = get_queried_object();
if( is_tag() ) {
$slug = $queried_object ? $queried_object->slug : ' ' ;