Skip to content

Instantly share code, notes, and snippets.

View vralle's full-sized avatar

Vitaliy Ralle vralle

View GitHub Profile
@vralle
vralle / config.rb
Last active August 29, 2015 14:05
Run Compass with Autoprefixer and make minifed version CSS with CSSO
require "compass"
# Require any additional compass plugins here.
require "autoprefixer-rails"
require "csso"
# Set this to the root of your project when deployed:
http_path = "../"
css_dir = "css"
sass_dir = "_sass"
images_dir = "images"
@vralle
vralle / CSS3-Spinner.markdown
Created October 8, 2014 16:29
A Pen by Vitaliy Ralle.
@vralle
vralle / gist:f4c3872a5996969b4f5e
Last active August 29, 2015 14:12
Remove Akismet js
<?php
// Remove Akismet js
function vralle_remove_akismet_script () {
remove_action( 'comment_form', array( 'Akismet', 'load_form_js' ) );
}
if ( ! is_admin() && ( defined( 'AKISMET_VERSION' ) || function_exists( 'akismet_http_post' ) ) ) {
add_action( 'wp_enqueue_scripts', 'vralle_remove_akismet_script' );
}
@vralle
vralle / admin.js
Last active November 23, 2015 17:01
Insert embed image as Shortcode by WP Media
// ### Convert an HTML-representation of an object to a string.
function myHTML() {
// Save default function
var defaultHTML = wp.html.string;
// image intercept
wp.html.string = function( options ) {
// If image, send new function
if( 'img' === options.tag ) {
return shortcake.html( options );
}
@vralle
vralle / img-shortcode.php
Last active December 12, 2015 00:56
Image Shortcode: Return images with WP markup
<?php namespace Vralle\Plugin\Shortcode\Img;
/*-------------------------------------------------------------------
* Register UI
*-----------------------------------------------------------------*/
function editor_ui() {
global $_wp_additional_image_sizes;
$default_sizes = [
@vralle
vralle / converter.php
Last active December 12, 2015 21:49
Convert images to Shortcode
<?php namespace Vralle\Plugin\Shortcode\Img;
/*-------------------------------------------------------------------
* Convert images to Shortcode
*-----------------------------------------------------------------*/
function html_to_shortcode( $content ) {
// Returns, if content is empty
if( empty( $content ) ) return $content;
if( 'content_save_pre' === current_filter() )
@vralle
vralle / amp-images-map.php
Last active February 10, 2019 19:40
A map of amp images output:
/**
* Single image
* @link https://ampbyexample.com/components/amp-img/
*/
$single_image = array(
'element' => 'amp-img',
'attributes' => array(),
);
/**
@vralle
vralle / Bootstrap Modal and popover with Velocity.js animation.markdown
Created July 15, 2015 16:36
Bootstrap Modal and popover with Velocity.js animation
@vralle
vralle / method-1.php
Last active January 31, 2022 23:11
The SEO Framework - Exclude WooCommerce account pages from SEO and Sitemap
<?php
/**
* Stop each TSF meta output.
*/
add_filter( 'the_seo_framework_sitemap_hpt_query_args', 'vralle_no_sitemap' );
add_filter( 'the_seo_framework_articles_data', 'vralle_no_article_json' );
add_filter( 'the_seo_framework_robots_meta_array', 'vralle_no_search_robots_meta' );
add_filter( 'the_seo_framework_use_og_tags', 'vralle_no_meta' );
add_filter( 'the_seo_framework_use_facebook_tags', 'vralle_no_meta' );
add_filter( 'the_seo_framework_use_twitter_tags', 'vralle_no_meta' );
@vralle
vralle / array_iteration_thoughts.md
Created June 4, 2022 22:35 — forked from ljharb/array_iteration_thoughts.md
Array iteration methods summarized

Array Iteration

https://gist.github.com/ljharb/58faf1cfcb4e6808f74aae4ef7944cff

While attempting to explain JavaScript's reduce method on arrays, conceptually, I came up with the following - hopefully it's helpful; happy to tweak it if anyone has suggestions.

Intro

JavaScript Arrays have lots of built in methods on their prototype. Some of them mutate - ie, they change the underlying array in-place. Luckily, most of them do not - they instead return an entirely distinct array. Since arrays are conceptually a contiguous list of items, it helps code clarity and maintainability a lot to be able to operate on them in a "functional" way. (I'll also insist on referring to an array as a "list" - although in some languages, List is a native data type, in JS and this post, I'm referring to the concept. Everywhere I use the word "list" you can assume I'm talking about a JS Array) This means, to perform a single operation on the list as a whole ("atomically"), and to return a new list - thus making it mu