Skip to content

Instantly share code, notes, and snippets.

View iairose's full-sized avatar

iairose iairose

View GitHub Profile
@iairose
iairose / ubuntu-nextjs-nginx-config-file
Created December 17, 2022 13:13 — forked from oelbaga/01 - Setup Nextjs site on Ubuntu Server - Terminal commands
Setup NextJS app on Digital Ocean Ubuntu server Full Terminal Commands Step by Step
#nginx config file for Nextjs App
#place in /etc/nginx/sites-available/name_of_config_file
server {
listen 80;
server_name domainname.com;
gzip on;
gzip_proxied any;
gzip_types application/javascript application/x-javascript text/css text/javascript;
gzip_comp_level 5;
@iairose
iairose / mk-jwt-token
Created October 6, 2022 12:20 — forked from briceburg/mk-jwt-token
mk-jwt-token -- bash shell script for generating JWT tokens. requires `openssl` and `base64` which you have.
#!/usr/bin/env bash
#
# usage: JWT_SECRET="silly" mk-jwt-token
# @WARN: modify the payload and header to your needs.
#
main(){
set -eo pipefail
[ -n "$JWT_SECRET" ] || die "JWT_SECRET environment variable is not set."
<script
src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>
<script>
var cartCount = {{ cart.item_count }};
$(document)
.ready(function() {
jQuery.getJSON('/cart.js', function(cart) {
items = cart.items;
var results = items.filter(x => x.id === 6223106801703);
if ((results.length == 0) && (items.length > 0)) {
jQuery.post('/cart/add.js', {
quantity: 1,
id: 6223106801703
});
location.reload();
@iairose
iairose / shopify-add-to-cart
Created March 8, 2022 06:48 — forked from lucased/shopify-add-to-cart
Shopify - Add product to cart automatically
if (typeof Shopify === 'undefined') var Shopify = {};
Shopify.cart = {{ cart | json }};
Shopify.toAdd = 378589397;
var surchargeInCart = false;
var total = 2507; // total in cents.
for (var i=0; i<Shopify.cart.items.length; i++) {
if (Shopify.cart.items[i].id === Shopify.toAdd) {
surchargeInCart = true;
total -= Shopify.cart.items[i].line_price;
@iairose
iairose / product-image-srcset.liquid
Created September 2, 2021 09:29 — forked from zacwasielewski/product-image-srcset.liquid
Shopify responsive product images with srcset. Picturefill-compatible.
{% comment %}
Shopify responsive product images with srcset.
Example:
Include this snippet on a product page or within a products loop:
{% include 'product-image-srcset',
sizes: '(max-width: 640px) 50vw, (min-width: 641px) and (max-width: 960px) 33vw, 25vw' %}
@iairose
iairose / jquery.shopify-ajax-cart.js
Created August 22, 2021 11:11 — forked from schmoove/jquery.shopify-ajax-cart.js
A handy jQuery plugin for updating the Shopify Cart via their AJAX API
/*
* Project: Shopify AJAX Cart Plugin
* Description: Provides AJAX cart functionality for interacting with the Shopify AJAX API so you don't need an "Update Cart" button
* Dependency: jQuery 1.6+
* Author: Ryan Marshall (ryan@schmoove.co.nz)
* License: Free
* Usage:
*
* $('#cart-form').shopifyAJAXCart({
* item: '.line-item-container',
@iairose
iairose / shopify-money.js
Created August 13, 2021 21:57 — forked from stewartknapman/shopify-money.js
The Shopify.formatMoney method extracted from option_selection.js for stand-alone purposes.
var Shopify = Shopify || {};
// ---------------------------------------------------------------------------
// Money format handler
// ---------------------------------------------------------------------------
Shopify.money_format = "${{amount}}";
Shopify.formatMoney = function(cents, format) {
if (typeof cents == 'string') { cents = cents.replace('.',''); }
var value = '';
var placeholderRegex = /\{\{\s*(\w+)\s*\}\}/;
var formatString = (format || this.money_format);