Skip to content

Instantly share code, notes, and snippets.

View christianchristensen's full-sized avatar

Chris Christensen christianchristensen

View GitHub Profile
@core2duoe6420
core2duoe6420 / velop_log.py
Created February 5, 2022 07:43
A python script to follow Linksys Velop's log printed by sysinfo.cgi
import requests
import time
from datetime import datetime, timedelta
from requests.auth import HTTPBasicAuth
last_time = datetime.min
last_message = ''
while True:
basic = HTTPBasicAuth('admin', '${velop_password}')
@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 October 4, 2024 00:07
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 October 31, 2024 23:33
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

Phoenix/Spark demo

Option 1: prebuilt VM

There is a prebuilt Centos 6.5 VM with the below components installed:

  • HDP 2.3.0.0-1754
  • Spark 1.3.1

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) }