Skip to content

Instantly share code, notes, and snippets.

View mshroyer's full-sized avatar

Mark Shroyer mshroyer

View GitHub Profile
@mshroyer
mshroyer / bool1.asm
Created June 27, 2012 03:38
Uninitialized bool mischief
.file "bool1.c"
.intel_syntax noprefix
.section .rodata
.LC0:
.string "p is true"
.LC1:
.string "p is not true"
.LC2:
.string "p is false"
.LC3:
@mshroyer
mshroyer / gist:3307553
Created August 9, 2012 19:59
SproutCore bindings
// group_view.js
TestUI.GroupView = SC.View.extend(
childViews: 'headingView'.w(),
backgroundColor: 'white',
layout: { width: 640 },
classNames: 'groupview'.w(),
displayProperties: 'title'.w(),
title: '',
titleBinding: SC.Binding.from('.headingView.labelView.value'),
[ 810.832427] ath: phy0: No free RX buffer
[ 814.392730] ath: phy0: No free RX buffer
[ 815.840087] ath: phy0: No free RX buffer
[ 827.579498] ath: phy0: No free RX buffer
[ 829.039703] ath: phy0: No free RX buffer
[ 829.396911] ath: phy0: No free RX buffer
[ 831.521118] ath: phy0: No free RX buffer
[ 835.393554] ath: phy0: No free RX buffer
[ 844.106262] ath: phy0: No free RX buffer
[ 844.425750] ath: phy0: No free RX buffer
@mshroyer
mshroyer / gdb-select-window.el
Created November 24, 2012 21:31
Keyboard navigation between emacs gdb windows
;; For the consistency of gdb-select-window's calling convention...
(defun gdb-comint-buffer-name ()
(buffer-name gud-comint-buffer))
(defun gdb-source-buffer-name ()
(buffer-name (window-buffer gdb-source-window)))
(defun gdb-select-window (header)
"Switch directly to the specified GDB window.
Moves the cursor to the requested window, switching between
`gdb-many-windows' \"tabs\" if necessary in order to get there.
@mshroyer
mshroyer / factorial.py
Created December 6, 2012 21:01
Python GDB adventures
from __future__ import print_function
from os import kill, getpid
from signal import SIGINT
def factorial(n):
if n == 0:
# Break into GDB
kill(getpid(), SIGINT)
return 1
@mshroyer
mshroyer / ptycheck.c
Last active December 10, 2015 03:48
This fails on OpenBSD 5.2
/**
* ptycheck.c - Demonstrate possible problem in OpenBSD's ptcwrite
*
* Opens a pseudoterminal pair in "raw" mode, then forks off a child
* process which attempts to write MESSAGE_LEN random bytes to the pty
* master; meanwhile the parent process tries to read the same number of
* bytes from the slave. Once the parent has received the expected number
* of bytes, it compares the message received against the original to
* ensure that all data shuffled across the pseudoterminal successfully.
*
@mshroyer
mshroyer / openwrt_mirror.sh
Last active December 11, 2015 23:38
Script to create and update an OpenWrt Mercurial mirror from its existing git trunk and branch mirrors
#!/bin/sh
branches="attitude_adjustment backfire"
# Destination repostiory location
destination=/var/hg/mirrors/openwrt
# Source repository locations
source_dir=/var/git/mirrors/openwrt
source_trunk="${source_dir}/trunk.git"
@mshroyer
mshroyer / snapzfs.sh
Last active December 14, 2015 07:39
Utility script for maintaining rolling snapshots of ZFS datasets on FreeBSD 9.1.
#!/bin/sh
# snapzfs.sh - Maintain rotating ZFS dataset snapshots
#
# Creates, rotates, and prunes rolling snapshots of ZFS datasets. When
# this script is run, the sets defined in the configuration section below
# are snapshot and rotated as necessary depending on the age and number of
# existing snapshots. Written for and tested on FreeBSD 9.1.
#
# Mark Shroyer
@mshroyer
mshroyer / fsck.pl
Created March 28, 2013 22:25
gitolite fsck command
#!/usr/bin/env perl
# gitolite fsck command
#
# Add this to the gitolite commands subdirectory (e.g. on FreeBSD,
# /usr/libexec/gitolite/commands/) and then invoke `gitolite fsck` to run
# integrity checks on your repositories.
#
# Mark Shroyer
# Thu Mar 28 12:16:12 EDT 2013
@mshroyer
mshroyer / coerce_kiln.py
Last active December 16, 2015 11:29
Python 3.3 script to coerce Kiln Harmony into finishing conversion of a large git repository (e.g. the Linux kernel), simulating multiple presses of the Repair button until the job is done. Requires BeautifulSoup 4, Requests, and pointfree.
#!/usr/bin/env python3
"""Force Kiln Harmony to finish repairing a large repository
I'm currently seeing an issue with Kiln Harmony where an imported Linux
kernel git repository fails partway through translation to Mercurial. It
seems that I can keep clicking the "Repair Repository" button to prod Kiln
into finishing more of the translation, however this is time consuming.
This script automates the process of checking whether the translation of a