This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"github.com/progrium/darwinkit/macos/coreml" | |
"github.com/progrium/darwinkit/macos/foundation" | |
"github.com/progrium/darwinkit/objc" | |
"log" | |
"unsafe" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Ansi 0 Color</key> | |
<dict> | |
<key>Alpha Component</key> | |
<real>1</real> | |
<key>Blue Component</key> | |
<real>0.066666670143604279</real> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# A bash script to update a Cloudflare DNS A record with the external IP of the source machine | |
# Used to provide DDNS service for my home | |
# Needs the DNS record pre-creating on Cloudflare | |
## Based on https://gist.github.com/Tras2/cba88201b17d765ec065ccbedfb16d9a with updates to use | |
## per-zone configurable access tokens available in the API sections of your Cloudflare profile | |
## - [email protected] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Benchmark of different python calls: | |
TL;DR: | |
- don't use dict(), dataclasses or namedtuples | |
- use {...}, [...], (...) | |
- tuples are fastest | |
- args are faster than kwargs for dataclasses and namedtuples | |
RESULTS: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
py3.8 - macbook pro 16-inch, 2019, 2.3 GHz 8-Core Intel Core i9, 16 GB 2667 MHz DDR4 | |
In memory benchmarks, working with 100_000 items at a time | |
SqlAlchemy - insert bulk: 1560.605ms | |
SqlAlchemy - select all: 1350.774ms | |
SqlAlchemy - insert singles: 7821.888ms | |
sqlite3 - insert singles: 140.412ms |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# MIT LICENSE | |
# Nathan Michlo | |
""" | |
Script to bypass rate limits for a GoogleDrive file | |
by creating an export job for the parent folder. | |
1. User manually specifies the file id of this parent folder | |
2. Script starts an export job for this folder | |
3. Script polls and waits for completion of the export job |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import lru_cache | |
from typing import Tuple | |
from typing import Union | |
import numpy as np | |
import torch | |
# ========================================================================= # |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ordered dithering generalised to n dims | |
# 2x2 example: | |
# ■ ■ | □ ■ | □ ■ | □ □ | □ □ | |
# ■ ■ | ■ ■ | ■ □ | ■ □ | □ □ | |
# ~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ | |
# MIT License | |
# | |
# Copyright (c) 2021 Nathan Juraj Michlo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@functools.lru_cache() | |
def dither_matrix(n: int): | |
assert isinstance(n, int) and (n > 0) | |
if n == 1: | |
return np.array([[0]]) | |
matrix = (1/n**2) * np.asarray(np.bmat([ | |
[n**2 * dither_matrix(int(n/2)) + 0, n**2 * dither_matrix(int(n/2)) + 2], | |
[n**2 * dither_matrix(int(n/2)) + 3, n**2 * dither_matrix(int(n/2)) + 1], | |
])) | |
matrix.flags.writeable = False # because we are caching this |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ | |
# MIT License | |
# | |
# Copyright (c) 2021 Nathan Juraj Michlo | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is |
NewerOlder