Skip to content

Instantly share code, notes, and snippets.

View Kadreev's full-sized avatar
🚀
Reaching goals

Kadreev

🚀
Reaching goals
View GitHub Profile
@Kadreev
Kadreev / Shopify If Admin
Created March 5, 2022 16:54
Shopify if Admin
{% if content_for_header contains 'adminBarInjector' %}
{% endif %}
@Kadreev
Kadreev / svg placeholder
Created March 5, 2022 16:55
Responsive SVG Placeholder
data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 3 2'%3E%3C/svg%3E
@Kadreev
Kadreev / mem
Created March 5, 2022 16:55
Caching Memorization
const cache = {}; const myFunc = (input) => { if (cache[input]) { return cache[input]; }; console.log(`calculating...`); const value = input * 2; cache[input] = value; return value; }; myFunc(1); myFunc(2); myFunc(1);
@Kadreev
Kadreev / regex
Last active March 5, 2022 16:56
Find and replace all href=""
(?<=href=("|'))[^"']+(?=("|'))
@Kadreev
Kadreev / script
Created March 5, 2022 16:56
Shopify Box in post purchase page
<script> Shopify.Checkout.OrderStatus.addContentBox('<h2>Pick-up in store</h2>', '<p>We are open everyday from 9am to 5pm.</p>') </script>
@Kadreev
Kadreev / progress
Created March 14, 2022 10:42
progress percentage increase
const updateCount = (setProgress, progressPercent) => {
const target = parseInt(setProgress.getAttribute("data-done"));
const count = parseInt(progressPercent.innerText);
const increment = 1;
if (count < target) {
progressPercent.innerText = count + increment;
setTimeout(updateCount, 50);
} else if (count > target) {
progressPercent.innerText = count - increment;
@Kadreev
Kadreev / shopify.js
Created March 25, 2022 22:42
GLOBAL BINDING
/*
* Shopify Common JS
*
*/
if ((typeof window.Shopify) == 'undefined') {
window.Shopify = {};
}
Shopify.bind = function(fn, scope) {
return function() {
@Kadreev
Kadreev / button
Last active May 18, 2022 21:24
button #shopify
{% if settings.button_url %}
<a href="{{ settings.button_url }}" class="btn-red text-white font-bold rounded-full text-2xl mt-4 p-7 uppercase leading-3 w-full col-span-3">{{ settings.button_label }}</a>
{% endif %}
{
"type": "text",
"id": "button_label",
"label": "Button Label",
"default": "Shop Lifeboost"
@Kadreev
Kadreev / speed.js
Created June 6, 2022 08:04
Time the speed of functions
let i = 0;
console.time("While loop");
while (i < 100000) {
i++;
}
console.timeEnd("While loop");
console.time("For loop");
for (i = 0; i < 100000; i++) {
// For Loop
}
@Kadreev
Kadreev / permissions.file
Created June 6, 2022 10:54
update permissions
sudo chown -R boss /home/boss/DEV/vue-carte