Skip to content

Instantly share code, notes, and snippets.

View fuweid's full-sized avatar
🎯
Focusing

Fu Wei fuweid

🎯
Focusing
View GitHub Profile
@simonheb
simonheb / gist:b54b91358c3d7e2960a4f6e13e95ac54
Last active June 9, 2023 02:22
Patching the 5.12 Linux kernel to support new Intel hardware (e.g., Intel Iris Xe for Thinkpad X1 Titanium Yoga) on Ubuntu/Debian/Pop!_OS

Get a 5.12 Linux kernel with support for newer Intel hardware (e.g., Intel Iris Xe for Thinkpad X1 Titanium Yoga) on Ubuntu/Debian/Pop!_OS

Prologue: Do I need this?

I recently got a Thinkpad sporting an Intel® Core™ i5-1140G7 Processor 11. gen (1,80 GHz, Turbo Boost, 4 Cores, 8 Threads, 8 MB Cache with an Integrated Intel® Iris® Xe. Sadly graphics drivers did not work out-of-the-box and also not with the latets 5.12 kernel from xenmod. You can tell it's not working when graphics are slow, backlight adjustment buttons don't work and this is the output of inxi -G (you might need to sudo apt install inxi):

simon@pop-os:~$ inxi -G
Graphics:
  Device-1: Intel driver: N/A 
  Device-2: IMC Networks Integrated Camera type: USB driver: uvcvideo 
  Display: x11 server: X.Org 1.20.9 driver: fbdev unloaded: modesetting,vesa 
 resolution: 2256x1504~95Hz 
@adwait1-g
adwait1-g / running_the_kernel.md
Last active February 21, 2024 15:53
This gist tells you how to build the kernel and run it on qemu. This is also a way to get started with kernel's internals.

1. Downloading and building the Linux kernel

  1. Clone the github repository onto your local machine.
$ git clone https://github.com/torvalds/linux.git
$ cd linux
  1. Configure the build
package main
import (
"fmt"
"net"
"os"
"time"
bpf "github.com/iovisor/gobpf/bcc"
"github.com/florianl/go-tc"
@sbernard31
sbernard31 / test.c
Last active March 11, 2023 18:04
UDP load balancer proto using bcc (XDP/Bpf)
#define KBUILD_MODNAME "foo"
#include <uapi/linux/bpf.h>
#include <linux/bpf.h>
#include <linux/icmp.h>
#include <linux/if_ether.h>
#include <linux/if_vlan.h>
#include <linux/in.h>
#include <linux/ip.h>
#include <linux/tcp.h>
#include <linux/udp.h>
@cecilemuller
cecilemuller / 2019-https-localhost.md
Last active June 27, 2024 04:39
How to create an HTTPS certificate for localhost domains

How to create an HTTPS certificate for localhost domains

This focuses on generating the certificates for loading local virtual hosts hosted on your computer, for development only.

Do not use self-signed certificates in production ! For online certificates, use Let's Encrypt instead (tutorial).

@mcastelino
mcastelino / iptables-cheatsheet.md
Last active June 16, 2024 22:48
iptables-cheatsheet

The netfilter hooks in the kernel and where they hook in the packet flow

The figure below calls out

  • The netfilter hooks
  • The order of table traversal
@cpuspellcaster
cpuspellcaster / hijack.txt
Created January 8, 2017 02:20
Docker Hijack Protocol
Stream details:
When using the TTY setting is enabled in POST, the stream is the raw data from the process PTY and client’s stdin. When the TTY is disabled, then the stream is multiplexed to separate stdout and stderr.
The format is a Header and a Payload (frame).
HEADER
The header contains the information which the stream writes (stdout or stderr). It also contains the size of the associated frame encoded in the last four bytes (uint32).
@aliuygur
aliuygur / desc.md
Last active July 22, 2022 09:48
removes duplicate values in given slice

this algorithm 10x faster than https://www.dotnetperls.com/duplicates-go and zero allocation

➜  api git:(master) ✗ go test -v -bench=. main_test.go
=== RUN   TestSliceUniq
--- PASS: TestSliceUniq (0.00s)
BenchmarkSliceUniq-4             3000000               439 ns/op               0 B/op          0 allocs/op
BenchmarkRemoveDuplicates-4       500000              4599 ns/op             571 B/op          8 allocs/op
PASS
@MrTrustor
MrTrustor / clean-docker-for-mac.sh
Last active November 21, 2023 11:38
This script cleans the Docker.qcow2 file that takes a lot of disk space with Docker For Mac. You can specify some Docker images that you would like to keep.
#!/bin/bash
# Copyright 2017 Théo Chamley
# 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:
#
# The above copyright notice and this permission notice shall be included in all copies or
@CMCDragonkai
CMCDragonkai / memory_layout.md
Last active June 17, 2024 12:05
Linux: Understanding the Memory Layout of Linux Executables

Understanding the Memory Layout of Linux Executables

Required tools for playing around with memory:

  • hexdump
  • objdump
  • readelf
  • xxd
  • gcore