This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; From Clojure: the JFDI language by Michael O. Church | |
; https://docs.google.com/presentation/d/16ccLdZ6Epp6Nu-lMansEErwAjbN4sau4LztaARmdl_k/edit#slide=id.g1793dde48_1508 | |
; Motivation: runtime tracing of functions is a powerful debug technique. | |
; It’d require a framework to do this in Java, but in Clojure, a macro suffices! | |
(defmacro tracing [code] | |
`(do | |
(println "The code was: " '~code) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(dotimes [n (read-string (read-line))] | |
(let [x (read-string (read-line)), | |
ex (fn [x] | |
(inc | |
(reduce + | |
(map #(/ (reduce * (repeat % x)) | |
(reduce * (range 1 (inc %))) | |
) | |
(range 1 10) | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Note: This must be used in an Xcode project that contains a bridging header | |
// that includes <asl.h> | |
import Foundation | |
/// Provides high-level methods to access the raw data in | |
/// an ASL message. | |
struct SystemLogEntry { | |
/// Key-value pairs read from ASL message | |
let data: [String : String] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
device_types_output = `xcrun simctl list devicetypes` | |
device_types = device_types_output.scan /(.*) \((.*)\)/ | |
runtimes_output = `xcrun simctl list runtimes` | |
runtimes = runtimes_output.scan /(.*) \(.*\) \((com.apple[^)]+)\)$/ | |
devices_output = `xcrun simctl list devices` | |
devices = devices_output.scan /\s\s\s\s(.*) \(([^)]+)\) (.*)/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static func loadFont(fontName: String, baseFolderPath: String) -> Bool { | |
let basePath = baseFolderPath as NSString | |
let fontFilePath = basePath.stringByAppendingPathComponent(fontName) | |
let fontUrl = NSURL(fileURLWithPath: fontFilePath) | |
if let inData = NSData(contentsOfURL: fontUrl) { | |
var error: Unmanaged<CFError>? | |
let cfdata = CFDataCreate(nil, UnsafePointer<UInt8>(inData.bytes), inData.length) | |
if let provider = CGDataProviderCreateWithCFData(cfdata) { | |
if let font = CGFontCreateWithDataProvider(provider) { | |
if (!CTFontManagerRegisterGraphicsFont(font, &error)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class JSCContextTests: XCTestCase { | |
var jscContext: JSContext! | |
override func setUp() { | |
jscContext = JSContext() | |
let log_Binder: @convention(block) String -> Void = { input in | |
print(input) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/apple/swift/pull/348 | |
private func getDoubleStrWith16DecimalDigits(value: Double) -> String { | |
return String(format: "%.16f", value) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
modulesDirectory=$DERIVED_FILES_DIR/modules | |
modulesMap=$modulesDirectory/module.modulemap | |
modulesMapTemp=$modulesDirectory/module.modulemap.tmp | |
mkdir -p "$modulesDirectory" | |
cat > "$modulesMapTemp" << MAP | |
module sqlite3 [system] { |