Skip to content

Instantly share code, notes, and snippets.

View samdmarshall's full-sized avatar
💭
I will be slow to respond.

Samantha Demi samdmarshall

💭
I will be slow to respond.
View GitHub Profile
#import <math.h>
static inline BOOL FloatEqual(float a, float b) {
return (fabs(a-b) < FLT_EPSILON);
}
struct LevelHeader {
int64_t checksum;
int32_t version;
int64_t signature;
int32_t instance_count;
int32_t name_count;
int32_t template_count;
int32_t data_offset;
const char *exec_path = [[[NSBundle mainBundle] executablePath] cStringUsingEncoding:NSUTF8StringEncoding];
if (((graph[n].p2 == graph[j].p1) || ((graph[n].p1 == graph[j].p2) && (!compareEdge(graph[n],graph[j])))) && !graph[j].visited) {
//...
}
#if defined(CONFIGURATION_Debug)
#define NSLog( s, ... ) NSLog(@"[%p %@:(%d)] %@ %@", self, [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, [NSString stringWithUTF8String:__PRETTY_FUNCTION__], [NSString stringWithFormat:(s), ##__VA_ARGS__])
#else
#define NSLog( s, ... )
#endif
// cg is a set of objects that describe the properties of onscreen windows (app, frame, title, etc)
// this is comparing all of them to find the windows that are menubar items
NSSet *menubar = [NSSet setWithArray:[[cg allObjects] objectsAtIndexes:[[cg allObjects] indexesOfObjectsPassingTest:^BOOL(WindowObject *obj, NSUInteger idx, BOOL *stop) { return CGRectContainsRect(SystemMenuBarRect(), CGRectMake(obj.window_origin.x, obj.window_origin.y, obj.window_size.width, obj.window_size.height)); }]]];
/*
Notes:
static CGRect SystemMenuBarRect() {
CGRect main_bounds = CGDisplayBounds(CGMainDisplayID());
CGFloat system_height = [[NSStatusBar systemStatusBar] thickness];
return CGRectMake(main_bounds.origin.x, main_bounds.origin.y, main_bounds.size.width, system_height);
float value = (slider.value - slider.minimumValue);
float px_per_val = (slider.frame.size.width)/(slider.maximumValue - slider.minimumValue);
float position = (px_per_val * value) + 20;
<?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">
<dict>
<key>Type</key>
<string>PSMultiValueSpecifier</string>
<key>Title</key>
<string>Prefix</string>
<key>DefaultValue</key>
<string>Clarity</string>
for (NSScreen *screen in [NSScreen screens]) {
NSWindow *new_window = [[NSWindow alloc] initWithContentRect:screen.frame styleMask:NSBorderlessWindowMask backing:NSBackingStoreRetained defer:NO];
[new_window setLevel:kCGScreenSaverWindowLevel];
[new_window makeKeyAndOrderFront:nil];
}
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)? YES : NO
...
NSLog(@"%@",(IS_IPAD == TRUE ? @"YES" : @"NO"));