Skip to content

Instantly share code, notes, and snippets.

banjun banjun

Block or report user

Report or block banjun

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
@banjun
banjun / MediaLibraryAccess.swift
Created May 1, 2019
macOS screenshots Photos access via MLMediaLibrary
View MediaLibraryAccess.swift
import Cocoa
import MediaLibrary
/// requires NSPhotoLibraryUsageDescription in info.plist
/// requires Pictures access in sandbox settings
final class PhotoSource: NSObject {
let photosLibrary = MLMediaLibrary(options: [
MLMediaLoadSourceTypesKey: MLMediaSourceType.image.rawValue,
MLMediaLoadIncludeSourcesKey: [MLMediaSourcePhotosIdentifier],
MLMediaLoadExcludeSourcesKey: [MLMediaSourcePhotoBoothIdentifier],
@banjun
banjun / beaconcapture.swift
Created Jan 24, 2019
Capture iBeacon packets and show them in Touch Bar
View beaconcapture.swift
#!/usr/bin/swift
import CoreBluetooth
import AppKit
class AppDelegate: NSResponder, CBCentralManagerDelegate, NSTouchBarDelegate, NSApplicationDelegate {
let manager: CBCentralManager
var advertises: [Advertise] = []
override init() {
manager = CBCentralManager(delegate: nil, queue: DispatchQueue.main)
View im@sparql-playground.swift
import Foundation
var str = "Hello, playground"
enum RDFT {
case iri(IRI)
case rdfl(RDFL)
// case rdfb(RDFB)
}
View FakeFirebaseInstanceID.swift
final class FakeFirebaseInstanceID: NSObject {
@objc class func instanceID() -> FakeFirebaseInstanceID? { return nil }
static private let once: Void = {
method_exchangeImplementations(
class_getClassMethod(NSClassFromString("FIRInstanceID"), #selector(FakeFirebaseInstanceID.instanceID))!,
class_getClassMethod(FakeFirebaseInstanceID.self, #selector(FakeFirebaseInstanceID.instanceID))!)
}()
static func silenceFirebaseCheckin() {
@banjun
banjun / プリパラDB(仮)用ショートカット.md
Last active Sep 24, 2018
プリパラDB(仮)用ショートカット
View プリパラDB(仮)用ショートカット.md
View CocoaBindingViewController.swift
import Cocoa
class ViewController: NSViewController {
let model = NSMutableDictionary()
private(set) lazy var controller: NSObjectController = .init(content: model)
let textView1 = NSTextView()
let textView2 = NSTextView()
override func viewDidLoad() {
super.viewDidLoad()
@banjun
banjun / WindowCapture.swift
Last active Jun 4, 2018
specific window capture implementation memo for https://github.com/mzp/HeartVoice
View WindowCapture.swift
import Cocoa
import CoreGraphics
import Vision
struct TargetWindow {
let id: CGWindowID
let bounds: CGRect
init?(appName: String, windowTitle: String) {
guard let windows = CGWindowListCopyWindowInfo(.optionAll, kCGNullWindowID) as? [[String: Any]] else { return nil }
View SR-2750.swift
// inspection whether repdocuces or not, SR-2750
// devxoul/Then a.k.a. `.then`
// banjun/ikemen a.k.a. `※`
func testWithTypeAnnotation() {
let user = User().then {
$0. // success completion
}
}
@banjun
banjun / SignalProducerFromFuture.swift
Created Feb 21, 2018
create SignalProducer that create Future with the autoclosure on start and send a result to the inner observer
View SignalProducerFromFuture.swift
extension SignalProducer {
// create SignalProducer that create Future with the autoclosure on start and send a result to the inner observer
init(_ future: @escaping @autoclosure () -> Future<Value, Error>) {
self.init { observer, _ in
future()
.onSuccess {
observer.send(value: $0)
observer.sendCompleted()}
.onFailure {
observer.send(error: $0)}
View keybase.md

Keybase proof

I hereby claim:

  • I am banjun on github.
  • I am banjun (https://keybase.io/banjun) on keybase.
  • I have a public key ASCKLh62-ATKJawCqVs88yAl7RXvjVxgeGpW0T1LsZnF8Ao

To claim this, I am signing this object:

You can’t perform that action at this time.