Skip to content

Instantly share code, notes, and snippets.

View maciejkos's full-sized avatar
🐼

Maciej Kos maciejkos

🐼
View GitHub Profile
@dmelcer9
dmelcer9 / nice_index.py
Created December 19, 2024 20:03
A nice multi-level indexing function on tensors
def nice_index(tens: Tensor, index: Tensor) -> Tensor:
"""
A multi-level indexing function.
The last dimension of the index is a multi-level specifier
All other dimensions of the index are batch
For example, if the index is [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]
the result will be [[tens[1, 2], tens[3, 4]], [tens[5, 6], tens[7, 8]]]
See tests for more details
"""
@mattstibbs
mattstibbs / put_colon_in_offset.py
Created August 17, 2019 16:00
Add a colon to timezone offset when using datetime.strftime
import datetime
original_timestamp = datetime.datetime.now()
# Convert datetime object to a string representation
timestamp_string = original_timestamp.strftime("%Y-%m-%dT%H:%M:%S%z")
print(timestamp_string)
# OUTPUT: 2019-08-17T00:00:00+0000
# Add a colon separator to the offset segment
@SathyaBhat
SathyaBhat / gist:894012
Created March 30, 2011 07:36
Chrome extensions keyboard shortcut handler
/*
Right here's the thing - for keyPress events to be run, you'll have to make use of
content scripts. Content scripts handle things at webpage & DOM level. You'll have
to do changes to your manifest:
*/
------------------------
manifest.json:
------------------------
/*
Note: don't replace manifest.json, add the relevant changes else