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 / 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 / beaconcapture.swift
Created Jan 24, 2019
Capture iBeacon packets and show them in Touch Bar
View beaconcapture.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 = {
class_getClassMethod(NSClassFromString("FIRInstanceID"), #selector(FakeFirebaseInstanceID.instanceID))!,
class_getClassMethod(FakeFirebaseInstanceID.self, #selector(FakeFirebaseInstanceID.instanceID))!)
static func silenceFirebaseCheckin() {
banjun / プリパラDB(仮)用ショートカット.md
Last active Sep 24, 2018
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() {
banjun / WindowCapture.swift
Last active Jun 4, 2018
specific window capture implementation memo for
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 / 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
.onSuccess {
observer.send(value: $0)
.onFailure {
observer.send(error: $0)}

Keybase proof

I hereby claim:

  • I am banjun on github.
  • I am 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.