Skip to content

Instantly share code, notes, and snippets.

View mshroyer's full-sized avatar

Mark Shroyer mshroyer

View GitHub Profile
Q. Why do computer scientists always confuse Christmas and Halloween?
A. Because Oct 31 == Dec 25
(Oct is octal, or base 8; Dec is decimal, or base 10. The octal representation
of the decimal number 25 is 31.)
# PowerShell command to delete editor (Emacs, Vim, etc.) tilde backup files
# from any directories passed to it either as a parameter or through the
# pipeline.
function Remove-EditorBackups() {
param([string[]]$Paths, [switch]$Recurse, [switch]$Force, [switch]$Verbose)
begin {
$script:foundInput = $false
function delete($fileinfo) {
#!/usr/bin/perl
# mt-export-markdown.pl: Process Movable Type export files
# containing Markdown posts into pure HTML.
#
# Mark Shroyer
# Mon Oct 11 01:37:52 EDT 2010
use warnings;
use strict;
@mshroyer
mshroyer / Hello.hs
Created November 1, 2010 03:27
gtk2hs hello world
import Graphics.UI.Gtk
main :: IO ()
main = do
initGUI
window <- windowNew
label <- labelNew $ Just "Hello, world from gtk2hs!"
set window [ containerBorderWidth := 20,
containerChild := label ]
onDestroy window mainQuit
@mshroyer
mshroyer / mandelbrot.ss
Created March 31, 2011 07:32
Mandelbrot fractal in Scheme
(define (p i c x)
(cond ((< i 1) "*")
((> (magnitude x) 2) " ")
(else (p (- i 1) c (+ (* x x) c)))))
(do ((y -1 (+ y .05))) ((> y 1))
(do ((x -2 (+ x .025))) ((> x 1))
(let ((c (make-rectangular x y)))
(display (p 99 c c))))
(newline))
@mshroyer
mshroyer / Makefile
Created August 16, 2011 14:56
tcpdump makefile for OpenWrt
include $(TOPDIR)/rules.mk
PKG_NAME:=tcpdump
PKG_VERSION:=4.1.1
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://www.tcpdump.org/release/
PKG_MD5SUM:=d0dd58bbd6cd36795e05c6f1f74420b0
@mshroyer
mshroyer / firewall.sh
Last active March 28, 2021 19:21
iptables firewall script for buildserv
#!/bin/sh
### BEGIN INIT INFO
# Provides: firewall
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: iptables firewall
# Description: Custom iptables firewall
@mshroyer
mshroyer / room.py
Created August 21, 2011 01:47
Python example code
#!/usr/bin/env python
class Room:
def __init__(self, name):
self.name = name
if __name__ == '__main__':
r = Room('FooRoom')
r.shortdesc = "Some short description"
r.longdesc = "And some slightly longer description"
@mshroyer
mshroyer / test2.txt
Created October 19, 2011 18:55
Chicken Scheme question
=== FILE: test2.scm =======================================================
#>
#include <stdint.h>
uint32_t foreign_proc()
{
return UINT32_MAX;
}
@mshroyer
mshroyer / uninitialized_bool.c
Created June 25, 2012 20:25
Example of undefined behavior in C
#include <stdio.h>
#include <stdbool.h>
int main(int argc, char *argv[])
{
bool b;
*((unsigned char *)&b) = 0xff;
if ( b )
printf("b is true\n");