Skip to content

Instantly share code, notes, and snippets.

View kwilczynski's full-sized avatar
🍀

Krzysztof Wilczyński kwilczynski

🍀
  • Yokohama, Japan
  • 13:20 (UTC +09:00)
View GitHub Profile
@RhetTbull
RhetTbull / copy_file_with_progress_bar.py
Last active November 15, 2025 06:12
Python method to copy a file with a callback (e.g. to show a progress bar). Includes example of copying with both click.progressbar and tqdm.
""" Copy a file with callback (E.g. update a progress bar) """
# based on flutefreak7's answer at StackOverflow
# https://stackoverflow.com/questions/29967487/get-progress-back-from-shutil-file-copy-thread/48450305#48450305
# License: MIT License
import os
import pathlib
import shutil
@apangin
apangin / proccount.c
Created October 8, 2020 21:41
Sets the number of CPUs available for a JVM in a container (JDK < 8u191)
/*
* Copyright 2020 Andrei Pangin
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
$ cat > main.tf
provider "null" {
version = "2.1.1"
}
^D
$ terraform init
Initializing the backend...
Initializing provider plugins...
ARG go_version=1.17
ARG alpine_version=latest
FROM golang:${go_version}-alpine AS builder
ARG GOOS=linux
ARG GOARCH=amd64
ENV GOOS=${GOOS}
ENV GOARCH=${GOARCH}
@jgouly
jgouly / vt.md
Created September 15, 2020 23:39
Linux: Ctr-Alt-F<N> switches between virtual terminals/consoles, but how?

Linux: Ctr-Alt-F<N> switches between virtual terminals/consoles, but how?

I remembered the chvt (change foreground virtual terminal) command, so that seems like a good place to start. I looked at BusyBox's implementation in console-tools/chvt.c, hoping that it would be small enough to skim through. At 33 lines, with only 9 lines containing code I wasn't disappointed.

The call to console_make_active looks interesting. console_make_active can be found in libbb/get_console.c:

@kwilczynski
kwilczynski / binary.rb
Last active November 24, 2025 10:25
Example Homebrew formula for a Go command-line (CLI) binary
class Binary < Formula
desc ""
homepage ""
head do
url "", branch: "main"
depends_on "[email protected]" => :build if build.head?
end
@vegard
vegard / kernel-dev.md
Last active February 27, 2026 19:44
Getting started with Linux kernel development

Getting started with Linux kernel development

Prerequisites

The Linux kernel is written in C, so you should have at least a basic understanding of C before diving into kernel work. You don't need expert level C knowledge, since you can always pick some things up underway, but it certainly helps to know the language and to have written some userspace C programs already.

It will also help to be a Linux user. If you have never used Linux before, it's probably a good idea to download a distro and get comfortable with it before you start doing kernel work.

Lastly, knowing git is not actually required, but can really help you (since you can dig through changelogs and search for information you'll need). At a minimum you should probably be able to clone the git repository to a local directory.

@muff-in
muff-in / resources.md
Last active March 5, 2026 00:46
A curated list of Assembly Language / Reversing / Malware Analysis / Game Hacking-resources
@kwilczynski
kwilczynski / callback.c
Last active March 22, 2021 00:38
PM driver callbacks helper
// Using the && (logical AND) operator.
#define pm_driver_has_callback(__device, __callback) \
((__device)->driver && (__device)->driver->pm && (__device)->driver->pm->__callback)
#define pm_driver_do_callback(__device, __callback) \
(pm_driver_has_callback(__device, __callback) ? (__device)->driver->pm->__callback(__device) : 0)
// Using a statement expression to avoid using ternary operator...
@kwilczynski
kwilczynski / Vagrantfile
Last active May 11, 2022 13:51
Vagrant box ubuntu/focal64 and Ubuntu 20.04 freezing on vagrant up - fix by enabling serial console writing to /dev/null.
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/focal64"
config.vm.provider "virtualbox" do |vb|
vb.customize [ "modifyvm", :id, "--uartmode1", "file", "/dev/null" ]
end
end