Skip to content

Instantly share code, notes, and snippets.

View daviddelmonte's full-sized avatar

David DelMonte daviddelmonte

View GitHub Profile
@dchohfi
dchohfi / tableView:viewForHeaderInSection:
Created April 9, 2012 19:49
tableView:viewForHeaderInSection: like the default header view
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
float width = tableView.bounds.size.width;
int fontSize = 18;
int padding = 10;
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, width, fontSize)];
view.backgroundColor = [UIColor colorWithWhite:0 alpha:0];
view.userInteractionEnabled = YES;
view.tag = section;
@markd2
markd2 / serial.m
Created May 14, 2012 15:06
Playing with NSPropertyListSerialization
#import <Foundation/Foundation.h>
// clang -g -Wall -fobjc-arc -framework Foundation -o serial serial.m
static id makePlistObjects (void) {
NSMutableDictionary *top = [NSMutableDictionary dictionary];
[top setObject: @"Hi I'm a string" forKey: @"string"];
[top setObject: [NSNumber numberWithInt: 23] forKey: @"number"];
@stevekinney
stevekinney / README.md
Last active April 11, 2021 17:23
The frequency and wavelengths of musical notes.
@minikin
minikin / removeAllAnnotations()
Last active April 13, 2023 08:19
Remove all annotation from mapView [MapBox]
/// Remove all annotation from mapView (MapBox)
func removeAllAnnotations() {
guard let annotations = mapView.annotations else { return print("Annotations Error") }
if annotations.count != 0 {
for annotation in annotations {
mapView.removeAnnotation(annotation)
}
// Makes the text in an NSTextFieldCell vertically centered. Works with single line, non-editable cells.
// Maybe doesn't work with others.
// Stolen from this stackoverflow question:
// http://stackoverflow.com/questions/1235219/is-there-a-right-way-to-have-nstextfieldcell-draw-vertically-centered-text
import Cocoa
class VerticallyCenteredTextFieldCell: NSTextFieldCell {
override func titleRect(forBounds rect: NSRect) -> NSRect {
@PrasannaKumarChalla
PrasannaKumarChalla / RSVerticallyCenteredTextFieldCell.swift
Created August 27, 2017 18:08
vertically align nstextfield text
class RSVerticallyCenteredTextFieldCell: NSTextFieldCell {
var mIsEditingOrSelecting:Bool = false
override func drawingRect(forBounds theRect: NSRect) -> NSRect {
//Get the parent's idea of where we should draw
var newRect:NSRect = super.drawingRect(forBounds: theRect)
// When the text field is being edited or selected, we have to turn off the magic because it screws up
// the configuration of the field editor. We sneak around this by intercepting selectWithFrame and editWithFrame and sneaking a
// reduced, centered rect in at the last minute.
@NicholasBellucci
NicholasBellucci / ScrollingTextView.swift
Last active March 1, 2024 03:37
MacOS swift marquee scrolling text view
import Cocoa
open class ScrollingTextView: NSView {
// MARK: - Open variables
/// Text to scroll
open var text: NSString?
/// Font for scrolling text
open var font: NSFont?