Skip to content

Instantly share code, notes, and snippets.

View milkbottlelough's full-sized avatar

Loughlin McSweeney milkbottlelough

View GitHub Profile
@milkbottlelough
milkbottlelough / youtube-video-thumbnail.liquid
Last active January 25, 2023 14:21 — forked from junaidkbr/youtube-video-thumbnail.liquid
Get Youtube video thumbnail from Youtube URL in Shopify Liquid
{% assign video_url = 'https://www.youtube.com/watch?v=R5jIoLnL_nE' %}
{% assign thumbnail_url = '' %}
{% assign video_id = video_url | split: '/' | last %}
{% assign video_id = video_id | split: '?' | last %}
{% assign video_id = video_id | split: 'v=' | last %}
{% if video_id != blank %}
{% assign thumbnail_url = 'http://img.youtube.com/vi/' | append: video_id | append: '/maxresdefault.jpg' %}
{% endif %}
@milkbottlelough
milkbottlelough / checkout-random-products.css
Created March 23, 2021 10:40 — forked from xxxdepy/checkout-random-products.css
Script for Random Products Add to Cart on Shopify Checkout Page
/*
* Add to Cart module for Checkout
*/
.checkout-add-cart-module {
padding: 0px;
background-color: transparent;
margin-top: 30px;
@milkbottlelough
milkbottlelough / Controller.php
Created January 15, 2021 09:31
Private function to get an S3 asset url using a presigned request
/**
* Get the url of an S3 file
* @param [string] $key [naem of the file object on S3 e.g. logs/thisismylog.txt]
* @return [string] url to the file
*/
private function getFileUrl($key) {
$s3 = Storage::disk('s3');
$client = $s3->getDriver()->getAdapter()->getClient();
$bucket = config("filesystems.disks.s3.bucket");
{
"bold_folder_labels": true,
"color_scheme": "Packages/Materialize/schemes/Material Stereokai.tmTheme",
"font_face": "Fira Code",
"font_options":
[
"gray_antialias",
"subpixel_antialias"
],
"font_size": 12,
@milkbottlelough
milkbottlelough / gist:1c0ec5c0c4eec51ca894b9e7e73d1f6e
Created May 15, 2020 10:03
Generate random number with Liquid (Shopify)
{% capture time_seed %}{{ 'now' | date: "%s" }}{% endcapture %}
{% assign random = time_seed | times: 1103515245 | plus: 12345 | divided_by: 65536 | modulo: 32768 | modulo: 10 %}
This will generate pseudo-random numbers beetween 0 and 9. If you need from 0 to 99, just adjust the last modulo to 100 instead of 10 (and 1000 if you need 0-999).
@milkbottlelough
milkbottlelough / gist:367edfdffb24430d3672b4b85d786dd8
Created May 11, 2020 14:52
Check if a product is in a particular collection (shopify)
{% assign found = false %}
{% for c in product.collections %}
{% if c.handle=='merchandise' %}
{% assign found = true %}
{% endif %}
{% endfor %}
{% if found %}
... do stuff ...
@milkbottlelough
milkbottlelough / custom.scss.liquid
Last active April 18, 2024 19:50
Klaviyo Custom Form Integration
/*------------------------------------------------
KLAVIYO signup form
------------------------------------------------*/
.klaviyo_styling{
max-width: none;
}
.klaviyo-form-wrap.klaviyo_form_actions {
text-align: left;
@milkbottlelough
milkbottlelough / gist:bb4d12d9e487081d21c842f0c431c171
Created April 2, 2020 11:28
Secure Checkout Button (with built in SVG lock!)
<style>
button.Cart__Checkout {
padding-left: 20px;
}
svg.checkout-lock {
height: 20px;
width: auto;
margin-left: 0;
@milkbottlelough
milkbottlelough / pagespeed.php
Created March 30, 2020 11:32 — forked from typhonius/pagespeed.php
A PHP script to look up and parse google pagespeed results.
<?php
$url = 'URL GOES HERE';
$key = 'KEY GOES HERE';
// View https://developers.google.com/speed/docs/insights/v1/getting_started#before_starting to get a key
$data = json_decode(file_get_contents("https://www.googleapis.com/pagespeedonline/v1/runPagespeed?url=$url&key=$key"));
$dat = $data->formattedResults->ruleResults;
foreach($dat as $d) {
$name = $d->localizedRuleName;
@milkbottlelough
milkbottlelough / custom.scss.liquid
Created March 27, 2020 11:49
CM commerce custom form styling - Shopify - (Mar2020)
.conversio-container-footer{
.rf-header h3 {
padding: 0 !important;
margin: 0 0 10px 0 !important;
border-top: 1px solid #ded9cf;
border-bottom: 1px solid #ded9cf;
line-height: 2.3;