Skip to content

Instantly share code, notes, and snippets.

View ajgagnon's full-sized avatar
💻
typing some things

Andre Gagnon ajgagnon

💻
typing some things
View GitHub Profile
@ernsheong
ernsheong / access-mac-localhost-from-parallels-desktop-ie-edge.md
Last active January 24, 2024 00:30
Accessing macOS localhost from Parallels Desktop IE or Edge

Access macOS localhost from IE or Edge within Parallels Desktop

This issue is so infuriating that I'm going to take some time to write about it.

  1. MOST IMPORTANT. Your local development server must be bound to IP address 0.0.0.0. Some do this by default, but many don't. You need to make sure that you run your local server with correct IP bindings. You may need to provide additional flags to your serve commands e.g. polymer serve --hostname domain.local, hugo serve --bind 0.0.0.0. If you use a named domain like domain.local, it has to be defined in /etc/hosts and pointing at 0.0.0.0.

  2. My Parallels setting is using Shared Network, nothing special there.

  3. Open macOS Terminal and type ifconfig. Look for the value under vnic0 > inet. It is typically 10.211.55.2.

@mgibbs189
mgibbs189 / functions.php
Last active November 6, 2018 14:54
Add images to radio facets
<?php
add_filter( 'facetwp_facet_html', function( $output, $params ) {
if ( 'my_facet' == $params['facet']['name'] ) {
$output = '';
$values = (array) $params['values'];
$selected_values = (array) $params['selected_values'];
foreach ( $values as $result ){
$clean_val = esc_attr( $result );
$selected = in_array( $result['facet_value'], $selected_values ) ? ' checked' : '';
@ahmadawais
ahmadawais / upload-a-file.MD
Created June 18, 2017 11:07 — forked from websupporter/upload-a-file.MD
Upload a file using the WordPress REST API

Upload files

Using the REST API to upload a file to WordPress is quite simple. All you need is to send the file in a POST-Request to the wp/v2/media route.

There are two ways of sending a file. The first method simply sends the file in the body of the request. The following PHP script shows the basic principle:

@bekarice
bekarice / wc-add-order-item-meta-to-rest-response.php
Created December 28, 2016 20:18
Example: Add order item meta to WC REST API
<?php // only copy if needed
/**
* Example: Add order meta to the REST API
* WC 2.6+
*
* @param \WP_REST_Response $response The response object.
* @param \WP_Post $post Post object.
* @param \WP_REST_Request $request Request object.
* @return object updated response object
@hdf
hdf / string_score_closest.js
Last active July 6, 2018 15:14
Extension project for: https://github.com/joshaven/string_score/ adding functionality to find closest matches. See: https://github.com/joshaven/string_score/issues/28
// Extension project for: https://github.com/joshaven/string_score/
// See: https://github.com/joshaven/string_score/issues/28
/**
* Gives back an array of indexes of the unique closest matches,
* on a string array to a string.
* 'Hello World'.closest(['el', 'll', 'o', 'll']); //=> [ 0, 1 ]
*/
String.prototype.closest = function(words, fuzziness, one2many) {
'use strict';