Skip to content

Instantly share code, notes, and snippets.

Charlton Provatas cprovatas

Block or report user

Report or block cprovatas

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
cprovatas / gist:6acef442fc43123bcd5d5e937dc7951a
Created Jan 6, 2018
Monitor Mouse Event for any arbitrary application on macOS in Swift
View gist:6acef442fc43123bcd5d5e937dc7951a
let callback: CGEventTapCallBack = { (tapProxy, eventType, event, refcon) -> Unmanaged<CGEvent>? in
debugPrint("we are monitoring the mouse event here")
return nil
let eventMask = (1 << CGEventType.leftMouseDown.rawValue) | (1 << CGEventType.leftMouseUp.rawValue)
let machPort = CGEvent.tapCreateForPid(pid: 40529, place: .tailAppendEventTap, options: .defaultTap, eventsOfInterest: CGEventMask(eventMask), callback: callback, userInfo: nil)!
let runLoopSource = CFMachPortCreateRunLoopSource(kCFAllocatorDefault, machPort, 0)
cprovatas / BlockBasedSelector.h
Last active Sep 25, 2019
Block-Based Selectors in Swift
View BlockBasedSelector.h
// BlockBasedSelector.h
// Created by Charlton Provatas on 11/2/17.
// Copyright © 2017 CharltonProvatas. All rights reserved.
#import <Foundation/Foundation.h>
@interface BlockBasedSelector : NSObject
cprovatas / gist:8d4dafaa13da058da32b0f68f625b424
Created Oct 19, 2017
Solution to eliminate boilerplate code when Implementing Equatable for Associated Value Enums
View gist:8d4dafaa13da058da32b0f68f625b424
import UIKit
protocol AutoEquatableEnum {
static func == (lhs: Self, rhs: Self) -> Bool
extension AutoEquatableEnum {
static func == (lhs: Self, rhs: Self) -> Bool {
return ==
You can’t perform that action at this time.