Skip to content

Instantly share code, notes, and snippets.

View chearon's full-sized avatar

Caleb Hearon chearon

View GitHub Profile
@chearon
chearon / scroll.fish
Last active January 10, 2018 20:22
Place in your ~/.config/fish/functions folder. The "scroll" command will then toggle macOS/classic style scrollbars to help test websites.
function scroll
set state (defaults read NSGlobalDomain AppleShowScrollBars)
if [ $state = "Automatic" ]
set state "Always"
echo "Scrollbars set to classic (always visible)"
else
set state "Automatic"
echo "Scrollbars set to normal macOS (autohide, zero width)"
end
@chearon
chearon / init.vim
Last active September 6, 2022 07:09
The best possible neovim configuration
" Neovim-only, use in true color terminal
" Vundle config
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" Vundle vundles
Plugin 'VundleVim/Vundle.vim'
Plugin 'ap/vim-css-color'
Plugin 'hail2u/vim-css3-syntax'
@chearon
chearon / whatsthefont.c
Last active December 23, 2016 21:19
Compare FT and OSX font weights for a font
#include <CoreFoundation/CoreFoundation.h>
#include <CoreGraphics/CoreGraphics.h>
#include <CoreText/CoreText.h>
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_TRUETYPE_TABLES_H
#include FT_SFNT_NAMES_H
#include FT_TRUETYPE_IDS_H
#ifndef FT_SFNT_OS2
#define FT_SFNT_OS2 ft_sfnt_os2
@chearon
chearon / test_prefer_pango.sh
Last active May 5, 2016 14:12
Test node-canvas#prefer-pango w google fonts
G_FONTS_DIR=gfonts
NODE_CANVAS_DIR="./node-canvas"
mkdir -p pngs
find $G_FONTS_DIR -name '*.ttf' | while read i; do
echo $i;
cat <<EOT | node
var path = require('path'),
@chearon
chearon / describe_font.c
Created April 4, 2016 15:03
Print the family name, weight, style, and width of a specification string given to Pango
#include <pango/pango.h>
#include <glib.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
char*
get_arg_string(int argc, char** argv)
{
size_t total_len = 0;
@chearon
chearon / png_to_svg.sh
Last active June 16, 2017 15:37
Easy script to convert a folder of PNGs to same-sized SVGs using potrace
#!/bin/bash
# Run this in a directory of PNGs (or change *.png to *.jpg, *.gif, etc)
# It will make SVGs with the same name, at the same size as the PNGs
#
# DEPENDENCIES: imagemagick, potrace, mkbitmap (included in potrace)
# Adjust the following settings to get better results:
OPTTOLERANCE=.2 # 0 for angular images
CURVETHRESHOLD=1 # larger for less segments