Skip to content

Instantly share code, notes, and snippets.

@mnaberez
mnaberez / 8050mode.sh
Created March 15, 2014 23:24
Put an 8250 or SFD-1001 into 8050 mode using cbmctrl.
#!/bin/bash
#
# Put an 8250 or SFD-1001 into 8050 mode using cbmctrl.
# http://www.softwolves.com/arkiv/cbm-hackers/2/2411.html
if [ $# -lt 1 ]; then
echo "Usage: $0 <unit number>"
exit 2
fi
@mnaberez
mnaberez / count.py
Last active August 29, 2015 14:02
8-bit binary counter for the LabJack U3's FIO lines
#!/usr/bin/env python
# 8-bit binary counter for the LabJack U3's FIO lines
import time
import u3
dev = u3.U3()
# disable timers so they don't interfere with FIO
dev.configIO(NumberOfTimersEnabled=0)
@mnaberez
mnaberez / freq.py
Last active August 29, 2015 14:02
Measure frequency on the LabJack U3's FIO4 pin.
#!/usr/bin/env python
#
# |<------->| Measure the time between two rising
# edges on the LabJack's FIO4 pin,
# +----+ +----+ then calculate the frequency in Hertz.
# | | | |
# ----+ +----+ +----
import time
import u3
@mnaberez
mnaberez / strobe.py
Created June 19, 2014 20:57
Generate a single pulse of ~5 microseconds on the LabJack U3's FIO4 pin.
#!/usr/bin/env python
# Generate a single pulse of ~5 microseconds on the LabJack U3's FIO4 pin.
import LabJackPython
import u3
dev = u3.U3()
# fio4: timer 0 (frequency out)
# fio5: timer 1 (timer stop)
@mnaberez
mnaberez / 1571mode.sh
Created December 15, 2014 21:21
Put a 1571 into double-sided (1571) or single-sided (1541) mode using cbmctrl.
#!/bin/bash
#
# Put a 1571 into double-sided (1571) or single-sided (1541) mode
# using cbmctrl.
if [ $# -lt 1 ]; then
echo "Usage: $0 <unit number> <1541|1571>"
exit 2
fi
@mnaberez
mnaberez / vice-labels.rb
Created February 10, 2012 01:04
Generate VICE monitor labels from an XAsm listing file
#!/usr/bin/env ruby
# Ruby script to generate VICE monitor labels from
# an XAsm listing file.
filename = ARGV[0]
if filename
lines = File.readlines(filename)
else
abort "Usage: vice-labels.rb <filename>"
@mnaberez
mnaberez / trimwhitespace.php
Created February 13, 2012 22:09
Trim unnecessary whitespace from an HTML file or ERB template.
<?php
/**
* Trim unnecessary whitespace from an HTML file or ERB template.
*
* This is taken directly from Smarty 3.1.7 (http://www.smarty.net):
* libs/plugins.outfilter.trimwhitespace.php
*
* Changes:
* - Removed argument "Smarty_Internal_Template $smarty".
@mnaberez
mnaberez / missing_translations.user.js
Created February 19, 2012 18:51
Userscript for Greasemonkey and Chrome to highlight and console.log Rails I18n missing translations
// ==UserScript==
// @name Highlight Rails I18n Missing Translations
// @namespace http://mikenaberezny.com
// @description Highlight and console.log missing translations from Rails I18n.
// @include *
// ==/UserScript==
// Rails I18n wraps missing translations in <span class="translation_missing">
var elements = document.getElementsByClassName("translation_missing");
@mnaberez
mnaberez / phpbb3_override_tpl_allow_php.sql
Created May 27, 2012 20:57
MySQL triggers that prevent phpBB3's "Allow PHP code in templates" option from being enabled
DROP TRIGGER phpbb_config_insert_tpl_allow_php;
DROP TRIGGER phpbb_config_update_tpl_allow_php;
DELIMITER ;;
CREATE TRIGGER phpbb_config_insert_tpl_allow_php BEFORE INSERT ON phpbb_config FOR EACH ROW
IF (NEW.config_name = 'tpl_allow_php') THEN
SET NEW.config_value = 0;
SET NEW.is_dynamic = 0;
END IF;;
@mnaberez
mnaberez / compact_singleline_pp.rb
Created September 3, 2012 00:04
More compact output from PP.singleline_pp by omitting spaces
require 'pp'
class PP
class CompactSingleLine < SingleLine
# output comma separators as "," instead of ", " to save bytes
def comma_breakable
text ","
end
end