Skip to content

Instantly share code, notes, and snippets.

View oksushi's full-sized avatar

Cal Wilson oksushi

View GitHub Profile
@dominikwilkowski
dominikwilkowski / README.md
Last active March 9, 2020 05:16 — forked from evangs/delete-old-files.js
Batch delete old files from Slack

Batch delete old file from your slack workspace

Freeing space

To free up some space in your slack workspace and having to delete each file by hand

To run the app you first need a legacy token from slack for your workspace. Then download the cleanSlack.js file and run it via Node.js.

By default the script will delete files older than a year. You can change that in the TIMESTAMP variable.

@svaustin66
svaustin66 / show-discount-code.liquid
Last active May 21, 2022 20:04
Display the Cookie stored discount code on Shopify Pages
<div id="discount-message"></div>
<script type="text/javascript">
var codeCookieValue;
var getCookie = function(name) {
var value = "; " + document.cookie;
var parts = value.split('; '+name+'=');
if (parts.length == 2) return parts.pop().split(";").shift();
};
codeCookieValue = getCookie('discount_code');
@nepsilon
nepsilon / how-to-batch-convert-jpg-images-to-progressive-jpg-images.md
Last active April 3, 2024 16:55
How to batch convert JPG images to progressive JPG images? — First published in fullweb.io issue #82

How to batch convert JPG images to progressive JPG images?

Progressive JPG images, as opposed to baseline JPG, will display right away in the browser, and will load bits of it in cycle, rendering it from blur to clear.

Progressive is known to provide a better user experience, preventing the ”fax loading” effect. Where the image is displayed in full, but sequentially from top to bottom.

The imagemagick package will install the convert command that you can run to convert JPG to progressive:

convert -strip -interlace Plane -quality 80 input-file.jpg output-file.jpg
@stewartknapman
stewartknapman / _shopify_add_free_product.md
Last active March 19, 2021 13:30
Automagically add a free product to the customers cart when they purchase a certain product(s)

We want to automagically add a free product to the customers cart when they purchase a certain product(s).

Note: This code will likely need to be adapted to suit your theme, however it should be enough to discribe the concept.

Add the free product

  1. Define the free product and which products can add it. We create some theme setting that allow us to pick the free product and a collection of products that can add it. e.g. settings.free-product and settings.free-product-collection
@dominikwilkowski
dominikwilkowski / README.md
Last active October 19, 2020 03:52
Ubuntu setup with NGINX http/2 and letsencrypt

Intro

This is a basic collection of things I do when setting up a new headless ubuntu machine as a webserver. Following the steps below should give you a reasonable secure server with HTTP/2 support (including ALPN in chrome) and the fast NGINX server. I am happy to add things so leave a comment.

Basics

After creating the server (droplet on DigitalOcean) log in with

// intrinsic.scss ------------------------
// An Intrinsic Ratio Component
// From http://daverupert.com/2015/12/intrinsic-placeholders-with-picture/
// ---------------------------------------
.intrinsic {
// Make sure <picture> wrapper is set to block
// Max-width is governed by parentNode
display: block;
@paulirish
paulirish / what-forces-layout.md
Last active May 17, 2024 18:01
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@dominikwilkowski
dominikwilkowski / navigation.liquid
Last active October 13, 2016 07:19
Jekyll automatic page navigation
{% comment %}
This snippet spits out the HTML navigation derived from the front matter settings in your markdown files.
https://gist.github.com/dominikwilkowski/c7d916c9b36e4eebbc90
Usage:
{% include navigation.liquid %}
Return:
HTML direct output
@chrisgrabinski
chrisgrabinski / shopify-auto-currencies-switcher.js
Last active January 16, 2023 20:04
(Shopify) Automatically change a shop's currency based on the customer's geolocation
// Dependencies
// - https://github.com/carolineschnapp/currencies
// Don't change currency if Cookie has been already set
if (Currency.cookie.read() == null) {
jQuery.ajax( {
url: '//freegeoip.net/json/',
type: 'GET',
dataType: 'jsonp',
@dominikwilkowski
dominikwilkowski / Gruntfile.js
Last active August 29, 2015 14:06
Basic grunt setup
'use strict';
/*******************************************************************************************************
*
* FOLDER STRUCTURE
*
* dev // files in root just move to ./prod/ and *.html files will look for grunt-includes directives
* ├── HTMLincludes // HTML snippets included by grunt-includes
* │ └── windows.html
* ├── fonts // files will simply be moved to ./prod/fonts/