Skip to content

Instantly share code, notes, and snippets.

View troyanvic's full-sized avatar

Troyan Vic troyanvic

View GitHub Profile
@bschwartz757
bschwartz757 / async.js
Last active November 15, 2023 03:23
Async/await function to fetch data from multiple URLs in parallel
/* Client side, works in Chrome 55 and Firefox 52 without transpilation */
//https://blogs.msdn.microsoft.com/typescript/2016/11/08/typescript-2-1-rc-better-inference-async-functions-and-more/
async function fetchURLs() {
try {
// Promise.all() lets us coalesce multiple promises into a single super-promise
var data = await Promise.all([
/* Alternatively store each in an array */
// var [x, y, z] = await Promise.all([
// parse results as json; fetch data response has several reader methods available:
//.arrayBuffer()
@claudiosanches
claudiosanches / functions.php
Created November 8, 2016 14:14
WooCommerce - Saving new "My account" registration fields
<?php
/**
* Save the extra register fields.
*
* @param int $customer_id Current customer ID.
*/
function wooc_save_extra_register_fields( $customer_id ) {
if ( isset( $_POST['billing_first_name'] ) ) {
// WordPress default first name field.
update_user_meta( $customer_id, 'first_name', sanitize_text_field( $_POST['billing_first_name'] ) );