Skip to content

Instantly share code, notes, and snippets.

View kmmbvnr's full-sized avatar
💭
#StopPutin #StopWar

Mikhail Podgurskiy kmmbvnr

💭
#StopPutin #StopWar
View GitHub Profile
@gpulido
gpulido / autocomplete.component.html
Created March 1, 2020 12:47
mockup for a mdc autocomplete component
<div #surfaceAnchor mdcMenuSurfaceAnchor (click)="onClick($event)">
<ng-content (keydown)="onKeydown($event)" select="mdc-text-field"></ng-content>
<ng-content select="mdc-menu"></ng-content>
</div>
@tinkerology
tinkerology / RoundedCube.scad
Created February 17, 2020 05:56
Create a cube with rounded sides
$fn=60;
// Answer from: https://stackoverflow.com/users/1320888/cutetare
// https://stackoverflow.com/questions/33146741/way-to-round-edges-of-objects-openscad/33289349#33289349
module roundedcube(xx, yy, height, radius) {
difference(){
cube([xx,yy,height]);
@davidbegin
davidbegin / measure_memory.py
Created January 21, 2020 03:43
Measure Memory usage of functions with a decorator
# Stolen from: https://medium.com/survata-engineering-blog/monitoring-memory-usage-of-a-running-python-program-49f027e3d1ba
print("\33c")
import tracemalloc
def measure_memory(func):
tracemalloc.start()
@pirate
pirate / django_turbo_response.py
Last active November 21, 2022 21:12
An extended HTTPResponse class for Django 2.2 adding support for streaming partial template responses incrementally, preload headers, HTTP2 server push, CSP headers, running post-request callbacks, and more (fully typed).
"""
This is an extended HTTP response class for Django >=2.0 that adds lots of fancy features.
It's most useful when needing to accellerate slow view functions that return templates,
but it can be used anywhere where you need to return an HTTPResponse() or render(...).
It works by subclassing the builtin Django HttpResponse and StreamingHttpResponse,
and adding improvements in many areas, including functionality, speed, and security.
The most up-to-date version of this code can be found here:
@disintegrator
disintegrator / https-during-dev.macos.sh
Last active April 23, 2024 22:41
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 {
@franktopel
franktopel / HTMLBaseElement.md
Last active August 25, 2023 12:03
HTMLBaseElement class solving the problem of connectedCallback being called before children are parsed

There is a huge practical problem with web components spec v1:

In certain cases connectedCallback is being called when the element's child nodes are not yet available.

This makes web components dysfunctional in those cases where they rely on their children for setup.

See WICG/webcomponents#551 for reference.

To solve this, we have created a HTMLBaseElement class in our team which serves as the new class to extend autonomous custom elements from.

@pierre-pretorius
pierre-pretorius / turbolinks_local_storage.js
Last active November 14, 2019 12:56
Store turbolinks cache in window.localStorage
@dedsm
dedsm / timescale--db--backend--base.py
Last active April 24, 2024 14:15
WeRiot Django Timescale integration
import logging
from django.contrib.gis.db.backends.postgis.base import \
DatabaseWrapper as PostgisDBWrapper
from django.db import ProgrammingError
from .schema import TimescaleSchemaEditor
logger = logging.getLogger(__name__)
@hopsoft
hopsoft / prefetch.js
Last active December 27, 2023 02:45
Turbolinks Prefetching
const hoverTime = 400
const fetchers = {}
const doc = document.implementation.createHTMLDocument('prefetch')
function fetchPage (url, success) {
const xhr = new XMLHttpRequest()
xhr.open('GET', url)
xhr.setRequestHeader('VND.PREFETCH', 'true')
xhr.setRequestHeader('Accept', 'text/html')
xhr.onreadystatechange = () => {
@sj26
sj26 / sidekiq.service
Last active July 4, 2023 19:20 — forked from dsadaka/\lib\systemd\system\sidekiq-static.service
systemd unit files for multiple sidekiq workers
[Unit]
Description=Sidekiq workers
# start as many workers as you want here
Wants=sidekiq@1.service
Wants=sidekiq@2.service
# ...
[Service]
Type=oneshot
ExecStart=/bin/true