Skip to content

Instantly share code, notes, and snippets.

View noahp's full-sized avatar

Noah Pendleton noahp

View GitHub Profile
@noahp
noahp / add-a-user.sh
Last active April 9, 2020 12:38
New sudo ssh only user to ubuntu
# log in to the server and switch to root
ssh my-server
sudo su
# create the new user
adduser --home /home/<username> --shell /bin/bash --disabled-password <username>
# switch to the user
su <username>
@noahp
noahp / brokenpipe_decorator.py
Created March 28, 2019 17:43
Decorator for broken pipe error when paging python script output
"""
Python when printing to a pager (less), if you exit without
reading all the output, you get an ugly but harmless exception:
BrokenPipeError: [Errno 32] Broken pipe
If you try to just trap the error, you still get this print
on python3:
Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>
BrokenPipeError: [Errno 32] Broken pipe
@noahp
noahp / linux-network-utils.md
Created January 31, 2019 19:30
linux networking utils
@noahp
noahp / tuzki.sh
Created January 28, 2019 23:55
tuzki bunny rabbit black and white gif emoji
# best pack of them i've found
http://yoursmiles.org/k-tuzki.php
# get 'em all
seq -w 1 88 | xargs -I % wget http://yoursmiles.org/ksmile/tuzki/k54%.gif
@noahp
noahp / gdb-python-thread-extra_info.patch
Created November 20, 2018 19:49
patch gdb python bindings to expose InferiorThread extra_info string 🙃
diff --git a/gdb/python/py-infthread.c b/gdb/python/py-infthread.c
index 4b2705a0af..34983f0ec5 100644
--- a/gdb/python/py-infthread.c
+++ b/gdb/python/py-infthread.c
@@ -117,6 +117,22 @@ thpy_set_name (PyObject *self, PyObject *newvalue, void *ignore)
return 0;
}
+static PyObject *
+thpy_get_extra_info (PyObject *self, void *ignore)
@noahp
noahp / info.md
Created November 15, 2018 02:18
Python c extension gdb hint with cyrus dashboard

debugging python native extension (.so)

If you're using the excellent cyrus dashboard (https://github.com/cyrus-and/gdb-dashboard), be aware that using set confirm off prevents being able to set these breakpoints before the .so is loaded, so recommend setting set confirm on.

@noahp
noahp / black-wrapper.sh
Last active November 8, 2018 14:09
python black formatter wrapper for py2 envs
#!/usr/bin/env bash
# Place this script somewhere in $PATH and chmod +x it!
# use system python3 (eg `sudo apt install python3-pip && pip3 install black`)
python3 -m black "$@"
# # alternative form, for python3 virtualenv
# ~/.virtualenvs/py3/bin/python -m black "$@"
@noahp
noahp / dell-D6000-dock-ubuntu.md
Last active March 11, 2025 09:11
Dell Universal Dock D6000 on ubuntu
@noahp
noahp / bitbucket-scroll-review-list.user.js
Last active September 19, 2018 12:22
greasemonkey script for bitbucket
// ==UserScript==
// @name Add a scroll bar to the reviewers list in Bitbucket
// @description Changes overflow rules on reviewsr pane to scroll
// @version 2
// @grant none
// @match *://source.fitbit.com/*
// @require http://code.jquery.com/jquery-latest.js
// ==/UserScript==
function addGlobalStyle(css) {
@noahp
noahp / args_error.sh
Last active August 31, 2018 17:43
-Werror=format-extra-args bug
docker run -i -v"$(pwd):/mnt/workspace" -t zbeekman/nightly-gcc-trunk-docker-image
gcc -Wall -Werror /mnt/workspace/test.c
/mnt/workspace/test.c: In function 'main':
/mnt/workspace/test.c:57:12: error: too many arguments for format [-Werror=format-extra-args]
57 | printf("" PRIu32, 2);
| ^~
cc1: all warnings being treated as errors
test.c: