Skip to content

Instantly share code, notes, and snippets.

View cmyr's full-sized avatar
🖋️
font curious

Colin Rofls cmyr

🖋️
font curious
View GitHub Profile
@cmyr
cmyr / keybase.md
Created November 7, 2014 03:35
keybase.md

Keybase proof

I hereby claim:

  • I am cmyr on github.
  • I am cmyr (https://keybase.io/cmyr) on keybase.
  • I have a public key whose fingerprint is EBDF 6E34 C4B6 E898 9B04 A3F8 9003 3316 D794 8447

To claim this, I am signing this object:

@cmyr
cmyr / gist:1c1c6fe52d6fa57034a0
Created January 9, 2015 17:43
Compiler warnings for FIXME:
#!/bin/bash
WARNINGTAGS="FIXME:|\?\?\?:"
ERRORTAGS="\!\!\!:"
find "${SRCROOT}" \( -name "*.swift" -or -name "*.m" \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($WARNINGTAGS).*\$" | perl -p -e "s/($WARNINGTAGS)/ warning: \$1/"
if [ "${CONFIGURATION}" = "Release" ]
then
find "${SRCROOT}" \( -name "*.swift" -or -name "*.m" \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($ERRORTAGS).*\$" | perl -p -e "s/($ERRORTAGS)/ error: \$1/"
@cmyr
cmyr / suffix_simd.rs
Created September 11, 2018 23:17
Using simd in rust for suffix/prefix finding
const SSID_OPTS: i32 = _SIDD_UBYTE_OPS | _SIDD_CMP_EQUAL_EACH | _SIDD_UNIT_MASK
| _SIDD_LEAST_SIGNIFICANT | _SIDD_NEGATIVE_POLARITY;
/// # Examples
///
/// ```
/// let one = "aaaaaaaaaaaaaaaa";
/// let two = "aa3aaaaa9aaaEaaa";
/// //NOTE: reversed
/// let exp = "0001000100000100";

2018-12-27

Update: line breaking and view revisions

So I had a frustrating week, last week. I'd been spending much of december working on a long-standing feature for xi, line breaking / word wrap. That is; the ability to wrap lines of text to the width of the window, as needed. This is table stakes for a text editor (or a text view, or a web browser, or anything that displays text in a variable width window) but it's something we had until now only half-done.

Background

This problem has some nuance. To back up: We have a string, and we have a width (of a window, say), and we need to determine how to break the string up so that it fits in the given window. To do this, we need to know two things at runtime: where in the string we are allowed to create a line break (the break opportunities), and the width required to draw various 'atoms' of the string, where an 'atom' is a sub-string that cannot contain a line break.

@cmyr
cmyr / rust-tips.md
Last active June 23, 2022 21:58
Rust quick tips collection

Rust Tips & Suggestions

Struct forms:

There are three struct forms: unit structs, tuple structs, and named field structs:

struct UnitStruct;
struct TupleStruct(String, usize);
struct NamedStruct { string: String, is_cuss_word: bool }