Skip to content

Instantly share code, notes, and snippets.

HarshTrivedi /
Last active May 11, 2024 19:28 — forked from Tushar-N/
Minimal tutorial on packing (pack_padded_sequence) and unpacking (pad_packed_sequence) sequences in pytorch.
import torch
from torch import LongTensor
from torch.nn import Embedding, LSTM
from torch.autograd import Variable
from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence
## We want to run LSTM on a batch of 3 character sequences ['long_str', 'tiny', 'medium']
# Step 1: Construct Vocabulary
# Step 2: Load indexed data (list of instances, where each instance is list of character indices)
MFreidank /
Last active October 16, 2023 13:36
A pytorch DataLoader that generates an unbounded/infinite number of minibatches from the dataset.
from import DataLoader
class InfiniteDataLoader(DataLoader):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Initialize an iterator over the dataset.
self.dataset_iterator = super().__iter__()
def __iter__(self):
martinruenz /
Last active November 15, 2022 06:39
ffmpeg snippets / cheatsheet
mbinna /
Last active May 16, 2024 02:57
Effective Modern CMake

Effective Modern CMake

Getting Started

For a brief user-level introduction to CMake, watch C++ Weekly, Episode 78, Intro to CMake by Jason Turner. LLVM’s CMake Primer provides a good high-level introduction to the CMake syntax. Go read it now.

After that, watch Mathieu Ropert’s CppCon 2017 talk Using Modern CMake Patterns to Enforce a Good Modular Design (slides). It provides a thorough explanation of what modern CMake is and why it is so much better than “old school” CMake. The modular design ideas in this talk are based on the book [Large-Scale C++ Software Design](

rosshadden /
Created May 12, 2017 14:18
Mixed non/HiDPI monitors in X
#!/usr/bin/env bash
numDisplays=$(xrandr --current | grep '\bconnected' | wc -l)
outputs="--output eDP1 --primary --mode 2880x1620 --pos 2880x0 --dpi 96 --scale 1x1"
xrandr --output HDMI1 --off
xrandr --output DP2 --off
if xrandr | grep "HDMI1 connected"; then
outputs+=" --output HDMI1 --auto --mode 1920x1080 --pos 0x0 --right-of eDP1 --scale 1.5x1.5"
bshillingford / arxiv2kindle.ipynb
Last active March 1, 2024 12:50
arxiv2kindle: recompiles an arxiv paper for kindle-sized screens, and sends it to your wifi-enabled kindle
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
bishboria /
Last active April 25, 2024 06:27
Springer made a bunch of books available for free, these were the direct links
wangkuiyi / pre-commit-clang-format
Last active August 19, 2021 14:04
Git pre-commit hook that invokes clang-format to reformat C/C++/Objective-C source code.
# git pre-commit hook that runs an clang-format stylecheck.
# Features:
# - abort commit when commit does not comply with the style guidelines
# - create a patch of the proposed style changes
# modifications for clang-format by
# This file is part of a set of unofficial pre-commit hooks available
# at github.
Lordnibbler /
Last active October 20, 2022 17:32
Sample Pull Request Template






A few sentences describing the overall goals of the pull request's commits.

Related PRs

jezen / Io Example Problems
Created December 15, 2013 13:17
The example problems have gone missing from the Io language website, so here’s a backup.
#Sample code
#Hello world
"Hello world!" print
factorial := method(n, if(n == 1, 1, n * factorial(n - 1)))
99 bottles of beer