Skip to content

Instantly share code, notes, and snippets.

@hayes0724
hayes0724 / lazy-image.liquid
Last active January 3, 2022 20:25
Shopify lazysizes image
{%- comment -%}
Lazyload/Lazysizes responsive image snippet
Author: Eric Hayes
Version: 2.3
-------------------------------------
Requires:
image: {Obect} image object setting variable
Accepts:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
{% assign found_title = false %}
{% for item in checkout.line_items %}
{% if item.variant.id == 7387208286253 %}
{% assign found_title = true %}
{% endif %}
{% endfor %}
{% if checkout.subtotal_price > 10000 and found_title == false %}
<script>
@mikowl
mikowl / oneliners.js
Last active June 29, 2024 17:39
👑 Awesome one-liners you might find useful while coding.
// Inspired by https://twitter.com/coderitual/status/1112297299307384833 and https://tapajyoti-bose.medium.com/7-killer-one-liners-in-javascript-33db6798f5bf
// Remove any duplicates from an array of primitives.
const unique = [...new Set(arr)]
// Sleep in async functions. Use: await sleep(2000).
const sleep = (ms) => (new Promise(resolve => setTimeout(resolve, ms)));
// or
const sleep = util.promisify(setTimeout);
@adriennetacke
adriennetacke / countdown.js
Last active September 1, 2022 04:18
Countdown timer in pure JavaScript
function countdown(endDate) {
let days, hours, minutes, seconds;
endDate = new Date(endDate).getTime();
if (isNaN(endDate)) {
return;
}
setInterval(calculate, 1000);
@ayamflow
ayamflow / gist:b602ab436ac9f05660d9c15190f4fd7b
Created May 9, 2016 19:10
Safari border-radius + overflow: hidden + CSS transform fix
// Add on element with overflow
-webkit-mask-image: -webkit-radial-gradient(white, black);
@freakdesign
freakdesign / blog-atom.liquid
Last active October 19, 2021 21:48
Shopify RSS atom feed
{% layout none %}{% comment %}
/*
* Simple blog feed
*
* Copyright (c) 2015 Jason Bowman (jason@freakdesign.com.au)
* Licensed under the MIT license:
* http://www.opensource.org/licenses/mit-license.php
*
*/
{% endcomment %}<?xml version="1.0" encoding="UTF-8"?>
@addyosmani
addyosmani / README.md
Last active July 24, 2024 10:54 — forked from 140bytes/LICENSE.txt
108 byte CSS Layout Debugger

CSS Layout Debugger

A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.

One-line version to paste in your DevTools

Use $$ if your browser aliases it:

~ 108 byte version

@ludder
ludder / grunt-git-hooks
Created May 20, 2014 07:45
Copy git hooks to hooks folder with Grunt
grunt.registerTask('default', function () {
var fs = require('fs');
// my precommit hook is inside the repo as /hooks/pre-commit
// copy the hook file to the correct place in the .git directory
grunt.file.copy('hooks/pre-commit', '.git/hooks/pre-commit');
// chmod the file to readable and executable by all
fs.chmodSync('.git/hooks/pre-commit', '755');
});
@shemul49rmc
shemul49rmc / Add Custom Content After All WordPress Posts
Last active December 31, 2015 05:39
Add Custom Content After All WordPress Posts
/**
* Add Custom Content After All WordPress Posts By http://goo.gl/ht6fZo
*/
function add_after_post_content($content) {
if(!is_feed() &#038;& !is_home() &#038;& is_singular() &#038;& is_main_query()) {
$content .= '<p>YOUR CONTENT AFTER POST</p>';
}
return $content;
}
add_filter('the_content', 'add_after_post_content');
@ajfisher
ajfisher / twitter-fix.md
Last active March 1, 2018 06:42
CSS fixes to Twitter web client to remove all the inline previews

Twitter Web Client Inline Image Removal

If you're a heavy user of the Twitter web client like me then you'll find the new inline preview feature extremely intrusive as it breaks up the timeline too much. If I wanted to use facebook or linkedin then I'd be using facebook or linkedin. Having said that, cards in Twitter are great and the ability to preview media before jumping off site is really cool - but it should be my choice, not have everything foisted on my timeline.

That the mobile client allows for this with a setting is even more annoying.

So here's the fix. This only works in Chrome but I'm sure an enterprising person could do something similar for Safari and Firefox using the same CSS. Pull requests to update instructions for other browsers are of course very welcome.

Updates