Skip to content

Instantly share code, notes, and snippets.

View stuartcarnie's full-sized avatar

Stuart Carnie stuartcarnie

View GitHub Profile
@stuartcarnie
stuartcarnie / influxql.ebnf
Last active May 17, 2017 00:53
EBNF for InfluxQL
// queries
query ::= statement ( ";" statement )*
statement ::= alter_retention_policy_stmt |
create_continuous_query_stmt |
create_database_stmt |
create_retention_policy_stmt |
create_subscription_stmt |
create_user_stmt |
@stuartcarnie
stuartcarnie / LICENSE.txt
Last active July 11, 2021 18:30
Clang API notes schema definition
Copyright 2020 Stuart Carnie
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
http://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,
@stuartcarnie
stuartcarnie / NSEvent+Publisher.swift
Last active March 5, 2023 19:08
Combine Publisher support for NSEvent.addLocalMonitorForEvents
@available(macOS 10.15, *)
extension NSEvent {
static func publisher(scope: Publisher.Scope, matching: EventTypeMask) -> Publisher {
return Publisher(scope: scope, matching: matching)
}
public struct Publisher: Combine.Publisher {
public enum Scope {
case local, global
}
@stuartcarnie
stuartcarnie / LogNotifications.swift
Created January 23, 2022 23:22
Watch all notifications posted to Notification Center
// Place this early in your application's startup process, such as an init
let cb: CFNotificationCallback = { (centre: CFNotificationCenter?, observer: UnsafeMutableRawPointer?, name: CFNotificationName?, object: UnsafeRawPointer?, userInfo: CFDictionary?) in
print("Notification: ", terminator: "")
if let name = name {
print("(\(name.rawValue)) ")
} else {
print()
}