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
# BASED ON @nmichlo's ISSUE AT: | |
# https://github.com/pytorch/pytorch/issues/60531 | |
# NOTE: modern features of torch and numpy make this easier to implement in python | |
# as modern one liners. | |
##### TORCH EXAMPLE ##### | |
# chunks = 3 | |
# dim = 0 | |
# tensor = torch.arange(7) |
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
# XTerm Control Sequences based on: | |
# - https://invisible-island.net/xterm/ctlseqs/ctlseqs.html | |
# ========================================================================= # | |
# XTerm Control Sequences from invisible-island.net as pythonic code. | |
# Basic control sequences are string variables. | |
# - eg: ESC = '\033' | |
# CSI = ESC + '[' | |
# Control sequences that have args can be called to return a string. | |
# - eg: sgr = CSI + Ps + 'm' |
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 | |
## - info@foo-games.com |
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
# Adapted from https://amitness.com/vscode-on-colab | |
# Copy this script into a colab cell | |
# install deps if needed | |
!(command -v "code-server" 1>/dev/null) || (curl -fsSL https://code-server.dev/install.sh | sh && echo) | |
!(python -c "import pyngrok" 2>/dev/null) || (pip install -qqq pyngrok) | |
# run vscode in background if needed | |
!(ps -ef|awk '/code-server/&&!/awk/{exit 1}') && (nohup code-server --port 9000 --auth none &) |
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
# check for available pypi synonyms of a given word | |
# $ available_pypi_synonyms.py <words...> | |
import argparse | |
import itertools | |
import re | |
import diskcache as dc | |
import requests | |
from bs4 import BeautifulSoup |
NewerOlder