Skip to content

Instantly share code, notes, and snippets.

View kmikiy's full-sized avatar

Miklós kmikiy

View GitHub Profile
@danieltmbr
danieltmbr / map-joined-reduce.swift
Last active September 21, 2017 09:57
Compare performance reduce to joined & map+joined
/**
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 January 3, 2019 09:16
Fixing control-click vs right-click contextual menus in NSView
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))
{
@NicholasBellucci
NicholasBellucci / ScrollingTextView.swift
Last active March 1, 2024 03:37
MacOS swift marquee scrolling text view
import Cocoa
open class ScrollingTextView: NSView {
// MARK: - Open variables
/// Text to scroll
open var text: NSString?
/// Font for scrolling text
open var font: NSFont?