This file contains 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
# sourcing this file will define a bash functions that | |
# tries to run subsequent calls to emacs with 24 bit color. | |
# | |
# It sets TERM=xterm-emacs-leg if | |
# - we've created a user-local terminfo record for xterm-emacs-leg, and | |
# - we're using iTerm2 or something has set COLORTERM=truecolor | |
# | |
# This will cause emacs to use 24 bit color only when it will work, | |
# inside or outside of tmux. I haven't found a way to auto-detect Blink.sh yet. | |
# |
This file contains 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
// known-good: Swift 4.2, macOS | |
import Foundation | |
import ModelIO | |
private func LogDebug(_ s:Any) -> Void { print(s) } | |
private func LogInfo(_ s:Any) -> Void { print(s) } | |
private func LogError(_ s:Any) -> Void { print(s) } | |
struct POINT3D { | |
var x:Float |
This file contains 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
import Foundation | |
// Swift 2.0 | |
// poor man's parsers for (TSV) tab-separated value files | |
// for something more full-featured, the best avenue is CHCSVParser | |
/** | |
Reads a multiline, tab-separated String and returns an Array<NSictionary>, taking column names from the first line or an explicit parameter | |
*/ |
This file contains 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
# This uses scikit learn internals, since the sk public API requires you to pass | |
# in an estimator and sometimes you just want to pass in the some data you'd | |
# use to calculate a raw CM | |
def plot_cm(y_true,y_pred,labels): | |
from sklearn.metrics._plot.confusion_matrix import ConfusionMatrixDisplay | |
sample_weight = None | |
normalize = None | |
include_values = True |
This file contains 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
import Darwin | |
/** | |
Returns a lazy sequence that returns a String for every line of `file`. | |
Example 1: | |
// print all lines from a file | |
let file = fopen(NSBundle.mainBundle().pathForResource("Cartfile", ofType: nil)!,"r") | |
for line in lineGenerator(file) { print(line,separator: "", terminator: "") } | |
fclose(file) |
This file contains 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
import Foundation | |
import AVFoundation | |
import ImageIO | |
import MobileCoreServices | |
import BespokeCore | |
struct FrameInfo { | |
var frame:CGImage | |
var frameDuration:TimeInterval |
This file contains 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
/// An `OutputStreamType` which uses GCD to write to a file | |
class FileOutputStream : OutputStreamType | |
{ | |
private let filepath:NSURL | |
private let channel:dispatch_io_t! | |
/** | |
Initializes output stream to write to `filename` in the user's Documents directory. | |
*/ |
This file contains 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
:;exec emacs --no-init-file --no-site-lisp -script "$0" -- "$@" # -*- mode:emacs-lisp -*- | |
(defun main () | |
(require 'cl-lib) | |
(let ((script-name (nth 2 command-line-args)) | |
(args (cdr command-line-args-left))) | |
;; assert: ARGS now is a possibly empty list of command line args to the script | |
;; check for valid arguments here | |
(when (not args) | |
(princ (format "usage: %s PATH_TO_FILE" script-name)) |
This file contains 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
import Darwin | |
import Foundation | |
// known good: Swift 5 | |
// runs on macOS, probably works on iOS (but haven't tried) | |
/// Wraps `host_statistics64`, and provides info on virtual memory | |
/// | |
/// - Returns: a `vm_statistics64`, or nil if the kernel reported an error | |
/// |
This file contains 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
// known-good: Xcode 8, Swift 3 | |
import Foundation | |
var standardError = FileHandle.standardError | |
extension FileHandle : TextOutputStream { | |
public func write(_ string: String) { | |
guard let data = string.data(using: .utf8) else { return } |