Skip to content

Instantly share code, notes, and snippets.

View lemonmojo's full-sized avatar

Felix Deimel lemonmojo

View GitHub Profile
@nolanw
nolanw / NSBundle+StopAutoloadingNibs.m
Created February 5, 2011 23:04
Prevent NSApp from autoloading a nib at launch.
#import <Foundation/Foundation.h>
// NSApplication has this weird habit of trying very hard to load a nib at
// launch. If there are none in the app bundle, it'll wander off into the
// frameworks until it finds one, then try to use it.
//
// You know this is what's happening if you get four log messages at launch
// saying "Could not connect the action buttonPressed: to target of class
// NSApplication". You've deleted MainMenu.nib and removed the "Main nib file
@steipete
steipete / UIImage+PSPDFKitAdditions.m
Created August 13, 2011 20:52
Preload UIImage for super-smooth interaction. especially great if you use JPGs, which otherwise produce a noticeable lag on the main thread.
- (UIImage *)pspdf_preloadedImage {
CGImageRef image = self.CGImage;
// make a bitmap context of a suitable size to draw to, forcing decode
size_t width = CGImageGetWidth(image);
size_t height = CGImageGetHeight(image);
CGColorSpaceRef colourSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef imageContext = CGBitmapContextCreate(NULL, width, height, 8, width*4, colourSpace,
kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little);
@s4y
s4y / LICENSE.md
Created August 26, 2011 17:11
For Mac OS X: Get a list of running processes, and tell if a particular process is running, by name

Copyright (c) 2010 DeepTech, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE O

@indragiek
indragiek / gist:4659386
Last active December 11, 2015 20:59
Fix for NSSplitView's non integral drawing/frame calculations
// In an NSSplitView subclass
- (void)drawDividerInRect:(NSRect)rect
{
[super drawDividerInRect:NSIntegralRect(rect)];
}
// In NSSplitViewDelegate implementation
- (CGFloat)splitView:(NSSplitView *)splitView constrainSplitPosition:(CGFloat)proposedPosition ofSubviewAt:(NSInteger)dividerIndex
@beccadax
beccadax / NSWindow+BetterSheets.h
Created July 14, 2013 03:46
Better sheet APIs for 10.8. Any resemblance to Mavericks is purely coincidental.
//
// NSWindow+BetterSheets.h
// Gistapo
//
// Created by Brent Royal-Gordon on 7/12/13.
// Copyright (c) 2013 Architechies. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@deltamobile
deltamobile / finalizer_example.go
Last active January 8, 2024 18:19
An example of the use of a finalizer (the runtime.SetFinalizer function) for a Go (golang) data structure. The documentation describes the expected signature for the function passed to SetFinalizer, but it is nice to see a running example. Tested with Go 1.1.2.
package main
import (
"fmt"
"runtime"
"time"
)
type Foo struct {
name string
@gotcake
gotcake / reference_counting.c
Created October 29, 2013 19:45
A small implementation of reference counting for C. Frees the programmer from keeping track of pointers and knowing when to free them when they are shared between multiple structures and functions.
#include "reference_counting.h"
#include <stdio.h>
#define NULL 0
// reference counting....
static struct m_ref {
void *ptr;
int count;
struct m_ref *next;
@Wevah
Wevah / gist:10145527
Created April 8, 2014 15:44
Using kPasteboardTypeFileURLPromise/kPasteboardTypeFilePromiseContent
- (NSArray *)writableTypesForPasteboard:(NSPasteboard *)pasteboard {
// pasteboard must be stored away because there's no way to get it in -pasteboardPropertyListForType: :(
_currentPasteboard = pasteboard;
NSArray *types = @[(id)kPasteboardTypeFileURLPromise, (id)kPasteboardTypeFilePromiseContent];
return types;
}
// ...
@danielpunkass
danielpunkass / fsa.py
Last active July 22, 2018 02:50
A simple lldb module for adding an "fsa" command to inject F-Script anywhere into any process
"""
Automate loading of F-Script Anywhere into any app.
By Daniel Jalkut - @danielpunkass - http://indiestack.com/
To set up:
0. Make sure you have FScript.framework installed in /Library/Frameworks (http://www.fscript.org)
1. Copy this script to ~/.lldb/fsa.py
2. Add the following to your ~/.lldbinit file:
@nek023
nek023 / NSStatusBarButtonCell+ForciblyHighlighted.h
Last active April 5, 2022 11:34
Keep NSStatusBarButton highlighted
#import "NSStatusBarButtonCell.h"
@interface NSStatusBarButtonCell (ForciblyHighlighted)
@property (nonatomic, assign, getter=isForciblyHighlighted) BOOL forciblyHighlighted;
@end