Skip to content

Instantly share code, notes, and snippets.

View dcabines's full-sized avatar

David Cabiness dcabines

View GitHub Profile
@dcabines
dcabines / App.Utils.Array
Created July 16, 2015 19:06
array stuff.
App.Utils.Array = (function () {
'use strict';
var utils = {
// TESTED
// check to see if a value is one of any of the supplied values
anyValue: function (value, values) {
return this.any(values, function (item) {
return item === value;
});
@dcabines
dcabines / toSmallCaps.js
Last active June 17, 2016 01:30
Cᴏɴᴠᴇʀᴛ ʟᴏᴡᴇʀ ᴄᴀsᴇ ʟᴇᴛᴛᴇʀs ɪɴ ᴀ sᴛʀɪɴɢ ᴛᴏ sᴍᴀʟʟ ᴄᴀᴘs. Fᴀᴄᴇʙᴏᴏᴋ sᴜᴘᴘᴏʀᴛs sᴍᴀʟʟ ᴄᴀᴘs.
window.toSmallCaps = (function () {
var letters = "abcdefghijklmnopqrstuvwxyz";
var caps = "ᴀʙᴄᴅᴇғɢʜɪᴊᴋʟᴍɴᴏᴘǫʀsᴛᴜᴠᴡxʏᴢ";
return function replace(value) {
var newValue = '';
for (i = 0; i < value.length; i++) {
var letter = value[i];
var index = letters.indexOf(letter);
@dcabines
dcabines / String.prototype.toSmallCaps.js
Created February 17, 2016 18:44
This is the same as the last one, just done a little differently.
String.prototype.toSmallCaps = (function () {
var letters = "abcdefghijklmnopqrstuvwxyz";
var caps = "ᴀʙᴄᴅᴇғɢʜɪᴊᴋʟᴍɴᴏᴘǫʀsᴛᴜᴠᴡxʏᴢ";
function translate(character) {
var index = letters.indexOf(character);
return index !== -1 ? caps.charAt(index) : character;
}
function mapReduce(value, transform) {
@dcabines
dcabines / gist:f7e584d372d35f5c384dfe210925baa3
Created July 23, 2020 15:50
The Harper’s ‘Letter,’ cancel culture and the summer that drove a lot of smart people mad
By
Sarah Ellison and
Elahe Izadi
July 23, 2020 at 9:20 a.m. EDT
This is what was on Thomas Chatterton Wiliams’s mind when he decided to write a short letter on the risks to liberalism and open discourse and get some like-minded thinkers to sign on.
He was thinking of the Poetry Foundation, whose leaders resigned after their four-sentence statement in support of Black Lives Matter was deemed too tepid by 1,800-plus petition-signers. And the National Book Critics Circle, whose board imploded over its own attempt at such a statement.
He was thinking of David Shor, a political scientist who was fired after tweeting about a study suggesting that violent street protests helped tip the 1968 election to the GOP; and Colin Kaepernick, a quarterback who was shunned from the NFL after his anti-racism activism ran afoul of conservative fans.
function element<e extends HTMLElementTagNameMap[keyof HTMLElementTagNameMap]>(
tag: keyof HTMLElementTagNameMap,
attributes: { [k in keyof HTMLParagraphElement]?: string; },
events: { [k in keyof HTMLElementEventMap]?: string; },
...children: HTMLElement[]
): e {
const element = document.createElement(tag) as e;
Object.keys(attributes).forEach(key => {
if (key === 'innerText') {
union(){
translate([0, 0, 2])
union() {
translate([2,0,0]) cube([220,20,2]);
translate([222,0,0]) cube([2,20,18]);
cube([2,20,18]);
translate([0,0,16])
linear_extrude(
height = 2,
const root = 'https://api.spacetraders.io';
// utils
const timeout = (seconds) => new Promise(resolve => setTimeout(resolve, seconds * 1000));
const sleeper = (seconds) => (x) => new Promise(resolve => setTimeout(() => resolve(x), seconds * 1000));
const userName = () => `user-${new Date().getTime()}-${Math.random()}`;
const querySeparator = (path) => path.indexOf('?') === -1 ? '?' : '&';
const get = (path) => fetch(`${root}${path}`).then(x => x.json()).then(saveState).then(saveArchive).then(sleeper(1));
const post = (path, body) => fetch(`${root}${path}`, postOptions(body)).then(x => x.json()).then(saveState).then(saveArchive).then(sleeper(1));
const put = (path, body) => fetch(`${root}${path}`, putOptions(body)).then(x => x.json()).then(saveState).then(saveArchive).then(sleeper(1));
$fa = 1;
$fs = 1;
bell_height = 50;
bell_diameter = 10;
bell_wall = 1.2;
bell_foot_height = 10;
bell_foot_gap = 5;
snorkel_height = bell_height - 20;
$originalsFolder = 'originals'
$resizedFolder = 'resized'
$reorganizedFolder = 'reorganized'
$originals = Get-ChildItem -Path $originalsFolder -Recurse -Include *.jpg
foreach ($original in $originals) {
$resized = Get-ChildItem -Path $resizedFolder -Recurse -Include $original.Name
$destination = ($resized.FullName).Replace($resizedFolder, $reorganizedFolder).Replace($resized.Name, "")
New-Item $destination -Type Directory
@dcabines
dcabines / drip-ring.scad
Created November 2, 2022 13:34
For hydroponic irrigation
tube_radius = 4;
wall = 1.2;
ring_degree = 310;
ring_radius = 80;
ring_step = 10;
hole_min_radius = 0.6;
hole_max_radius = 1;
hole_diff_radius = hole_max_radius - hole_min_radius;