Skip to content

Instantly share code, notes, and snippets.

View maurice-does-software's full-sized avatar

Maurice Ferguson maurice-does-software

View GitHub Profile
import { Component, Input } from '@angular/core';
import { FormsModule } from '@angular/forms';
//This slider has a 2 color dynamic background for the rail,
//and a handle that enlarges when hovered.
@Component({
selector: 'pretty-slider',
standalone: true,
imports: [FormsModule],
template: `
@maurice-does-software
maurice-does-software / TouchObjectTrackerApp.html
Last active August 16, 2019 18:14
This single page app will store and recall location data. Meant to be invoked via NFC tags or manually.
<!DOCTYPE html>
<html lang="en">
<head>
<script type="text/javascript" defer="defer">
/**
* @author Maurice Ferguson maurice.does.software@gmail.com
* @version 0.5
* @since 2019-08-16
* @see https://gist.github.com/maurice-does-software/4fd0a574ddd74ef7f78a51f84292791a
* @desc
function validateDriversLicenseNumber(stateAbbrev, dln, consumer){
var stateDlnPatterns={
/* Each pattern string is either a function name or a partial regex. */
AK: {patterns:["\\d{1,7}"], human:"1 to 7 digits"},
AL: {patterns:["\\d{7}", "\\d{1,7}"], human:"1 to 7 digits"},
AR: {patterns:["\\d{9}"], human:"9 digits"},
AZ: {patterns:["[A-Z]{1}\\d{8}", "[A-Z]{2}\\d{3,6}", "\\d{9}"], human:"(1 letters then 8 digits) OR (2 letters then 3 to 6 digits) OR (9 digits)"},
CA: {patterns:["[A-Z]{1}\\d{7}"], human:"1 letters then 7 digits"},
@echo off
rem This script is meant to automate as much as possible our interactions
rem with an archaic, unscriptable Windows GUI app,
rem which downloads data dumps needed for a *nix server app.
rem It assumes Windows is running in a VM with no ssh/scp client
rem but with a shared folder that the host OS can access.
rem The echos at the end are just a handy reminder for myself
rem so I don't have to search through my notes for server details.
rem Config
@maurice-does-software
maurice-does-software / multi_server_patch_script.sh
Created June 1, 2016 17:46
This script creates a patch file of the most recent git commit, uses scp and patch to apply the changes to each of 3 app servers, then restarts the rails apps on those servers one by one, after waiting for the user to give the go-ahead (so they can take the servers down from a load balancer, or perform other tasks first). It accepts two optional…
#!/bin/bash
#Allow numeric prefix to be set as an argument.
#Can use `-` to pass through and still pass additional commands.
if [ -n "$1" ] && [ "$1" != "-" ]
then
NUMERIC_PREFIX=$1
else
NUMERIC_PREFIX='0001'
fi
@maurice-does-software
maurice-does-software / quote_rotator.js
Created March 24, 2016 00:51
A simple quote rotator based on jQuery.
/*
Usage:
To create a rotator for container element `#the-container`, rotating every 12 seconds, using class `foobar` to show:
createQuoteRotator('#the-container',12,'foobar');
To create a rotator for the element `#blah` using the default 8 second interval and default class 'show' to show:
createQuoteRotator('#blah');
To stop the timer of the second quote rotator on the page:
window.clearInterval(window.quoteRotators[1].timer);
*/
#This method is meant to filter incoming parameters in the controller
#before calling a model method like `update_attributes` with those parameters.
def sanitize_params object, new_attrs
new_attrs.keys.each do |k|
#Remove keys for which there is no setter method.
(new_attrs.delete(k) && next) if !object.respond_to?("#{k}=")
#Remove keys holding datetimes that haven't changed substantially (more than just the seconds being truncated).
if new_attrs[k] && object.respond_to?(k) && object.send(k).is_a?(Time)
existing_value=object.send(k).utc.to_i+object.send(k).utc_offset
new_attrs.delete(k) if new_attrs[k].to_time.to_i/120==existing_value/120
(function(){
function makeSticky(selector){
var $el =$(selector),
elOffSetFromTop =$el.offset().top,
elStickyOffSet =parseInt($el.attr('data-sticky-offset'))||0;
var makeItStick=function(){
var windowOffSetFromTop=$(window).scrollTop();
if (windowOffSetFromTop+elStickyOffSet > elOffSetFromTop+10) {
/* A small tool for splitting MPO files into their JPG components.
* $Id: mposplit.c,v 1.3 2011/07/07 00:11:38 chris Exp $
* Copyright (C) 2009-2011, Christian Steinruecken. All rights reserved.
*
* This code is released under the Revised BSD Licence.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*