Skip to content

Instantly share code, notes, and snippets.

View zac's full-sized avatar

Zac White zac

View GitHub Profile
@zac
zac / NSCalendarDate+Disassembly.m
Last active August 7, 2020 17:21
-[NSCalendarDate descriptionWithCalendarFormat:locale:] Disassembly
/* @class NSCalendarDate */
-(void *)descriptionWithCalendarFormat:(void *)arg2 locale:(void *)arg3 {
var_E8 = arg3;
var_118 = self;
var_C0 = [[objc_allocWithZone(@class(NSMutableString), _cmd, arg2, arg3) init] autorelease];
var_108 = arg2;
r13 = [arg2 length];
var_1E8 = [NSCharacterSet decimalDigitCharacterSet];
if (r13 == 0x0) goto loc_17d89;
[[ "$ENABLE_PREVIEWS" = "NO" ]] || exit 0
[[ "$MAC_OS_X_VERSION_MAJOR" -ge "101500" ]] || exit 0
TMPFILE=`mktemp /tmp/SwiftUIcon.swift.XXXXXX` || exit 1
trap "rm -f $TMPFILE" EXIT
if [ -z "$SCRIPT_INPUT_FILE_0" ]
then
echo "error: You must specify your Icon.swift as the first Input File in the Build Phase."
exit 1
import Foundation
let env = ProcessInfo.processInfo.environment
guard let deviceFamily = env["TARGETED_DEVICE_FAMILY"],
let projectPath = env["PROJECT_DIR"],
let project = env["PROJECT"] else {
exit(1)
}
enum GenerationError: Error {
case couldNotGetImageRep
case couldNotGeneratePNG
}
extension View {
/// Generates an image from the current View
/// - Parameter size: The size of the image to generate
func generateImageData(size: CGSize) throws -> Data {
struct Icon_Previews : PreviewProvider {
static var previews: some View {
Icon()
.previewHomescreen()
.background(
LinearGradient(
gradient: Gradient(colors: [.purple, .orange]),
startPoint: .bottom,
endPoint: .top
)

Keybase proof

I hereby claim:

  • I am zac on github.
  • I am zacwhite (https://keybase.io/zacwhite) on keybase.
  • I have a public key ASBXaiAy0e62kaBQoB_JszcDYlWT2hqa8v_zzY-ZbvucCgo

To claim this, I am signing this object:

@interface UIView (QuickLookUtilities)
- (id)debugQuickLookObject;
@end
@implementation UIView (QuickLookUtilities)
- (id)debugQuickLookObject
{
UIGraphicsBeginImageContext(self.frame.size);
[self drawViewHierarchyInRect:(CGRect){ .size = self.frame.size } afterScreenUpdates:YES];
UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
@zac
zac / VLMStreamingAudioPlayer.h
Created April 19, 2012 04:03
A very simple interface to playback audio from a URL.
typedef enum {
VLMStreamingPlaybackStatusStopped,
VLMStreamingPlaybackStatusPlaying,
VLMStreamingPlaybackStatusBuffering,
VLMStreamingPlaybackStatusCompleted
} VLMStreamingPlaybackStatus;
typedef void(^VLMStreamingPlaybackStatusCallback)(VLMStreamingPlaybackStatus status);
typedef void(^VLMStreamingPlaybackProgressCallback)(CGFloat fractionComplete);
typedef void(^VLMStreamingDownloadProgressCallback)(CGFloat fractionComplete);
#include <stdio.h>
main(t,_,a)char *a;{return!0<t?t<3?main(-79,-13,a+main(-87,1-_,
main(-86,0,a+1)+a)):1,t<_?main(t+1,_,a):3,main(-94,-27+t,a)&&t==2?_<13?
main(2,_+1,"%s %d %d\n"):9:16:t<0?t<-72?main(_,t,
"@n'+,#'/*{}w+/w#cdnr/+,{}r/*de}+,/*{*+,/w{%+,/w#q#n+,/#{l,+,/n{n+,/+#n+,/#\
;#q#n+,/+k#;*+,/'r :'d*'3,}{w+K w'K:'+}e#';dq#'l \
q#'+d'K#!/+k#;q#'r}eKK#}w'r}eKK{nl]'/#;#q#n'){)#}w'){){nl]'/+#n';d}rw' i;# \
){nl]!/n{n#'; r{#w'r nc{nl]'/#{l,+'K {rw' iK{;[{nl]'/w#q#n'wk nw' \
iwk{KK{nl]!/w{%'l##w#' i; :{nl]'/*{q#'ld;r'}{nlwb!/*de}'c \
;;{nl'-{}rw]'/+,}##'*}#nc,',#nw]'/+kd'+e}+;#'rdq#w! nr'/ ') }+}{rl#'{n' ')# \