Skip to content

Instantly share code, notes, and snippets.

@stlk
stlk / GET-product-feed.js
Created July 21, 2023 12:54
Heureka XML feed Shopify app build on gadget.dev
/**
* Route handler for GET hello
*
* @param { import("gadget-server").RouteContext } request context - Everything for handling this route, like the api client, Fastify request, Fastify reply, etc. More on effect context: https://docs.gadget.dev/guides/extending-with-code#effect-context
*
* @see {@link https://www.fastify.io/docs/latest/Reference/Request}
* @see {@link https://www.fastify.io/docs/latest/Reference/Reply}
*/
@stlk
stlk / admin.py
Last active January 23, 2023 16:50
Shopify-like product variants in Django
class ProductAdminForm(forms.ModelForm):
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
if self.instance.pk:
self.fields["option1"].queryset = self.instance.options.all()
class Meta:
model = Product
fields = "__all__"
@stlk
stlk / create_product.py
Last active January 3, 2022 10:54
How to generate a product with 100 variants
import shopify
from django.core.management.base import BaseCommand
from console.models import AuthAppShopUser
class Command(BaseCommand):
def add_arguments(self, parser):
parser.add_argument(
"myshopify_domain",
@stlk
stlk / celery_django_redis_ratelimit.py
Last active November 11, 2021 08:05 — forked from Vigrond/celery_django_redis_ratelimit.py
RQ / Django / Redis Rate Limiting
# Rate limiting with Python RQ + Django + Redis
# Multiple Fixed Windows Algorithm inspired by Figma https://www.figma.com/blog/an-alternative-approach-to-rate-limiting/
import functools
from typing import Callable
import django_rq
from rq import Retry
from django.utils import timezone
from datetime import timedelta
@stlk
stlk / main.py
Created May 15, 2021 10:59
fastapi background
from fastapi import BackgroundTasks, FastAPI
import aiohttp
import asyncio
app = FastAPI()
async def send_request():
async with aiohttp.ClientSession() as session:
async with session.get("https://httpdump.io/") as response:
{
"description": "Business number",
"states": [
{
"name": "Trigger",
"type": "trigger",
"transitions": [
{
"event": "incomingMessage"
},
diff --git a/snippets/ajax-cart-template.liquid b/snippets/ajax-cart-template.liquid
index 7f820eb..d49ebee 100644
--- a/snippets/ajax-cart-template.liquid
+++ b/snippets/ajax-cart-template.liquid
@@ -26,14 +26,16 @@ Use the raw liquid tags to keep the handlebar.js template tags as available hook
</ul>
<div class="cart-bottom">
<div class="buttons-container">
- <a href="/cart" class="minicart-button">{% endraw %}{{ 'cart.general.view_cart' | t }}{% raw %}</a>
+ <a href="/cart" class="minicart-button" style="width: 100%;">{% endraw %}{{ 'cart.general.view_cart' | t }}{% raw %}</a>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@stlk
stlk / lampa_barvy.ino
Last active January 22, 2018 14:16
my cool description
#include <Adafruit_NeoPixel.h>
#define PIN 1
#define WAIT 40
Adafruit_NeoPixel strip = Adafruit_NeoPixel(7, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin();
strip.setBrightness(255);
#include <Adafruit_NeoPixel.h>
#define PIN 1
#define WAIT 40
// pouzivame knihovnu Adafruit_NeoPixel pro komunikaci s diodou
Adafruit_NeoPixel strip = Adafruit_NeoPixel(1, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
// Zakladni nastaveni diody