Skip to content

Instantly share code, notes, and snippets.

Avatar

Miklós kmikiy

View GitHub Profile
@NicholasBellucci
NicholasBellucci / ScrollingTextView.swift
Last active Jun 29, 2021
MacOS swift marquee scrolling text view
View ScrollingTextView.swift
import Cocoa
open class ScrollingTextView: NSView {
// MARK: - Open variables
/// Text to scroll
open var text: NSString?
/// Font for scrolling text
open var font: NSFont?
@danieltmbr
danieltmbr / map-joined-reduce.swift
Last active Sep 21, 2017
Compare performance reduce to joined & map+joined
View map-joined-reduce.swift
/**
Measuring the performance of reduce compared to joined and map+joined.
Spoiler: map+joined way more faster!!!
Try this code in a .playground file if you want.
*/
func measure(closure: (()->Void)) {
let start = Date()
closure()
@matthewreagan
matthewreagan / controlclick.swift
Last active Jan 3, 2019
Fixing control-click vs right-click contextual menus in NSView
View controlclick.swift
override func mouseDown(theEvent: NSEvent)
{
/* Hard-coding this behavior isn't great, and shouldn't be necessary. (It should
be up to OS X to define what a contextual-menu click is/isn't, and we should
only care about vending our NSMenu via `menuForEvent:`). */
let modifierFlags = theEvent.modifierFlags;
if (modifierFlags.contains(.ControlKeyMask))
{