Skip to content

Instantly share code, notes, and snippets.

@killgxlin
killgxlin / gist:0a28ca18cca9303ebd6c8187ad23de95
Created Jan 16, 2020
osx1015 设置 ScreenCapture 权限
View gist:0a28ca18cca9303ebd6c8187ad23de95
#import <Foundation/Foundation.h>
#import <CoreVideo/CoreVideo.h>
#import <AppKit/AppKit.h>
BOOL canRecordScreen()
{
if (@available(macOS 10.15, *)) {
CFArrayRef windowList = CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly, kCGNullWindowID);
NSUInteger numberOfWindows = CFArrayGetCount(windowList);
NSUInteger numberOfWindowsWithName = 0;
@killgxlin
killgxlin / main.go
Created Aug 27, 2019 — forked from LiamHaworth/main.go
Example of run an interactive process on the current user from system service on windows (Golang)
View main.go
package main
import (
"github.com/kardianos/service"
"log"
"flag"
)
type Service struct {}
View example.cpp
int
write_json(int wfd, Document &doc) {
auto &al = doc.GetAllocator();
GenericStringBuffer<UTF8<>, Document::AllocatorType> sb(&al);
PrettyWriter<GenericStringBuffer<UTF8<>, Document::AllocatorType>, UTF8<>, UTF8<>, Document::AllocatorType > sbwr(sb, &al);
doc.Accept(sbwr);
return strndup(sb.GetString(), sb.GetSize());
uint32_t size = sb.GetSize();
assert(write(wfd, &size, sizeof(size)) == sizeof(size));
@killgxlin
killgxlin / libevent_example.c
Last active Aug 29, 2015
a libevent example
View libevent_example.c
/*
============================================================================
Name : libevent_sample.c
Author : killerg
Version :
Copyright : Your copyright notice
Description : Hello World in C, Ansi-style
============================================================================
*/