Skip to content

Instantly share code, notes, and snippets.

View Jakub3628800's full-sized avatar
:shipit:

Jakub Kriz Jakub3628800

:shipit:
View GitHub Profile
@Jakub3628800
Jakub3628800 / hello.py
Created October 25, 2025 07:06
Testing
print("hello world")
@Jakub3628800
Jakub3628800 / pre-commit.yaml
Created October 25, 2025 06:55
GitHub action to run pre-commit.
---
name: pre-commit
on: # yamllint disable-line rule:truthy
pull_request:
push:
branches: [master]
env:
SKIP: no-commit-to-branch # Disable the no-commit-to-branch hook in CI
@Jakub3628800
Jakub3628800 / pre-commit-autoupdate.yaml
Created October 25, 2025 06:36
GitHub action to periodically update pre-commit hook versions.
name: Auto-Update pre-commit Hooks
on:
schedule:
- cron: "0 0 * * 1"
workflow_dispatch:
permissions:
contents: write
pull-requests: write
@Jakub3628800
Jakub3628800 / make_commit.py
Created July 13, 2023 19:23
Create commit on github using github api
import requests
import argparse
import os
GH_USERNAME = "Jakub3628800"
GH_REPO = "repository123"
MAIN_BRANCH = "master"
auth_header = {
@Jakub3628800
Jakub3628800 / Example: Tuple unpacking
Created January 8, 2023 17:10
Example: Tuple unpacking
# Example 0: Unpack a tuple
weeks = ('monday', 'tuesday', 'wednesday')
first, second, third = weeks
print(first, second, third)
# monday tuesday wednesday
weeks = ('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday')
first, second, *other = weeks
print(first, second, other)
# monday tuesday ['wednesday', 'thursday', 'friday', 'saturday', 'sunday']
# Tuples can be defined with or without brackets
weekdays = "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"
print(weekdays)
# ('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday')
for week in weekdays:
print(week)
# monday
# tuesday
from collections import Counter
items = ["apple", "orange", "apple", "pear", "orange", "apple"]
item_counts = Counter(items)
print(item_counts)
# Counter({'apple': 3, 'orange': 2, 'pear': 1})
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Jakub3628800
Jakub3628800 / gist:50090ae1e59a8cfd771737ab3082aa2d
Created November 10, 2020 12:33 — forked from hest/gist:8798884
Fast SQLAlchemy counting (avoid query.count() subquery)
def get_count(q):
count_q = q.statement.with_only_columns([func.count()]).order_by(None)
count = q.session.execute(count_q).scalar()
return count
q = session.query(TestModel).filter(...).order_by(...)
# Slow: SELECT COUNT(*) FROM (SELECT ... FROM TestModel WHERE ...) ...
print q.count()

Kafka 0.11.0.0 (Confluent 3.3.0) added support to manipulate offsets for a consumer group via cli kafka-consumer-groups command.

  1. List the topics to which the group is subscribed
kafka-consumer-groups --bootstrap-server <kafkahost:port> --group <group_id> --describe

Note the values under "CURRENT-OFFSET" and "LOG-END-OFFSET". "CURRENT-OFFSET" is the offset where this consumer group is currently at in each of the partitions.

  1. Reset the consumer offset for a topic (preview)