Skip to content

Instantly share code, notes, and snippets.

-- Generate a vanilla MERGE statement for Microsoft SQL Server that performs an
-- upsert. You may need to further modify the generated statement to fit your
-- needs, but it should at least save you from typing the same fields in
-- quadruplicate.
--
-- History:
-- 2021-04-15: Daniel Rothfus - Initial version
DECLARE @MergeColumns TABLE([Name] SYSNAME NOT NULL);
INSERT INTO @MergeColumns
@danielrothfus
danielrothfus / launch_emacs.bat
Created September 4, 2017 03:20
Launch emacs in the Linux subsystem for Windows
REM Launch emacs in the Linux subsystem for Windows for a quoted filename.
REM Daniel Rothfus
REM Sept 3, 2017
REM
REM To add Linux emacs as a right-click item in the context menu, add a registry
REM key at Computer\HKEY_CLASSES_ROOT\*\shell\emacs\command with the default
REM value "C:\...\launch_emacs.bat" "%1". Set the parent key's default value to
REM the entry's desired name, such as "Launch in Emacs".
REM
REM This script is an MVP and as such it probably has many edge cases around
@danielrothfus
danielrothfus / about.txt
Last active August 29, 2015 13:56
Raspberry Pi Wall Mount
This is a simple wall mount for a Raspberry Pi in the case found at
http://www.thingiverse.com/thing:30572. This mount works by supporting the Pi
by its two lower corners, so that the Ethernet port and the USB ports face out
of the bottom of the Pi.
To mount supports, put the corner supports on the Pi, attach short command
strips to the backside of the feet, and then push the Pi with the feet up
against the wall. The Pi will then be able to slide in and out of the supports
whenever you want to attach it to the wall.
@danielrothfus
danielrothfus / rushsolver.py
Last active March 31, 2021 05:13
A simple Python 3 script to brute force a minimal solution to the Rush Hour game.
# Rush Hour Solver
# rushsolver.py
# Daniel Rothfus
# This is a fairly slow brute force solver for the game Rush Hour. This solver
# was inspired by http://acm2013.cct.lsu.edu/localdoc/problems-scripting/1.pdf
# Please note that this solver was made for Python 3, not Python 2.
#
# To use this script, first input the character that will represent the special
# car to remove from the right side of the grid in the following board. Next,
# input the board in ASCII art on the next 6 rows. Periods should be used to
@danielrothfus
danielrothfus / streamview.html
Last active July 28, 2016 15:29
A basic HTML file for showing a web page with a full-screen view of a mjpg-streamer stream.
<html>
<head>
<title>Live Feed</title>
<script>
ASPECT_RATIO = 4.0 / 3.0;
IMAGE_SRC = "/?action=stream"
function initialize(){
var elem = document.getElementById("liveFeed")
var border = 0
@danielrothfus
danielrothfus / derhuff.c
Created February 11, 2013 05:29
A very simple Huffman implementation I wrote for bit-by-bit I/O practice.
/** \file derhuff.c
\author Daniel Rothfus
\version 1.0
\brief A really simple Huffman implementation.
Derhuff is a simple utility to compress files using the Huffman coding scheme.
To compress a file, it analyzes the frequencies of all the bytes in the file
and builds a tree using these frequencies, which it writes to the output. With
this tree, the program then converts each byte of the input to the path to get
to the corresponding leaf in the tree. To decode, it just reads the tree from