Skip to content

Instantly share code, notes, and snippets.

@raphlinus
raphlinus / OldJson.swift
Created December 29, 2017 19:08
Simple JSON task using old "idiomatic" Swift
// Copyright 2017 Google LLC
//
// 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
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
@raphlinus
raphlinus / update.json
Created December 29, 2017 18:49
A typical xi-editor update notification sampled from an edit session
{"method":"update","params":{"update":{"ops":[{"n":6374,"op":"invalidate"},{"n":18,"op":"invalidate"},{"n":87,"op":"invalidate"},{"n":101,"op":"invalidate"},{"n":6580,"op":"skip"},{"n":56,"op":"copy"},{"n":63,"op":"invalidate"},{"n":63,"op":"skip"},{"n":56,"op":"copy"},{"n":61,"op":"invalidate"},{"n":61,"op":"skip"},{"n":56,"op":"copy"},{"n":59,"op":"invalidate"},{"n":59,"op":"skip"},{"n":56,"op":"copy"},{"n":57,"op":"invalidate"},{"n":57,"op":"skip"},{"n":56,"op":"copy"},{"n":55,"op":"invalidate"},{"n":55,"op":"skip"},{"n":56,"op":"copy"},{"n":53,"op":"invalidate"},{"n":53,"op":"skip"},{"n":56,"op":"copy"},{"n":52,"op":"invalidate"},{"n":52,"op":"skip"},{"n":56,"op":"copy"},{"n":49,"op":"invalidate"},{"lines":[{"styles":[0,1,3,0,5,5,0,6,3,0,1,4,0,1,3,0,7,6,0,2,3],"text":"\tinput.type = \"radio\";\n"},{"styles":[0,1,3,0,7,5,0,12,3,0,1,4,0,1,3,0,5,5,0,7,3,0,3,4,0,1,3,0,3,6,0,2,3],"text":"\tsupport.radioValue = input.value === \"t\";\n"},{"styles":[0,7,3],"text":"} )();\n"},{"styles":[0,1,3],"text":"\n"},{"styl
@raphlinus
raphlinus / text.f.glsl
Created December 14, 2017 15:59
text compositing fragment shader
// Copyright 2017 Google LLC.
//
// 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
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
@IBAction func shapingToy(_: Any) {
print("shaping toy start")
//let text = "hello 😀 العالمية"
let text = "hello this is a pretty long string that's designed to see what the effect on shaping is. Probably it's not something we need to worry about"
let font = NSFont(name: "Inconsolata", size: 14)!
let attributes: [NSAttributedStringKey: AnyObject] = [
NSAttributedStringKey.font: font,
]
let attrString = NSMutableAttributedString(string: text, attributes: attributes)
// benchmark time!