- Http://www.alexisgallagher.com
View excel_parseDates.vba
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
' Expects a datetimestr in the format "YYYYMMDD" with - or / or no separator | |
' Parses independently of local region, unlike VBA.DateTime.DateValue() | |
' Known-good on Excel for Mac Version 16.4 | |
Function parseYYYYMMDD(dateTimeStr As String) As Date | |
Dim normalized As String | |
normalized = VBA.Strings.Trim(dateTimeStr) | |
normalized = VBA.Strings.Replace(dateTimeStr, "/", "") | |
normalized = VBA.Strings.Replace(normalized, "-", "") |
View PKCS12.swift
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
// xcode 7.3 | |
import Foundation | |
/** | |
Struct representing values returned by `SecPKCS12Import` from the Security framework. | |
This is what Cocoa and CocoaTouch can tell you about a PKCS12 file. | |
*/ |
View ScaleAspectFitImageView.swift
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 UIKit | |
// known-good: Xcode 8.2.1 | |
/** | |
UIImageView subclass which works with Auto Layout to try | |
to maintain the same aspect ratio as the image it displays. | |
This is unlike the usual behavior of UIImageView, where the |
View Zipping.swift
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
// Zipping.swift | |
// known-good: Swift 4.2 | |
// Alexis Gallagher | |
import Foundation | |
public extension URL { | |
/// Creates a zip archive of the file or folder represented by this URL and returns a references to the zipped file | |
/// |
View Extra Logging for My Great App.mobileconfig
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<!-- iOS 10, macOS Sierra, and friends bring a new logging subsystem that's | |
supposed to scale from the kernel, up to frameworks, and up to apps. It defaults | |
to a more regimented, privacy-focused approach that large apps and complex | |
systems need. | |
It, along with Activity Tracing introduced in iOS 8 and macOS Yosemite and the | |
Console app in macOS Sierra, hope to help you graduate from caveman debugging to |
View colorize-emacs.bashsource
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. | |
# |
View loadPoints.swift
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 |
View tsv_to_json.swift
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 | |
*/ |
View plot_cm.py
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 |
View SwiftLineReader.swift
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) |
NewerOlder