Skip to content

Instantly share code, notes, and snippets.

@dieu
dieu / Dockerfile
Last active May 22, 2025 00:54
Home Assistant Docker on Mac OS
FROM homeassistant/home-assistant:stable
# Install avahi-daemon in container
# https://gnanesh.me/avahi-docker-non-root.html
RUN set -ex \
&& apk --no-cache --no-progress add avahi avahi-tools dbus \
# Disable default Avahi services
&& rm /etc/avahi/services/* \
&& rm -rf /var/cache/apk/*
import UIKit
import PlaygroundSupport
protocol WaterfallLayoutDelegate: AnyObject {
    func numberOfColumns() -> Int
    func columnsSize(at indexPath: IndexPath) -> CGSize
    func columnSpace() -> CGFloat
}
final class WaterfallLayoutViewController: UIViewController, UICollectionViewDataSource {
@asoorm
asoorm / docker-compose-mongo-replicaset.yml
Created September 14, 2018 19:00
Mongo Replica Set docker compose
version: "3"
services:
mongo1:
hostname: mongo1
container_name: localmongo1
image: mongo:4.0-xenial
expose:
- 27017
ports:
- 27011:27017
@jcdickinson
jcdickinson / Readme.md
Last active May 28, 2025 07:43
Proof-of-work JS

POW?

[The idea isn't new.][1] It's a technique that asks the client to perform proof-of-work in order to increase the costs associated with spamming a website. For a single user the workload shouldn't be an issue at all, but a spammer (or indeed a brute-forcing hacker) might run into problems with being able to maintain a high throughput of requests. Validating the proof of work is trivially computational and hence will not put your server under the same amount of stress.

POWJS on my laptop takes 17 seconds to solve the problem in Chrome (50 seconds in IE 11) with 22 bits required to be zero. The workload can be started as soon as the user opens the page and will run asyncronously in the background (in a web worker if the browser supports them).

POWJS uses CryptoJS, but won't pollute your global namespace with it. This can't be used (as-is) to farm bitcoins or what-have-you, it merely performs a random POW.

Usage