Skip to content

Instantly share code, notes, and snippets.

def get_grid_points(self, mask_arr: np.ndarray, pad_ratio: int = 50) -> np.ndarray:
"""
Returns a grid of points that are in the foreground of the given binary mask.
The padding between points in the grid is adjusted based on the size of the mask.
Parameters:
- mask: A 2D binary numpy array, where 1 represents foreground and 0 represents background.
- pad_ratio: Scaling factor (divisor) used to compute the padding between points in the grid. Larger values result in smaller padding.
@cip8
cip8 / Docker-Compose-As-Service.md
Last active November 30, 2022 10:11 — forked from Luzifer/README.md
Running docker-compose as a systemd service

Running docker-compose as a systemd service

Files

File Purpose
/etc/compose/docker-compose.yml Compose file describing what to deploy
/etc/systemd/system/docker-compose-reload.service Executing unit to trigger reload on docker-compose.service
/etc/systemd/system/docker-compose-reload.timer Timer unit to plan the reloads
/etc/systemd/system/docker-compose.service Service unit to start and manage docker compose
@cip8
cip8 / IPv4-IPv6-domain-regex.go
Created October 19, 2022 19:21 — forked from ahmetozer/IPv4-IPv6-domain-regex.go
Ipv4 - IPv6 - domain Regex Golang
ipv6_regex := `^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$`
ipv4_regex := `^(((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4})`
domain_regex := `^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]$`
match, _ := regexp.MatchString(ipv4_regex+`|`+ipv6_regex+`|`+domain_regex, host)
if match {
fmt.Println("Input is valid")
} else {
fmt.Println("Given input does not match")
re

Keybase proof

I hereby claim:

  • I am ciprian-cimpan on github.
  • I am ciprian42 (https://keybase.io/ciprian42) on keybase.
  • I have a public key ASAFJVuXrpaYfsFfCKnC-2Bg9Hn1SA0HbI5_u1BkwRzOdwo

To claim this, I am signing this object: