Skip to content

Instantly share code, notes, and snippets.

View kevinmarks's full-sized avatar

Kevin Marks kevinmarks

View GitHub Profile
@kevinmarks
kevinmarks / gist:093db5313ab7f0fa479bd823df2c1128
Created February 14, 2024 22:40
Diffing two objects in js - checks that the new has at least the same keys as the old, and if not, shows where.
function diffdata(legacy,shiny) {
let delta={}
for (const key in legacy){
const oldval = legacy[key];
const newval = shiny[key];
if (typeof(oldval)==='object' && typeof(newval)==='object'){
delta[key] = diffdata(oldval,newval)
} else if (oldval==newval){
delta[key]="✅";
} else if(Math.abs((oldval-newval)/oldval)<0.001){
@kevinmarks
kevinmarks / dabblet.css
Created June 22, 2023 15:22
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
.main-window {
background-color: #111111;
text-align: center;
display: block;
margin: auto;
margin-top: 10px;
{
"rels": {},
"items": [
{
"id": "navigation",
"type": [
"h-navigation",
"h-section"
],
"properties": {},
@kevinmarks
kevinmarks / gist:fe90eb54129a1014b9ccdc395181357a
Created November 21, 2022 21:54
example CW markup from unmung.com/mastoview
<div class="h-entry entry __omnibear-selected-item">
<div class="p-author h-card header">
<img src="https://files.mastodon.social/accounts/avatars/109/257/143/813/191/096/original/b87fef5a3f693f10.png" class="u-photo">
<a class="p-name" href="https://mastodon.social/@minimammoth">Helena Pérez Valle</a> @<span class="p-nickname">minimammoth</span>
</div>
<details >
<summary class="p-summary">DnD, Combat <span class="showmore">Show More</span></summary>
<div class="e-content content">
<p>The Pudding King takes a Legendary Action and sends a Giant Amoeba to explode next to Crysanthea. She rolls a nat 20 but is still hit hard, and goes down. <a href="https://mastodon.social/tags/DnD" class="mention hashtag" rel="tag">#<span>DnD</span></a> <a href="https://mastodon.social/tags/DnDMondays" class="mention hashtag" rel="tag">#<span>DnDMondays</span></a> <a href="https://mastodon.social/tags/combat" class="mention hashtag" rel="tag">#<span>combat</span></a></p>
</div>
@kevinmarks
kevinmarks / dabblet.css
Last active July 18, 2019 12:26
toggle buttons wtf
/**
* toggle buttons wtf
*/
td {
border-bottom: 1px solid #ddd;
padding: .5rem .75rem;
}
tr {border: pink;}
.toggle_tv:not(:checked) ~ table .service-DTV {display:none;}
@kevinmarks
kevinmarks / diffdata
Created March 20, 2019 16:02
comparing 2 nested arrays in PHP
function diffdata($legacy,$shiny) {
$delta=array();
foreach ($legacy as $key => $oldval){
$newval = $shiny[$key];
if ($oldval==$newval){
$delta[$key]="✅";
} else if (is_array($oldval) && is_array($newval)){
$delta[$key] = diffdata($oldval,$newval);
} else {
$delta[$key]="❌ expected: $oldval<br>❌ returned: $newval";
@kevinmarks
kevinmarks / gist:ba16e408b1093f23ff72d6536456dd0f
Last active March 15, 2019 14:40
non recursive create_folder
function create_folder($path, $slug)
{
$folderPath = $basePath = $path . $slug;
$counter=0;
while (file_exists($folderPath){
$counter++;
$folderPath = $basePath . "-$counter";
}
mkdir($folderPath); //Creates the folder
$fn = $folderPath . '/listen.md'; //Sets the filename
@kevinmarks
kevinmarks / diffdata.js
Last active December 26, 2018 16:52
Diff data stripped - compare objects and show only the inner bits that differ
function diffdatastripped(legacy,shiny) {
let delta={},allgood=true;
for (const key in legacy){
const oldval = legacy[key];
const newval = shiny[key];
if (typeof(oldval)==='object' && typeof(newval)==='object'){
delta[key] = diffdatastripped(oldval,newval)
if (delta[key] !="✅") {
allgood=false;
}
<?xml version="1.0" ?>
<svg height="600" width="600" xmlns="http://www.w3.org/2000/svg" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs >
<g id="l0">
<rect width="600" height="600" fill="black"/>
</g>
<g id="l1">
<use xlink:href="#l0" transform="translate(0,0) scale(0.3333333333333333)"/>
<use xlink:href="#l0" transform="translate(200,0) scale(0.3333333333333333)"/>
<use xlink:href="#l0" transform="translate(0,200) scale(0.3333333333333333)"/>
@kevinmarks
kevinmarks / gist:f74137c9c5ceb55c173134a8ac7563fc
Last active November 20, 2016 22:50
Tweets recovered from noterlive logs
#nodevember @leeb: is going to give us a talk on how we think about architecture, not just code. "Architecture is a metaphor"
#nodevember @leeb: Architecture originates from studying the arch, an infinitely composable shape that allows us to build amazing things.
#nodevember @leeb: Pollios tells us architecture has: 1) Firmitas - durability 2) Utilitas - Suitable for purposes 3) Venustas - beauty
#nodevember @leeb: Architecture is about making fundamental structural choices. In software, we choose the elements of abstraction.
#nodevember @leeb: The problem of software architecture is trying to figure out what changed. So we try to add things that...change more?
#nodevember @leeb: When models and views have to listen to each other, there is cascading problems and syncing.
#nodevember @leeb: While REST helped us model our data in terms of a network service, it fails when we rely on other data.
#nodevember @leeb: If we tightly control what can change in the first place, immutability gives us new principl