Skip to content

Instantly share code, notes, and snippets.

@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 / build-vice-superpet.sh
Last active May 18, 2023 12:18
Build and install VICE with SuperPET support
#!/bin/bash
#
# Build and install the VICE emulator from source
# and then start the SuperPET 6809 mode emulation.
#
# Tested on Ubuntu 10.04 Desktop (x86) but likely
# works on other Debian-based systems.
set -x
set -e
@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
@mnaberez
mnaberez / p500_ieee488_read.asm
Created January 12, 2013 19:46
P500 IEEE-488 read/write routines commented (based on the disassembly from http://www.von-bassewitz.de/uz/oldcomputers/p500/rom500.s.html)
;READ
; Output secondary address on IEEE-488 bus
tksa: jsr txbyte
tkatn: lda #$3D
and tpi1_pa
; Output A on IEEE-488, switch data to input
setlns: sta tpi1_pa
lda #%11000011 ;PA7 NRFD Output
@mnaberez
mnaberez / patch_psych_whitelist.rb
Created January 31, 2013 20:12
Rails initializer that patches Psych to only resolve whitelisted classes.
# Patch Psych to only resolve classes required for RubyGems. Whitelist
# from: https://github.com/rubygems/rubygems.org/pull/516/files#L2R15
require "yaml"
unless defined?(Psych) && Psych == YAML
abort "Psych is not the YAML parser so unable to patch"
end
module Psych
@mnaberez
mnaberez / 0xed.rb
Created May 1, 2013 17:49
Open a file in 0xED from the command line.
#!/usr/bin/env ruby
if ARGV[0]
filename = File.expand_path(ARGV[0])
abort "File not found: #{filename}" unless File.file?(filename)
else
abort "Usage: #{__FILE__} <filename>"
end
`osascript -e 'tell application "0xED" to activate'`
@mnaberez
mnaberez / build-mess-softbox.sh
Last active July 10, 2016 02:45
Build MESS with SoftBox support
#!/bin/bash
#
# Build the MESS emulator from source and then
# start the SoftBox emulation.
#
# Tested on Ubuntu Desktop 16.04 (amd64)
set -x
set -e
set -o errexit