Skip to content

Instantly share code, notes, and snippets.

View pszemraj's full-sized avatar

Peter pszemraj

View GitHub Profile
@steven2358
steven2358 / ffmpeg.md
Last active May 15, 2025 12:51
FFmpeg cheat sheet
@MichaelPolla
MichaelPolla / github-resize-pictures.md
Last active July 5, 2024 21:21
Markdown - Resize pictures in GitHub, including in comments comment

Markdown - Resize pictures in GitHub

I found that the "best" way is to use HTML, as it works both in Readme/.md files and also in comments (within Issues, Gist...)

E.g. when adding/editing a comment (within Issues, Gist...) :

  • Upload the picture by drag-and-drop in the text field
  • replace ![image](https://your-image-url.type) with <img src="https://your-image-url.type" width="100" height="100">

As mentioned by @cbestow (thanks!), it's not mandatory to set both width and height. If only one is set, the other will be adjusted accordingly to preserve the aspect ratio of the image.

@simonw
simonw / how-to-upgrade-heroku-postgresql.md
Last active May 3, 2025 15:45
How to upgrade a Heroku PostgreSQL database to a new plan

How to upgrade a Heroku PostgreSQL database to a new plan

I started a project on a Hobby Dev plan (free, limit 10,000 rows), and then later needed to upgrade it to Hobby Basic ($9/month, limit 10,000,000 rows).

After assigning the new database, I had two databases attached to the application. They looked something like this:

  • HEROKU_POSTGRESQL_OLIVE (postgresql-dimensional-3321) Old, free-tier (Hobby Dev) database
@noelbundick
noelbundick / LICENSE
Last active March 30, 2025 13:12
Exclude WSL installations from Windows Defender realtime protection
MIT License
Copyright (c) 2018 Noel Bundick
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
furnished to do so, subject to the following conditions:
@thomwolf
thomwolf / gradient_accumulation.py
Last active November 23, 2024 20:53
PyTorch gradient accumulation training loop
model.zero_grad() # Reset gradients tensors
for i, (inputs, labels) in enumerate(training_set):
predictions = model(inputs) # Forward pass
loss = loss_function(predictions, labels) # Compute loss function
loss = loss / accumulation_steps # Normalize our loss (if averaged)
loss.backward() # Backward pass
if (i+1) % accumulation_steps == 0: # Wait for several backward steps
optimizer.step() # Now we can do an optimizer step
model.zero_grad() # Reset gradients tensors
if (i+1) % evaluation_steps == 0: # Evaluate the model when we...
@finiteautomata
finiteautomata / run_mlm_big_text_files.py
Created August 3, 2021 12:54
Train MLM with big text files (Workaround)
"""
This is a workaround for `examples/run_mlm.py` for pretraining models
with big text files line-by-line.
For the time being, `datasets` is facing some issues dealing with really
big text files, so we use a custom dataset until this is fixed.
August 3th 2021
Author: Juan Manuel Pérez
@pszemraj
pszemraj / AutoTA-Example.md
Last active January 1, 2022 03:40
HayStack Course Info Extractor - IML s21.ipynb

AutoTA Example

  • A series of transformer models that embed your course documents, search for them when you ask it a question, and construct a reply in coherent english using a text2text generator.
  • Based on the work done by deepset.ai in their Haystack library.
  • As the notebook preview does not always load on GitHub, click here for the Colab notebook / demo. Instructions are provided on what to edit to use the notebook both in simple cases (i.e. just changing the questions) to adapting the notebook for other purposes.

Example: The model's explanation of K-Means

question to model: What is the k-means algorithm?

@pszemraj
pszemraj / geospatial-example-valais-rasterio-sentinel-2.ipynb
Created August 22, 2021 23:19
Geospatial Example - Valais + Rasterio + Sentinel-2.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pszemraj
pszemraj / visual-analysis-via-umap-course-text-data.ipynb
Last active January 1, 2022 03:31
Visual Analysis via UMAP - Course Text Data
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pszemraj
pszemraj / dm1-2021hs-info-extraction-v2.ipynb
Created October 14, 2021 17:19
DM1-2021hs-info-extraction [v2].ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.