Skip to content

Instantly share code, notes, and snippets.

View zqqf16's full-sized avatar
:electron:
Focusing

zqqf16 zqqf16

:electron:
Focusing
View GitHub Profile
@zqqf16
zqqf16 / CorsProxy.swift
Created January 22, 2017 08:54 — forked from sciolist/CorsProxy.swift
GCDWebServer Cors proxy
import GCDWebServer
class CorsProxy {
init(webserver : GCDWebServer!, urlPrefix: String) {
var prefix =
(urlPrefix.hasPrefix("/") ? "" : "/")
+ urlPrefix
+ (urlPrefix.hasSuffix("/") ? "" : "/")
let pattern = "^" + NSRegularExpression.escapedPatternForString(prefix) + ".*"
@zqqf16
zqqf16 / DynamicFunctions.swift
Created August 4, 2016 07:26 — forked from neonichu/DynamicFunctions.swift
Using dlopen / dlsym to call C functions from Swift
import Darwin
let handle = dlopen("/usr/lib/libc.dylib", RTLD_NOW)
let sym = dlsym(handle, "random")
let functionPointer = UnsafeMutablePointer<() -> CLong>(sym)
let result = functionPointer.memory()
println(result)
#!/bin/sh
PLIST_BUDDY=/usr/libexec/PlistBuddy
function add_compatibility() {
"$PLIST_BUDDY" -c "Add DVTPlugInCompatibilityUUIDs:10 string $2" \
"$1/Contents/Info.plist"
}
function has_compatibility() {