Skip to content

Instantly share code, notes, and snippets.

View mdchaney's full-sized avatar

Michael Chaney mdchaney

View GitHub Profile
/*
By Michael Darrin Chaney
Copyright 2014 Michael Chaney, All Rights Reserved
Released under terms of MIT License or GPLv2
*/
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <time.h>
.Title EFinder Program to evaluate e
.Ident 'V03-02'
.Show MEB
;The purpose of this program will be to find e out to the
;specified number of decimal places. The idea here will be to use the
;definition:
;
; 1 1 1 1 1 1 1
; e = - + - + - + - + - + - + - + ...
#!/usr/bin/env python
# Demonstration of using Max7219 chip with raspberry pi
# and Python. Program will count from 0-999 on first three digits
# and 999-0 on second three digits. Includes code to setup,
# handle clock & latch, and send 16 bits at a time.
import RPi.GPIO as GPIO
import time
@mdchaney
mdchaney / parse_id3v23.rb
Created April 18, 2017 20:46
Pure Ruby parser for ID3 v2.3 tags
#!/usr/bin/env ruby
# By Michael Chaney, mdchaney@michaelchaney.com
# Copyright 2017, Michael Chaney Consulting Corporation, All Rights Reserved
#
# Released under GPL v2 License or MIT License
#
# Simple parser for ID3 v2.3 tags in MP3 files. Provide the filename
# on the command line.
#!/usr/bin/perl
# By Michael Chaney, Michael Chaney Consulting Corporation
# Copyright 2006, Michael Chaney Consulting Corporation, all rights reserved
# read wav chunks, see what each chunk is
use strict;
use POSIX qw(strftime);
@mdchaney
mdchaney / recursive_delete.rb
Created October 1, 2018 13:08
Recursively remove data from tables in PGSQL, considering foreign keys
#!/usr/bin/env ruby
@verbose = true
tables_to_clear = ARGV.dup.freeze
# Alternately, clear out everything but these tables
#UNCLEARED_TABLES=%w{ ar_internal_metadata schema_migrations }
#tables_to_clear = (ActiveRecord::Base.connection.tables.sort - UNCLEARED_TABLES).freeze
@mdchaney
mdchaney / README
Last active April 10, 2020 16:18
Bootstrap 4 multi-select replacement
This code will replace <select multiple...> boxes with a readonly text input that shows all items selected. When clicked, a modal will appear giving the user the ability to select items with check boxes. In the page load function, just call setup_selection_popups(). The select elements should have a class of "replaceable", and of course the multiple attribute must be present. Everything is contained in one javascript file, and a css file. Bootstrap 4 uses jquery, so it must be present. However, jquery is used only to show the modal.
@mdchaney
mdchaney / card_utilities.js
Created July 28, 2022 02:31
Modernization of Stripe's jquery.payment - almost drop-in replacement with no jQuery
// Based on Stripe's jquery.payment, offers a simple set of utilities
// for handling credit card numbers, expirations, and CVC/CVV2 codes
//
// cc_format_card_number(field)
// cc_format_card_expiry(field)
// cc_format_card_cvc(field)
//
// "field" may be either the actual DOM element reference or a string
// with the ID of the DOM element. This will add event handlers to
// the field to handle input.
@mdchaney
mdchaney / _line_item.html.erb
Created May 17, 2017 22:34
Help for dynamic subforms in Rails
<!--
In this file, the fields can be set to "required", but that will
cause issues. Specifically, when someone clicks "Remove" the fields
will be hidden and unless the "required" prop is set to false the form
will not submit. Also note that when showing this line if the object
is marked_for_destruction? it should be hidden. The javascript below
will handle both these issues.
-->
<tr class="line_item subform fields" id="line_item_<%= f.object.id %>">
<td>
@mdchaney
mdchaney / _line_item.html.erb
Created September 28, 2023 04:02
Stimulus-based subform
<!--
Note that when showing this line if the object is marked_for_destruction? it
should be hidden.
-->
<tr class="line_item subform fields" id="line_item_<%= f.object.id %>">
<td>
<%= f.text_field :field_1, required: true %>
</td>
<td>
<%= f.text_field :field_2, required: true %>