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
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
#!/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
// 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
(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
; 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
(defn convert [](with-open [rdr (reader "/Users/zhaowang/workspace/clojure/labrepl/data/words")] | |
(doseq [line (take 2000 (line-seq rdr))] | |
(writeToFile (str "\"" line "\"" ","))))) | |
(defn writeToFile [line] | |
(with-open [wrtr (writer "test.json" :append true)] | |
(.write wrtr line))) |
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
(ns scratch.core) | |
(defn dividable? [number] | |
#(zero? (mod number %)) | |
) | |
(defn dividableByAny? [number divList] | |
(> (count (filter (dividable? number) divList)) 0) | |
) |
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
You can easily remove all the trailing whitespace within a single file by using | |
a regular expression with the Find/Replace dialog. Enter [ \t]+$ in the "Find:" box | |
and leave the "Replace with:" box empty. Check the "Regular expressions" option | |
then click "Replace All" |
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
<style> | |
#outer | |
{ | |
background:red; | |
display:table; | |
width: 100%; | |
height:600px; | |
} | |
#inner | |
{ |