Skip to content

Instantly share code, notes, and snippets.

@ddm
ddm / launch.sh
Created June 24, 2019 06:58
X11 Docker Apps with XQuartz xterm
#!/usr/bin/env bash
COMMAND=$1
pushd `dirname $0` > /dev/null
DIR=`pwd -P`
popd > /dev/null
cd $DIR
@ddm
ddm / lpc1114.cfg
Last active October 15, 2017 06:53 — forked from RickKimball/lpc1114.cfg
configuration files for lpc812 using SWD from an stlink-v2 discovery board
#-----------------------------------------
# NXP lpc1114fn23 Cortex-M0 32k flash, 4k ram
set CHIPNAME lpc1114
set CPUTAPID 0x0BB11477
set CPUROMSIZE 0x8000
set CPURAMSIZE 0x1000
# After reset the chip is clocked by the ~12MHz internal RC oscillator.
# When board-specific code (reset-init handler or device firmware)
#!/bin/bash
# Create a complete OS .dmg file (it needs the Apple Developers Tools installed)
# usage:
# pkg-create.sh <contents-root-folder> <package-name> <package-version> <vendor-string>
#
CONTENTS=$1
shift
NAME=$1
shift
#!/usr/bin/env sh
/usr/bin/screen -S reverse-ssh-tunnel -d -m /usr/bin/autossh -M 65500 -o "ServerAliveInterval 20" -R 2222:localhost:22 server
@ddm
ddm / docker-compose.yml
Created August 1, 2017 19:39
Alpine cron
version: "3"
services:
cron:
image: alpine
command: sh -c "echo '* * * * * task > /proc/1/fd/1 2> /proc/1/fd/2' | crontab - && crond -f"
volumes:
- ./task.sh:/usr/local/bin/task:ro

Adventures in Python Core Dumping

After watching Bryan Cantrill's presentation on [Running Aground: Debugging Docker in Production][aground] I got all excited (and strangely nostalgic) about the possibility of core-dumping server-side Python apps whenever they go awry. This would theoretically allow me to fully inspect the state of the program at the point it exploded, rather than relying solely on the information of a stack trace.

// A round-robin priority arbiter for valid/ready signaling using carry chain logic.
module arbiter#(parameter N = 2)
(
input wire clk,
input wire [N-1:0] s_valid,
output wire [N-1:0] s_ready,
output wire m_valid,
input wire m_ready
);

From this paper: http://fpgacpu.ca/fpga/hdl/Tumbush%20DVCon%2005.pdf

  1. If any operand in an operation is unsigned the entire operation is unsigned.
  2. Investigate fully all "signed to unsigned conversion occurs" synthesis warnings. These point to incorrect functionality.
  3. All signed operands will be sign-extended to match the size of the largest signed operand.
  4. Type casting using $unsigned will make the operation unsigned. The operand will be extended with 0’s if necessary.
  5. Type casting using $signed makes the operand signed. The operand will be sign-extended with 1's if necessary. Pad the operand with a single 0 bit before the cast if this is not desired.
  6. Expression type depends only on the operands or operation; it does not depend on the LHS of the expression.

Additional points based on feedback from Owen Shepherd:

@ddm
ddm / JavaScript.ipynb
Last active September 22, 2017 21:19
docker run -p 127.0.0.1:8888:8888 -v `pwd`:/work dimdm/notebook
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ddm
ddm / apk.sh
Created February 8, 2017 08:22
Unpack or pack an apk
#!/usr/bin/env bash
DIR=`dirname $0`
TARGET_APK="target.apk"
TARGET_DIR="target"
if [[ ! "$1" =~ ^(unpack|pack)$ ]]; then
echo "Choose 'unpack' or 'pack'"
exit 1
fi