Skip to content

Instantly share code, notes, and snippets.

View klmitchell2's full-sized avatar
🎯
Focusing

Kevin Mitchell Jr klmitchell2

🎯
Focusing
View GitHub Profile

Objective-C Coding Convention and Best Practices

Most of these guidelines are to match Apple's documentation and community-accepted best practices. Some are derived some personal preference. This document aims to set a standard way of doing things so everyone can do things the same way. If there is something you are not particularly fond of, it is encouraged to do it anyway to be consistent with everyone else.

This document is mainly targeted toward iOS development, but definitely applies to Mac as well.

Operators

NSString *foo = @"bar";
@skull-squadron
skull-squadron / gist:941862
Created April 26, 2011 06:13
Find the next free GID / UID on Mac OS X 10.6 snow leopard.
NEXTUID=$(dscl . -list /Users UniqueID | awk 'BEGIN{i=0}{if($2>i)i=$2}END{print i+1}')
NEXTGID=$(dscl . -list /Groups PrimaryGroupID | awk 'BEGIN{i=0}{if($2>i)i=$2}END{print i+1}')
@charlesdaniel
charlesdaniel / basic_auth_nodejs_test.js
Created January 27, 2012 02:53
Example of HTTP Basic Auth in NodeJS
var http = require('http');
var server = http.createServer(function(req, res) {
// console.log(req); // debug dump the request
// If they pass in a basic auth credential it'll be in a header called "Authorization" (note NodeJS lowercases the names of headers in its request object)
var auth = req.headers['authorization']; // auth is in base64(username:password) so we need to decode the base64
console.log("Authorization Header is: ", auth);
@cbuck
cbuck / buddies.applescript
Last active November 29, 2016 07:54
Get buddies list from MESSAGES app
set newline to ASCII character 10
set availableFormat to "\\033[0;37m"
set awayFormat to "\\033[0;30m"
set idleFormat to "\\033[0;30m"
set offlineFormat to "\\033[0;30m"
set unknownFormat to "\\033[0;30m"
set resetFormat to "\\033[0;30m"
set ownName to "****YOURNAME****"
ACTION
AD_HOC_CODE_SIGNING_ALLOWED
ALTERNATE_GROUP
ALTERNATE_MODE
ALTERNATE_OWNER
ALWAYS_SEARCH_USER_PATHS
ALWAYS_USE_SEPARATE_HEADERMAPS
APPLE_INTERNAL_DEVELOPER_DIR
APPLE_INTERNAL_DIR
APPLE_INTERNAL_DOCUMENTATION_DIR
@ddrccw
ddrccw / hello.h
Created January 14, 2014 04:03
detect jailbreak
//
// Created by ddrccw on 14-1-10.
// Copyright (c) 2014年 ddrccw. All rights reserved.
// refer to http://danqingdani.blog.163.com/blog/static/1860941952012102122847478/
#import <sys/stat.h>
#import <mach-o/dyld.h>
//#import <stdlib.h>
//#import <string.h>
@DomiR
DomiR / Iphone.md
Last active October 22, 2021 00:05
Iphone passwordless ssh

Passwordless SSH

If you have no own key in ~/.ssh/ calld id_rsa.pub then create one:

ssh-keygen -t rsa

Copy the public file to the iphone

@aktau
aktau / imessage
Last active June 11, 2023 20:30
Send iMessage from the commandline
#!/bin/sh
if [ "$#" -eq 1 ]; then stdinmsg=$(cat); fi
exec <"$0" || exit; read v; read v; read v; exec /usr/bin/osascript - "$@" "$stdinmsg"; exit
-- another way of waiting until an app is running
on waitUntilRunning(appname, delaytime)
repeat until my appIsRunning(appname)
tell application "Messages" to close window 1
delay delaytime
end repeat
@johnhatvani
johnhatvani / UiButton+Block.
Last active October 10, 2021 04:34
Objective-c runtime fun -- A UIButton that takes a block as an action. The cool thing it does is it adds this action as an instance method at runtime.
#import <objc/runtime.h>
typedef void (^buttonAction)(UIButton *sender);
@implementation UIButton (BlockAction)
+ (UIButton *) buttonWithType:(UIButtonType)type andAction:(buttonAction)action forControlEvents:(UIControlEvents)controlEvents; {
UIButton * button = [UIButton buttonWithType:type];
// suppress undeclared selector warning or else '@selector(action:)' will complain.