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
## From http://stackoverflow.com/questions/2311750/change-file-encoding-to-utf-8-via-vim-in-a-script | |
#This is the simplest way I know of to do this easily from the command line: | |
vim +"argdo se bomb | se fileencoding=utf-8 | w" $(find . -type f -name *.rb) | |
#Or better yet if the number of files is expected to be pretty large: | |
find . -type f -name *.rb | xargs vim +"argdo se bomb | se fileencoding=utf-8 | w" |
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
+ (UIFont *)uifontFromCTFontRef:(CTFontRef)ctFont { | |
CGFloat pointSize = CTFontGetSize(ctFont); | |
NSString *fontPostScriptName = (NSString *)CFBridgingRelease(CTFontCopyPostScriptName(ctFont)); | |
UIFont *fontFromCTFont = [UIFont fontWithName:fontPostScriptName size:pointSize]; | |
return fontFromCTFont; | |
} | |
+ (CTFontRef)ctFontRefFromUIFont:(UIFont *)font { | |
CTFontRef ctfont = CTFontCreateWithName((__bridge CFStringRef)font.fontName, font.pointSize, NULL); | |
return CFAutorelease(ctfont); |
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 | |
extension FileHandle { | |
/// Return an iterator over the bytes in the file. | |
/// | |
/// - returns: An iterator for UInt8 elements. | |
public func bytes() -> FileHandleByteIterator { | |
return FileHandleByteIterator(fileHandle: self) | |
} |
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
// USB Vendor ID: 0x05AC | |
// USB Product ID: 0x0251 | |
/* The upper label indicates the key's function. | |
* The lower label indicates the USB/HID Keyboard report value. | |
* The keyboard report (endpoint 0x81) has the following data structure: | |
* ``` | |
* struct kdb_report { | |
* uint8_t modifier; | |
* uint8_t reserved; |
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
class TranslucentWin:NSWindow, NSApplicationDelegate, NSWindowDelegate{ | |
/** | |
* | |
*/ | |
override init(contentRect: NSRect, styleMask aStyle: Int, backing bufferingType: NSBackingStoreType, `defer` flag: Bool) { | |
super.init(contentRect: Win.sizeRect, styleMask: NSTitledWindowMask|NSResizableWindowMask|NSMiniaturizableWindowMask|NSClosableWindowMask|NSFullSizeContentViewWindowMask, backing: NSBackingStoreType.Buffered, `defer`: false) | |
self.contentView!.wantsLayer = true;/*this can and is set in the view*/ | |
self.backgroundColor = NSColor.greenColor().alpha(0.2) | |
self.opaque = false | |
self.makeKeyAndOrderFront(nil)//moves the window to the front |
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
// | |
// NSWindow+Fade.swift | |
// BH Bezel Notification | |
// | |
// Created by Ben Leggiero on 2017-11-09. | |
// Translated to Swift 4 from the original (ObjC): https://gist.github.com/indragiek/1397050 | |
// Copyright © 2017 Ben Leggiero. All rights reserved. | |
// | |
import Foundation |
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
#!/bin/bash | |
set -eu | |
SYSCTL_FILE=/etc/sysctl.d/90-tcp-bbr.conf | |
# check root | |
if [[ $EUID -ne 0 ]]; then | |
echo "This script must be run as root" | |
exit 1 | |
fi |
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
func windowScene(_ windowScene: UIWindowScene, | |
didUpdate previousCoordinateSpace: UICoordinateSpace, | |
interfaceOrientation previousInterfaceOrientation: UIInterfaceOrientation, | |
traitCollection previousTraitCollection: UITraitCollection) { | |
// windowScene.coordinateSpace.bounds | |
// windowScene.interfaceOrientation.isLandscape | |
} |
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
func openAndSelectFile(filename:String){ | |
let files = [NSURL(fileURLWithPath: filename)]; | |
NSWorkspace.sharedWorkspace().activateFileViewerSelectingURLs(files); | |
} |
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 | |
// "".hexData.hexString // | |
// "01".hexData.hexString // 01 | |
// "ab".hexData.hexString // ab | |
// "abff 99".hexData.hexString // abff99 | |
// "abff\n99".hexData.hexString // abff99 | |
// "abzff 99".hexData.hexString // ab | |
// "abf ff 99".hexData.hexString // ab | |
// "abf".hexData.hexString // ab |
OlderNewer