Skip to content

Instantly share code, notes, and snippets.

@leonbreedt
leonbreedt / keybase.md
Created March 25, 2014 07:12
keybase.md

Keybase proof

I hereby claim:

  • I am bitserf on github.
  • I am bitserf (https://keybase.io/bitserf) on keybase.
  • I have a public key whose fingerprint is 8EDF 16F2 41C9 8880 5D60 19FD C7FC 3270 F57F A785

To claim this, I am signing this object:

@leonbreedt
leonbreedt / iTermColorsToTerminalColors.swift
Last active May 16, 2024 19:50
Convert iTerm2 color scheme to Terminal.app color scheme. To use, just save to disk and run it like you would any script. NOTE: Needs Xcode 8.0 or later, since it has been ported to Swift 3.0.
#!/usr/bin/xcrun swift
//
// Copyright © 2016 Leon Breedt
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
@leonbreedt
leonbreedt / buildglyphs.js
Created September 12, 2015 20:36
buildglyphs.js from OS X
{
var r0_fs, r0_path, r0_Glyph, r0_Stroke, r0_tp, r0_inverse, r0_libspiro, r0_SpiroExpansionContext, r0_toml, r0_mix, r0_linreg, r0_bilinear, r0_fallback, r0_emptyFontStr, r0_buildFont, _r0_t0, _r0_t1, _r0_t2, _r0_t3, _r0_t4;
r0_fs = require('fs');
r0_path = require('path');
r0_Glyph = require('./support/glyph').Glyph;
r0_Stroke = require('./support/stroke').Stroke;
r0_tp = require('./support/transform').transformPoint;
r0_inverse = require('./support/transform').inverse;
r0_libspiro = require('libspiro-js');
r0_SpiroExpansionContext = require('./support/spiroexpand').SpiroExpansionContext;
@leonbreedt
leonbreedt / gist:dcf129ec74a430ba51e3
Created September 13, 2015 04:46
glyphs object dump
node generate regular build/.pass0-iosevka-regular.ttf --dumpmap build/iosevka-regular.charmap --dumpfeature build/.pass0-iosevka-regular.ab.fea
Building /.notdef for Iosevka Regular
Building /space for Iosevka Regular
Building /dotAbove for Iosevka Regular
Building /dieresisAbove for Iosevka Regular
Building /ringAbove for Iosevka Regular
Building /graveAbove for Iosevka Regular
Building /acuteAbove for Iosevka Regular
Building /circumflexAbove for Iosevka Regular
Building /caronAbove for Iosevka Regular
@leonbreedt
leonbreedt / FontPreview.swift
Last active July 13, 2018 02:43
Render font from command line on OS X without requiring font to be installed.
//
// FontPreview
// Copyright © 2018 Leon Breedt
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
@leonbreedt
leonbreedt / SimpleAttributedStringStyles.swift
Last active June 6, 2016 08:13
Simple attributed string styles
import Cocoa
/// Enumerates the types of fonts supported for attributed strings.
enum TextFontType {
case System
case Named(String)
}
@leonbreedt
leonbreedt / CustomPropertyJSValueLifetime.swift
Last active January 21, 2021 17:00
JavaScriptCore custom property JSValue lifetime
import Cocoa
import JavaScriptCore
/// Something that can be represented as a `JSValue`.
protocol JSValueRepresentable {
/// The `JSValue` for this thing.
var jsValue: JSValue { get }
}
### Keybase proof
I hereby claim:
* I am leonbreedt on github.
* I am leonbreedt (https://keybase.io/leonbreedt) on keybase.
* I have a public key whose fingerprint is 8EDF 16F2 41C9 8880 5D60 19FD C7FC 3270 F57F A785
To claim this, I am signing this object:
@leonbreedt
leonbreedt / main.rs
Created April 25, 2019 02:19
main.rs - no extracted function
mod api;
mod db;
mod models;
use pretty_env_logger;
use std;
use std::net::SocketAddr;
use warp::{self, Filter};
fn main() {
@leonbreedt
leonbreedt / api.rs
Created April 25, 2019 02:23
api.rs - extracted function
pub fn customers(pool: &'static db::ConnectionPool) -> impl warp::Filter {
// Clone pool in filter chain so child threads can access it safely.
let database = warp::any().map(move || pool.clone());
let customers = warp::path("customers");
let customers_index = customers.and(warp::path::end());
let customer_by_id = customers
.and(warp::path::param::<i64>())
.and(warp::path::end());