Skip to content

Instantly share code, notes, and snippets.

@boredzo
boredzo / gist:1696100
Created January 28, 2012 22:57
Creating font(s) from a URL
//Core Graphics method
CGDataProviderRef provider = CGDataProviderCreateWithURL((__bridge CFURLRef)fontURL);
CGFontRef graphicsFont = CGFontCreateWithDataProvider(provider);
CTFontRef coreTextFont = CTFontCreateWithGraphicsFont(graphicsFont, fontSize, /*matrix*/ NULL, /*attributes*/ NULL);
if (coreTextFont) {
NSFont *font = (__bridge NSFont *)coreTextFont;
[fonts addObject:font];
CFRelease(coreTextFont);
}
CGFontRelease(graphicsFont);
@boredzo
boredzo / Enhanced paper trimmer project.md
Last active May 21, 2023 17:24
Enhanced paper trimmer project plan (untested, this is just a braindump)

Enhanced paper trimmer project plan

The Project I'm Not Doing

This project, if I were to do it, would hopefully improve a paper trimmer's ability to deliver consistent, precise cuts to specific measurements.

I developed the urge to do this project after using my existing paper trimmer in the making of my postcards, which came out about the right size but with some variation. I think having hard stops rather than just grid lines might help solve the variation problem.

I don't really have the time or the severity of need to do this project, but it would be nice, so my brain has been hung up on it and I've been researching the heck out of it despite my conscious preference to not do the project.

Hopefully braindumping into this document will be the final step and I won't have to think about it again, at least until the next time I'm unhappy with what comes out of my paper trimmer.

@boredzo
boredzo / skew.scad
Created January 5, 2016 06:02
Skew operator for OpenSCAD
/*skew takes an array of six angles:
*x along y
*x along z
*y along x
*y along z
*z along x
*z along y
*/
module skew(dims) {
matrix = [
@boredzo
boredzo / gmail-basic-dark.css
Last active April 9, 2022 06:12
Gmail basic UI dark mode stylesheet
/*Gmail dark mode*/
@media(prefers-color-scheme: dark) {
/*
Ideally we could set the background-color of the body itself, but there's no way to refer to that element specifically enough to not also apply to many other sites. This is as close as we can get and it's still fairly generic (though maybe bgcolor= is rare enough these days that it could work).
Next best thing is to set the background-color of every sibling of Gmail's canonical link, which works except for thin strips on the left and right. Oh well.
html[lang="en"] body[bgcolor="#ffffff"],
*/
link[href="https://mail.google.com/mail/"] ~ * {
background-color: #222 !important;
}
@boredzo
boredzo / PRHAngleGradientFilter.h
Created June 1, 2013 21:48
Core Image custom filter to generate an angular gradient. The center is at the origin (0,0). You may want to use CIAffineTransform and/or CICrop on the output.
//
// PRHAngleGradientFilter.h
//
// Created by Peter Hosey on 2013-01-30.
// Copyright (c) 2013 Peter Hosey. All rights reserved.
//
#import <QuartzCore/QuartzCore.h>
@interface PRHAngleGradientFilter : CIFilter
@boredzo
boredzo / gist:4604459
Created January 23, 2013 11:04
Two-color angle gradient in Core Image
kernel vec4 coreImageKernel(__color startColor, __color endColor)
{
vec2 point = destCoord();
float angle = atan(point.y, point.x) + radians(180.0);
//Start from the upper middle, not the left middle
angle += radians(90.0);
angle = mod(angle, radians(360.0));
float fraction = angle / radians(360.0);
@boredzo
boredzo / YYYY.md
Created October 26, 2015 14:41
Unicode date formats, YYYY?!
@boredzo
boredzo / Untitled.out
Created December 18, 2012 05:30
Testing NSString compare:options:range: with a prefix range that is equal in both strings
2012-12-17 21:27:34.211 Untitled[10696:707] -1
2012-12-17 21:27:34.219 Untitled[10696:707] 0
@boredzo
boredzo / seeyouspacecowboy.sh
Last active July 21, 2018 17:47
A shell script to display SEE YOU SPACE COWBOY whenever you logout of your terminal!
#!/usr/bin/env bash
# SEE YOU SPACE COWBOY by DANIEL REHN (danielrehn.com)
# Displays a timeless message in your terminal with cosmic color effects
# Usage: add "sh ~/seeyouspacecowboy.sh; sleep 2" to .bash_logout (or similar) in your home directory
# (adjust the sleep variable to display the message for more seconds)
# Cosmic color sequence
@boredzo
boredzo / colorman.zsh
Last active June 19, 2017 14:44 — forked from cocoalabs/gist:2fb7dc2199b0d4bf160364b8e557eb66
Color Terminal for bash/zsh etc..
man() {
env \
LESS_TERMCAP_md=$'\e[1;36m' \
LESS_TERMCAP_me=$'\e[0m' \
LESS_TERMCAP_se=$'\e[0m' \
LESS_TERMCAP_so=$'\e[1;40;92m' \
LESS_TERMCAP_ue=$'\e[0m' \
LESS_TERMCAP_us=$'\e[1;32m' \
man "$@"
}