Skip to content

Instantly share code, notes, and snippets.

@kmck
kmck / asm6f.c.diff
Created April 5, 2020 21:48
Suppress IGNORENL'ed output in .mlb files and treat ENUM'ed labels as RAM aliases
diff --git a/asm6f.c b/asm6f.c
index 0507082..ac35efe 100644
--- a/asm6f.c
+++ b/asm6f.c
@@ -82,6 +82,7 @@ typedef struct {
int pass; //when label was last defined
int scope; //where visible (0=global, nonzero=local)
int ignorenl; //[freem addition] output this label in .nl files? (0=yes, nonzero=no)
+ int insideenum; //[kmck addition] output this label? (0=yes, nonzero=no)
void *link; //labels that share the same name (local labels) are chained together
function serializeNodeToString(node) {
if (typeof XMLSerializer !== 'undefined') {
return new XMLSerializer().serializeToString(node);
}
if (node.outerHTML != null) {
return node.outerHTML;
} else if (node instanceof Document) {
return node.documentElement && node.documentElement.outerHTML
? node.documentElement.outerHTML
: '';

Keybase proof

I hereby claim:

  • I am kmck on github.
  • I am kmck (https://keybase.io/kmck) on keybase.
  • I have a public key whose fingerprint is 9301 AF59 07DB 01B3 40E5 0C9C E2FA 0B60 B76B CE67

To claim this, I am signing this object:

@kmck
kmck / ReactComponentView.js
Last active October 3, 2016 19:57
Backbone.View wrapper for a React component
var ReactComponentView = Backbone.View.extend({
initialize: function(options) {
if (options) {
this.setComponent(options.ComponentClass, options.componentProps, options.componentChildren);
}
},
setComponent: function(ComponentClass, componentProps, componentChildren) {
(typeof ComponentClass === 'undefined') || (this.ComponentClass = ComponentClass);
(typeof componentProps === 'undefined') || (this.componentProps = componentProps);
@kmck
kmck / discard-asset-webpack-plugin.js
Last active October 1, 2016 20:37
Plugin to selectively discard Webpack assets before they are emitted
var _ = require('lodash');
function canDiscard(assetPath, discardPatterns) {
if (!_.isArray(discardPatterns)) {
discardPatterns = [discardPatterns];
}
return _.some(discardPatterns, function(discardPattern) {
if (_.isString(discardPattern)) {
return _.endsWith(assetPath, discardPattern);
} else if (_.isRegExp(discardPattern)) {
@kmck
kmck / matte-color.scss
Created June 9, 2016 21:36
SCSS mixin to flatten a color against another color
// ## matte
//
// Calculate the color created by flattened the input color against a base color with an opacity
//
// @param {Color} $color: foreground color
// @param {Color} [$matte]: background color (or `transparent`) to matte the foreground against
// @param {Number} [$opacity]: mixing opacity of the foreground color, analogous to layer opacity
// in an image editor
// @return {Color} the matted color
@kmck
kmck / SassMeister-input.scss
Created January 20, 2016 20:35
Generated by SassMeister.com.
// ----
// libsass (v3.3.2)
// ----
@function icon-char($filename) {
$char: "";
@if $filename == reblog {
$char: "\EA06";
}
@kmck
kmck / postForm.js
Created June 17, 2015 18:56
Fake a form posting action
function postForm(action, data) {
var form = document.createElement('form');
form.method = 'POST';
form.action = action;
var key, value, input;
for (key in data) {
value = data[key];
if (value.indexOf('\n') < 0) {
input = document.createElement('input');
input.name = key;
// Assumes jQuery
function form_submit(attributes, action, method) {
var $form = $('<form>').attr({
method: method ||'post',
action: action || window.location.pathname
});
$.each(attributes, function(name, value) {
$(value.indexOf('\n') < 0 ? '<input>' : '<textarea>').attr('name', name).val(value).appendTo($form);
});
$form.appendTo('body').submit().remove();
@kmck
kmck / Extract colors
Created August 2, 2013 21:58
Extracts all the colors of the wind
function extract_colors() {
var colors = [];
$('body').find('*').each(function(i,o) {
var color;
if (color = $(o).css('color')) colors.push(color);
if (color = $(o).css('background-color')) colors.push(color);
if (color = $(o).css('border-top-color')) colors.push(color);
if (color = $(o).css('border-right-color')) colors.push(color);
if (color = $(o).css('border-bottom-color')) colors.push(color);
if (color = $(o).css('border-left-color')) colors.push(color);