Skip to content

Instantly share code, notes, and snippets.

View petercossey's full-sized avatar

Peter Cossey petercossey

View GitHub Profile
@petercossey
petercossey / pick-list-prices.html
Created June 27, 2023 02:09
Render catalog price for products in a pick-list option modifier using client-side Storefront GraphQL API
{{#partial "page_bottom"}}
<script>
// Get product IDs for GraphQL query on product prices.
const pickListProductIds = []
{{#each product.options}}
{{#if partial '===' 'product-list'}}
pickListProductIds.push({{pluck values 'data'}})
{{/if}}
{{/each}}
@petercossey
petercossey / get-a-cart-async.js
Last active September 8, 2022 21:26
Javascript snippet for loading a cart in a BigCommerce Stencil environment
const storefrontCartUrl = "https://peters-everything-store.mybigcommerce.com/api/storefront/carts"
const getCart = async (url) => {
try {
const response = await fetch(url, {
"method": "GET",
"headers": {
"Content-Type": "application/json"
}});
const json = await response.json();
return json;
@petercossey
petercossey / findAndDeleteCart.js
Created July 5, 2022 04:22
Script you can execute on a BigCommerce Stencil storefront to delete existing cart for current session.
const myStorefrontUrl = "http://my-storefront.com"
findAndDeleteCart(myStorefrontUrl);
function findAndDeleteCart(storefrontUrl) {
fetch(storefrontUrl + "/api/storefront/carts", {
"method": "GET",
"headers": {
"Content-Type": "application/json"
}
})
@petercossey
petercossey / chia-plotter-madmax-c5ad.8xlarge.txt
Created June 19, 2022 08:52
Chia plotter log using madmax on an AWS EC2 c5ad.8xlarge instance
chia plotters madmax -r 24 -t /mnt/fastdisk1 -2 /mnt/fastdisk2 -d /home/ubuntu/chia-plots -f <farmer-public-key> -c <pool-contract-address>
Multi-threaded pipelined Chia k32 plotter - 2092041
Network Port: 8444
Final Directory: /home/ubuntu/chia-plots/
Number of Plots: 1
Crafting plot 1 out of 1 (2022/06/19 06:28:02)
Process ID: 2186
Number of Threads: 24
Number of Buckets P1: 2^8 (256)
Number of Buckets P3+P4: 2^8 (256)
@petercossey
petercossey / bigcommerce-widget-template-schema-example.json
Last active May 15, 2022 06:02
Completed example of custom widgets template schema
[
{
"type": "tab",
"label": "Content",
"sections": [
{
"label": "Product cards",
"settings": [
{
"type": "boolean",
@petercossey
petercossey / browserGameTick.js
Last active June 1, 2021 08:09
Game loop for web browsers using requestAnimationFrame
tick(); // start the game loop.
function tick() {
requestAnimationFrame(tick); // this will create the loop
// add functions/expressions which need to be in the game loop here.
}
// add game objects + code here.

Keybase proof

I hereby claim:

  • I am petercossey on github.
  • I am petercossey (https://keybase.io/petercossey) on keybase.
  • I have a public key ASCMOfde1I0sGduLMPWLc-WWEvkBIMTJXCV11cDgO0zoxwo

To claim this, I am signing this object:

@petercossey
petercossey / ctewls.module
Last active June 25, 2018 02:11
Drupal 7 Ctools modal example
<?php
/**
* @file
* Ctewls module
*/
/**
* Implementation of hook_menu().
*/
function ctewls_menu() {
@petercossey
petercossey / ubuntu-powerline-install.md
Last active July 12, 2022 12:44
Powerline font install for Ubuntu 16.10 (also confirmed working for 17.04, 17.10, 18.04, 19.10)

Install Powerline fonts for Z shell

Please note: there is an APT package called "fonts-powerline" which is tested and working for Ubuntu 20.04 which achieves the same outcome. Try "sudo apt install fonts-powerline"

If you're using Z Shell and a special prompt theme designed with Powerline fonts in mind, you'll need to install them on your machine. These are the most clear and cut-down instructions that I've found to work with Ubuntu 16.10 (also confirmed working for 17.04, 17.10, 18.04, 19.10) and all credit goes to renshuki's Ubuntu 14.04 + Terminator + Oh My ZSH with Agnoster Theme gist. I've extracted just the Powerline font instructions - my personal setup uses Prezto instead of Oh My ZSH (not included here).

Get the font and config files

cd ~
@petercossey
petercossey / sublime.desktop
Created January 23, 2015 02:31
Sublime Text desktop shortcut
# paste the following content into sublime.desktop
[Desktop Entry]
Version=1.0
Name=Sublime Text 2
GenericName=Text Editor
Exec=sublime
Terminal=false
Icon=/opt/Sublime Text 2/Icon/48x48/sublime_text.png
Type=Application
Categories=TextEditor;IDE;Development