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/sh | |
# usage: waitfor.sh myserver.example.com | |
ping_func(){ | |
host="$1" | |
$(ping -c 1 -t 1 "$host" &> /dev/null) | |
return $? | |
} | |
result=2 |
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+CharacterWidth.m | |
- (CGFloat)characterWidth | |
{ | |
CGFloat characterWidth = 0.0; | |
// get the width of a character by doing a layout with two spaces and measuring the position of the second glyph | |
NSAttributedString *measureAttributedString = [[NSAttributedString alloc] initWithString:@" " attributes:@{ NSFontAttributeName: self }]; | |
CTLineRef lineRef = CTLineCreateWithAttributedString((CFAttributedStringRef)measureAttributedString); | |
CFArrayRef arrayRef = CTLineGetGlyphRuns(lineRef); |
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/sh | |
basename=`basename $0` | |
if [ -z "$*" ]; then | |
echo "usage: ${basename} <dot> [ -o | -r | <file> | - ]" | |
echo "" | |
echo "options:" | |
echo " -o open dot in window with keyboard focus" | |
echo " -r read contents of dot" |
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
BOOL canRecordScreen = YES; | |
if (@available(macOS 10.15, *)) { | |
canRecordScreen = NO; | |
NSRunningApplication *runningApplication = NSRunningApplication.currentApplication; | |
NSNumber *ourProcessIdentifier = [NSNumber numberWithInteger:runningApplication.processIdentifier]; | |
CFArrayRef windowList = CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly, kCGNullWindowID); | |
NSUInteger numberOfWindows = CFArrayGetCount(windowList); | |
for (int index = 0; index < numberOfWindows; index++) { | |
// get information for each window |
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
There are a couple of problems with the new formatting bar: | |
1) The icon to turn it on/off doesn't make sense. It's a toolbar, and the "Aa" doesn't get that concept across. It's in a strange place, next to "@" and ":-)", icons that cause an element to come up over the text field without changing it. A lot of smart folks aren't figuring this out (and let's face it, no one reads the fricken' manual.) Don't believe me, check out the replies to this tweet: | |
https://twitter.com/chockenberry/status/1196992017143779328 | |
2) Once you have the epiphany to turn it off, it doesn't turn off the functionality. I've been using Markdown since it was just a glint in John Gruber's eye, and it's actually easier for me to _read_ text *like this* even when it contains `code`. | |
If I opt out of the formatting bar, it feels like I should be opting out the fancy completion stuff, too. |
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
// | |
// Debug.swift | |
// | |
// Created by Craig Hockenberry on 3/15/17. | |
// Updated by Craig Hockenberry on 2/20/24. | |
// Usage: | |
// | |
// SplineReticulationManager.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
// Created by Sean Heber on 4/12/12. | |
#import <UIKit/UIKit.h> | |
// If you work with a designer who specifies color in sRGB using 102,0,204, this category makes it simpler to instantiate | |
// a color with that specification: [UIColor colorWithRGB:102:0:204 alpha:1.0]; | |
@interface UIColor (RGB) | |
// NOTE: If you're using the extended sRGB color space, you'll want to use something other than UInt8 :-) | |
+ (UIColor *)colorWithRGB:(UInt8)r :(UInt8)g :(UInt8)b alpha:(CGFloat)alpha; |
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/sh | |
defaults read com.apple.finder CreateDesktop > /dev/null 2>&1 | |
enabled=$? | |
if [ "$1" = "off" ]; then | |
if [ $enabled -eq 1 ]; then | |
defaults write com.apple.finder CreateDesktop false | |
osascript -e 'tell application "Finder" to quit' | |
open -a Finder |
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
In the next version of iPulse, I'd like to show GPU statistics. Unfortunately, the format | |
for these statistics is vendor specfic (see the "Performance Statistics" dictionary below.) | |
In order to cover as many devices as possible, I'd like you to run the following commands | |
from your Terminal: | |
$ sysctl hw.model | |
$ ioreg -r -d 1 -w 0 -c "IOAccelerator" | |
You can help me read the results by putting them in a code block (triple backticks). |
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
$ spctl --verbose=4 --assess --type execute xScope.app | |
xScope.app: rejected | |
source=obsolete resource envelope | |
$ codesign --verify --verbose=4 xScope.app | |
--prepared:/Users/craig/Downloads/xScope.app/Contents/Frameworks/Sparkle.framework/Versions/Current/. | |
--validated:/Users/craig/Downloads/xScope.app/Contents/Frameworks/Sparkle.framework/Versions/Current/. | |
--prepared:/Users/craig/Downloads/xScope.app/Contents/Frameworks/YAML.framework/Versions/Current/. | |
--validated:/Users/craig/Downloads/xScope.app/Contents/Frameworks/YAML.framework/Versions/Current/. |