Skip to content

Instantly share code, notes, and snippets.

@karstenBriksoft
karstenBriksoft / Udp-WINS-client.c
Created March 5, 2024 17:01
example of how to do a UDP broadcast request for finding local Samba sharing servers.
#include <arpa/inet.h>
#include <netinet/in.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <sys/_types/_socklen_t.h>
#include <sys/select.h>
#include <sys/socket.h>
#include <sys/types.h>
//
// TCObject.m
//
//
// Created by Karsten Kusche on 19.12.20.
// Copyright © 2020 briksoftware.com. All rights reserved.
//
//
// compile with -fno-objc-arc
//
@karstenBriksoft
karstenBriksoft / bundlelessApplication.m
Created May 6, 2017 18:50
NSApplication without Bundle
// compile using: clang -fobjc-arc -framework AppKit bundlelessApplication.m -o bundleLess
//
// opens a NSApplication with dock icon and menu bar. NSRunningApplication will return no bundleURL for it
//
// via http://stackoverflow.com/questions/8137538/cocoa-applications-from-the-command-line
// and http://casperbhansen.wordpress.com/2010/08/15/dev-tip-nibless-development/
#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
@karstenBriksoft
karstenBriksoft / gist:02c8aab4a917446f94b42031a95ce3ab
Created May 2, 2016 08:40
drawing CLLocations in a CGContext
NSUInteger pointCount = self.waypoints.count;
MKMapPoint* points = calloc(sizeof(MKMapPoint), pointCount);
CGFloat minX = CGFLOAT_MAX, minY = CGFLOAT_MAX;
CGFloat maxX = 0, maxY = 0;
{
NSInteger i = 0;
for (CLLocation* location in self.waypoints)
{
MKMapPoint point = MKMapPointForCoordinate(location.coordinate);
@karstenBriksoft
karstenBriksoft / gist:5308470
Created April 4, 2013 07:16
how to submit apps that contain the growl xpc to the app store without loosing entitlements for the xpc
replace _appName_ with the name of your app (i.e. Contacts.app)
- open Terminal window
find /var/folders -name _appName_ 2>/dev/null
- delete all folders that were found
- build & archive _appName_
- open archive in Finder, locate _appName_
- open gdb
@karstenBriksoft
karstenBriksoft / gist:3845417
Created October 6, 2012 16:38
getting the coordinates of a status item
// based on code from http://the-useful.blogspot.de/2012/01/getting-nsstatusitem-co-ordinates.html
@implementation NSStatusItem (Position)
- (NSRect)frame
{
if (self.view)
{
return [[self.view window] frame];