Skip to content

Instantly share code, notes, and snippets.

View Mofect's full-sized avatar

Mofect Mofect

View GitHub Profile
async function getProductById(id) {
const handle = (await fetch(`/search/suggest.json?q=id:${id}&resources[type]=product&limit=1`)
.then(response => response.json())
.then(response => response.resources.results.products.shift())).handle;
return await fetch(`/products/${handle}.js`).then(response => response.json());
}
const product = await getProductById(2083844620358);
@m4vr0x
m4vr0x / Network_Initialization_Failed
Created March 29, 2021 03:33
Parallels - Fix for "Network Initialization Failed"
1) Close Parallels completely
2) In Terminal, type : sudo nano /Library/Preferences/Parallels/network.desktop.xml (this will open the Terminal text editor "nano")
3) Type your admin password to access the file
4) Locate this line <usekextless>-1</usekextless> it could be also value 1 and replace whatever value there with 0, so you should have <usekextless>0</usekextless>
5) Press Ctrl+O to ask for a save, then Ctrl+X to close the editor
In Terminal, type : sudo nano /Library/Preferences/Parallels/dispatcher.desktop.xml
find <usb>0</usb> and change 0 to 1
again Press Ctrl+O to ask for a save, then Ctrl+X to close the editor
6) Close Terminal and open Parallels like normal, your VM should load like on Catalina and before
@callaginn
callaginn / ajax-contact-form.js
Last active May 3, 2024 16:38
Shopify Ajax Contact Form
// Before implementing this, you'll need to contact Shopify support and ask them to turn off Google's ReCaptcha
// for your Shopify store's contact forms. Otherwise, it will redirect to the captcha's verification page.
// Retrieves input data from a form and returns it as a JSON object:
function formToJSON(elements) {
return [].reduce.call(elements, function (data, element) {
data[element.name] = element.value;
return data;
}, {});
}
@jazibsawar
jazibsawar / delete_custom_post_type.php
Created October 2, 2017 12:28
WordPress $wpdb: Delete all posts of a custom post type with its associated meta data (taxonomies, post meta) using SQL query & $wpdb
<?php
function delete_custom_posts($post_type = 'post'){
global $wpdb;
$result = $wpdb->query(
$wpdb->prepare("
DELETE posts,pt,pm
FROM wp_posts posts
LEFT JOIN wp_term_relationships pt ON pt.object_id = posts.ID
LEFT JOIN wp_postmeta pm ON pm.post_id = posts.ID
WHERE posts.post_type = %s

Scrolleo

Apple has been creating some amazing scrolling video sites lately and I've been trying to create a simplified plugin to recreate this effect. This is the alpha version of this plugin. You can see an example of the effect I'm recreating here: http://www.apple.com/macbook/

This uses requestAnimationFrame and allows you to create multiple custom scrolling videos easily.

A Pen by Mark Teater on CodePen.

License.

@goblindegook
goblindegook / wordpress.nginxconf
Last active February 14, 2023 21:05
Nginx virtual host configuration for WordPress
server {
listen 80;
server_name www.example.com;
rewrite ^ $scheme://example.com$request_uri?;
}
server {
listen 80;
server_name example.com;
// Get The Page ID You Need
get_option( 'woocommerce_shop_page_id' );
get_option( 'woocommerce_cart_page_id' );
get_option( 'woocommerce_checkout_page_id' );
get_option( 'woocommerce_pay_page_id' );
get_option( 'woocommerce_thanks_page_id' );
get_option( 'woocommerce_myaccount_page_id' );
get_option( 'woocommerce_edit_address_page_id' );
get_option( 'woocommerce_view_order_page_id' );
get_option( 'woocommerce_terms_page_id' );
@boogah
boogah / .htaccess
Created February 16, 2012 04:59
Expire headers .htaccess code.
<IfModule mod_expires.c>
ExpiresActive on
# Perhaps better to whitelist expires rules? Perhaps.
ExpiresDefault "access plus 1 month"
# Data
ExpiresByType text/xml "access plus 0 seconds"
ExpiresByType application/xml "access plus 0 seconds"
ExpiresByType application/json "access plus 0 seconds"