Skip to content

Instantly share code, notes, and snippets.

View gwerbin's full-sized avatar
💭
I might be slow to respond.

Greg Werbin gwerbin

💭
I might be slow to respond.
View GitHub Profile
@gwerbin
gwerbin / kbdpad_mk2.json
Created March 23, 2020 14:37
KBDPad VIA files
{
"name": "KBDPAD-MKII",
"vendorId": "0xA103",
"productId": "0x0006",
"lighting": "qmk_backlight_rgblight",
"matrix": {
"rows": 6,
"cols": 4
},
"layouts": {
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import sys
from time import perf_counter
import numpy as np
import torch
import torch.nn.functional as F
from sklearn.datasets import make_classification
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelBinarizer
from tqdm import tqdm
@gwerbin
gwerbin / sparse_column_indices.py
Created September 26, 2019 02:46
Get the column indices out of a sparse array
import numpy as np
from scipy import sparse
x = np.array([
[1, 0, 1],
[0, 0, 1],
[1, 1, 0],
[0, 1, 1]
])
@gwerbin
gwerbin / classes.md
Last active August 27, 2019 19:35
Classes in Python

In Python, an object is a container that holds pieces of data called "attributes". Each attribute has a name.

For example, if you have an object saved in the person variable, writing person.name retrieves the value held in the name attribute.

A class is the "type" of a particular object. An object is an "instance" of a class.

# Create the simplest possible class
class Person:
 pass
@gwerbin
gwerbin / ideas.md
Last active July 31, 2019 23:30
Freenode #python gets frustrated on a Sunday afternoon and rewrites Python.

Freenode #python rewrites Python

Text

The str class should represent a sequence of grapheme clusters, not codepoints. This should lead to less-surprising behavior when working with non-ASCII text.

NOTE: After some more discussion with other individuals, this might be too computationally intensive for "normal" use. It would be better to have a separate set of functions for working with grapheme clusters. How does it work in Swift?

Constructor

@gwerbin
gwerbin / poc.py
Created June 30, 2019 15:26
A more-correct implementation of PriorityQueue
import argparse
import asyncio
import random
import sys
import time
import priorityqueue
PRIORITY_HIGH = 3
@gwerbin
gwerbin / longest_ordered_substring.py
Last active June 8, 2019 02:55
Find the longest ordered substring in a string
from typing import Sequence, Tuple, TypeVar
from typing_extensions import Protocol
class SupportsGT(Protocol):
def __gt__(self, other):
...
T = TypeVar('T', bound=SupportsGT)

Installation:

pip install cython  # required in order to build the Cython extension
pip install ./
@gwerbin
gwerbin / keyboard-mounts.txt
Created April 7, 2019 15:27
Keyboard mounting styles
Legend
# case
$ screw
- plate
~ pcb
¦ line so you can see where the screws go
Top mount