Skip to content

Instantly share code, notes, and snippets.

View smeans's full-sized avatar

Scott Means smeans

View GitHub Profile
@smeans
smeans / DiffObjects.sql
Created April 17, 2024 04:02
MS SQL stored proc to diff two objects
CREATE OR ALTER PROCEDURE DiffObjects
@o1 nvarchar(max),
@o2 nvarchar(max)
AS
BEGIN
SET NOCOUNT ON;
if OBJECT_ID(@o1) is null
begin
select concat(@o1, ' does not exist') message
@smeans
smeans / boxes.css
Created February 27, 2024 02:22
CSS flex layout boxes
x-hbox, .x-hbox {
display: flex;
flex-direction: row;
align-items: center;
}
x-hbox.top, .x-hbox.top {
align-items: flex-start;
}
@smeans
smeans / traceif.py
Last active January 20, 2022 06:02
traceif: a Python decorator that conditionally logs function calls based on a lambda test expression.
# MIT License
#
# Copyright (c) 2022 Scott Means
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@smeans
smeans / range.js
Last active December 3, 2021 16:23
Python-like range() generator function for JavaScript
'use strict';
function* range(start, end, step) {
step = step || 1;
const dir = Math.sign(end-start);
if (dir != Math.sign(step)) {
yield start;
@smeans
smeans / hostmod.py
Last active July 5, 2021 06:48
Command line tool for toggling hosts file records
#/usr/bin/env python
# hostmod.py -- Command line tool for toggling hosts file records
#
# Written in 2020 by W. Scott Means (smeans@gmail.com)
# To the extent possible under law, the author has dedicated all copyright
# and related and neighboring rights to this software to the public domain
# worldwide. This software is distributed without any warranty.
#
# You should have received a copy of the CC0 Public Domain Dedication along with
# this software. If not, see <https://creativecommons.org/publicdomain/zero/1.0/>.
@smeans
smeans / badd_test.py
Last active March 13, 2018 18:38
Test generator for Red binary addition function (see badd.red gist).
import random
print 'Red [Title: "dynamically generated tests for badd function"]'
print 'do %badd.red'
for ll in range(1, 8):
for rl in range(1, 8):
for trunc in range(0, max(ll, rl)):
ll_top = 256**ll
ln = random.randint(0, ll_top)
rl_top = 256**rl
@smeans
smeans / badd.red
Last active March 13, 2018 18:33
Binary addition in Red.
Red [
Title: "binary addition"
]
;
; Adds two binary quantities, outputting a binary value. Some examples:
; ; actual answer D4
; e: #{D4}
; r: badd #{60} #{74}
; print ["expected:" e " result:" r]