Skip to content

Instantly share code, notes, and snippets.

totally useless

Colin Rofls cmyr

View GitHub Profile
cmyr /
Last active Feb 23, 2019
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 }
View async word wrap post


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.


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 /
Created Sep 11, 2018
Using simd in rust for suffix/prefix finding
/// # Examples
/// ```
/// let one = "aaaaaaaaaaaaaaaa";
/// let two = "aa3aaaaa9aaaEaaa";
/// //NOTE: reversed
/// let exp = "0001000100000100";
cmyr / gist:1c1c6fe52d6fa57034a0
Created Jan 9, 2015
Compiler warnings for FIXME:
View gist:1c1c6fe52d6fa57034a0
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" ]
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/"

Keybase proof

I hereby claim:

  • I am cmyr on github.
  • I am 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:

You can’t perform that action at this time.