Skip to content

Instantly share code, notes, and snippets.

@jet10000
jet10000 / https-during-dev.macos.sh
Created October 3, 2022 13:52 — forked from disintegrator/https-during-dev.macos.sh
Use Caddy, mkcert and dnsmasq to expose your development server over HTTPS
brew install caddy mkcert nss dnsmasq
mkcert -install
mkcert '*.app.test' '*.cdn.test'
# rename the certs and move them under /usr/local/etc/caddy/certs
cat <<EOF > /usr/local/etc/caddy/Caddyfile
*.app.test:443, *.cdn.test:443 {
@0187773933
0187773933 / ClipboardImageToB64String.py
Last active October 29, 2022 05:57
Converts Clipboard Image to HTML Base64 String Image
#!/usr/bin/env python3
import os
import time
import subprocess
from PIL import ImageGrab , Image
from pathlib import Path
import io
import codecs
import tempfile
import pyperclip
@HeinrichWizardKreuser
HeinrichWizardKreuser / fileresponseutils.py
Created August 2, 2021 09:51
Django FIleResponse helpers
from django.http import FileResponse
from io import BufferedReader, BytesIO
def file_response_from_str(content: str, filename: str) -> FileResponse:
""" Serves a file response from the given string
Args:
content: str
@hadanischal
hadanischal / charles-proxy-android.md
Created July 14, 2021 05:38 — forked from twaddington/charles-proxy-android.md
How to set up Charles Proxy for the Android Emulator.

Charles Proxy Android

Steps

1. Add the Network Security Configuration to your app

<network-security-config>
   <debug-overrides>
 
@lbatteau
lbatteau / sse-fastapi-redis.py
Last active February 21, 2025 05:19
Server-Sent Events in FastAPI with async Redis Pub/Sub
from aioredis import Channel, Redis
from fastapi import FastAPI
from fastapi.params import Depends
from fastapi_plugins import depends_redis, redis_plugin
from sse_starlette.sse import EventSourceResponse
from starlette.responses import HTMLResponse
html = """
<!DOCTYPE html>
<html>
@eduardoflorence
eduardoflorence / main.dart
Last active February 18, 2025 17:55
Getx - Sample Form
import 'package:flutter/material.dart';
import 'package:get/get.dart';
void main() {
runApp(GetMaterialApp(
initialRoute: '/login',
getPages: [
GetPage(
name: '/login',
page: () => LoginPage(),
@cweedall
cweedall / waitress (gunicorn alternative) in Python (for Windows OS)
Last active April 26, 2024 08:39
`waitress` / `waitress-serve` is `gunicorn` alternative for Python-based WSGI web app (like Django) on Windows
# Run a WSGI web app (like Django) on Windows
# see: https://stackoverflow.com/a/48542020/7363740
# Install if necessary
conda install waitress
pip install waitress
# Replace standard `gunicorn` command with `waitress-serve`
# for example: gunicorn --listen=*:8000 myapp.wsgi:application
waitress-serve --listen=*:8000 myapp.wsgi:application
@joshnuss
joshnuss / Clock.svelte
Last active January 16, 2022 09:54
A Svelte store that acts as a clock/interval timer
<script>
import timer from './timer.js'
// create clock that updates every 500ms
const clock = timer({interval: 500})
</script>
<!-- Expression will update every 500ms -->
Current time is: {$clock}
@sassman
sassman / App.svelte
Last active February 21, 2023 22:19
Timer in svelte
<script>
let s = 0;
let m = 0;
let active = false;
let timer;
function setActive(a) {
active = a;
if(!active) {
clearInterval(timer)
@terryupton
terryupton / page.twig
Created April 5, 2020 18:34
Ajax Request using alpineJS
<button
@click="showModal = !showModal | fetch('{{ entry.url() }}', {
headers: {
'Content-Type': 'application/json',
'X-Requested-With': 'XmlHttpRequest'
},
}).then(res => res.text()).then(text => { html = text })"
class="flex justify-center animate-grow-on-hover--small"
>