Skip to content

Instantly share code, notes, and snippets.

View christianchristensen's full-sized avatar

Chris Christensen christianchristensen

View GitHub Profile
@reelsense
reelsense / help-unfuck-virtualbox-freebsd-11-2-not-booting.md
Last active October 13, 2019 08:35
How to fix FreeBSD 11.2-RELEASE not booting because of error "Fatal trap 12: page fault while in kernel mode"

How to fix FreeBSD 11.2-RELEASE not booting because of Virtual Box driver.

I entcountered a bug with virtualbox-ose-nox11-5.2.14_1 & virtualbox-ose-kmod after upgrading to FreeBSD 11.2-RELEASE on first reboot.

The system would enter a boot loop with this crash error:

supdrvGipCreate: failed to allocate the GIP page
@chrisdone
chrisdone / gist:02e165a0004be33734ac2334f215380e
Last active February 27, 2024 08:02
Build and run minimal Linux / Busybox systems in Qemu

Common

export OPT=/opt
export BUILDS=/some/where/mini_linux
mkdir -p $BUILDS

Linux kernel

@brendangregg
brendangregg / gist:eebe3455fd8e528bb14d193a93d43b59
Created August 16, 2016 23:45
tcp dport fetching with ftrace on linux 3.13 x86_64
Using my perf-tools just to wrap ftrace:
# ./perf-tools/bin/kprobe 'p:tcp_v4_connect skc_dport=+2(%si):u16'
Tracing kprobe tcp_v4_connect. Ctrl-C to end.
telnet-9723 [001] d... 62326244.175951: tcp_v4_connect: (tcp_v4_connect+0x0/0x480) skc_dport=1600
telnet-9725 [001] d... 62326246.502760: tcp_v4_connect: (tcp_v4_connect+0x0/0x480) skc_dport=1700
telnet-9726 [001] d... 62326247.861937: tcp_v4_connect: (tcp_v4_connect+0x0/0x480) skc_dport=100
telnet-9727 [001] d... 62326249.220740: tcp_v4_connect: (tcp_v4_connect+0x0/0x480) skc_dport=e803
Now a crappy ntohs() to process the dport string:
@jayswan
jayswan / cidrs.sh
Created July 26, 2016 13:27
Scripts to retrieve CIDR blocks for various services
# Fastly
curl -s https://api.fastly.com/public-ip-list | jq -r '.addresses | .[]'
# Google
dig @8.8.8.8 +short txt _netblocks.google.com | awk '{gsub("ip4:","");for (col=2; col<NF;++col) print $col}'
# AWS
curl -s https://ip-ranges.amazonaws.com/ip-ranges.json | \
jq --raw-output '.prefixes | map(.ip_prefix) | .[]'
@gbaman
gbaman / HowToOTGFast.md
Last active March 11, 2024 02:40
Simple guide for setting up OTG modes on the Raspberry Pi Zero, the fast way!

Setting up Pi Zero OTG - The quick way (No USB keyboard, mouse, HDMI monitor needed)

More details - http://blog.gbaman.info/?p=791

For this method, alongside your Pi Zero, MicroUSB cable and MicroSD card, only an additional computer is required, which can be running Windows (with Bonjour, iTunes or Quicktime installed), Mac OS or Linux (with Avahi Daemon installed, for example Ubuntu has it built in).
1. Flash Raspbian Jessie full or Raspbian Jessie Lite onto the SD card.
2. Once Raspbian is flashed, open up the boot partition (in Windows Explorer, Finder etc) and add to the bottom of the config.txt file dtoverlay=dwc2 on a new line, then save the file.
3. If using a recent release of Jessie (Dec 2016 onwards), then create a new file simply called ssh in the SD card as well. By default SSH i

@bearfrieze
bearfrieze / comprehensions.md
Last active December 23, 2023 22:49
Comprehensions in Python the Jedi way

Comprehensions in Python the Jedi way

by Bjørn Friese

Beautiful is better than ugly. Explicit is better than implicit.

-- The Zen of Python

I frequently deal with collections of things in the programs I write. Collections of droids, jedis, planets, lightsabers, starfighters, etc. When programming in Python, these collections of things are usually represented as lists, sets and dictionaries. Oftentimes, what I want to do with collections is to transform them in various ways. Comprehensions is a powerful syntax for doing just that. I use them extensively, and it's one of the things that keep me coming back to Python. Let me show you a few examples of the incredible usefulness of comprehensions.

@tanb
tanb / xhyve-freebsd-tutorial-1.md
Last active November 27, 2021 13:07
FreeBSD running on xhyve tutorial. (Appendix: Resize image with qemu. Create FreeBSD VM with qemu).

TL;DR

  • Create 5GB FreeBSD image.
  • Install FreeBSD on xhyve.
  • Mount host directory.

Requisites

@lavalamp
lavalamp / The Three Go Landmines.markdown
Last active February 16, 2024 12:16
Golang landmines

There are three easy to make mistakes in go. I present them here in the way they are often found in the wild, not in the way that is easiest to understand.

All three of these mistakes have been made in Kubernetes code, getting past code review at least once each that I know of.

  1. Loop variables are scoped outside the loop.

What do these lines do? Make predictions and then scroll down.

func print(pi *int) { fmt.Println(*pi) }
@welch
welch / README.md
Last active April 27, 2016 20:44
exponential smoothing with de-seasonalization

Forecast

Holt-Winters smoother/forecaster for anomaly detection

Forecast threads a smooth curve through a noisy timeseries in a way that lets you visualize trends, cycles, and anomalies. It can be used as part of an automatic anomaly detection system for metric timeseries (that is, sequences of timestamped numerical values).

It accomplishes this using a variation of Holt-Winters forecasting -- more generally known as exponential smoothing. Forecast decomposes a noisy signal into level, trend, repetitive "seasonal" effects, and unexplained variation or noise. In this example, a "season" is a day long, and we model repeated day-over-day variation. The result is a smoothed version of the signal which may be used to forecast future values or detect unexpected variation. This approach has been successfully used for [network anomaly detection](https://www.usenix.org/legacy/event/lisa2000/full_papers/br