Skip to content

Instantly share code, notes, and snippets.

View TomLiu's full-sized avatar

Liu Yi TomLiu

View GitHub Profile
@TomLiu
TomLiu / GetIP.m
Last active December 19, 2015 12:29
Get IP
//
// AppDelegate.m
// demo
//
// Created by 61 on 13-4-25.
// Copyright (c) 2013年 61. All rights reserved.
//
#import "AppDelegate.h"
#import <netinet/in.h>
@TomLiu
TomLiu / NSString+reverse.m
Created June 22, 2013 12:23
NSString+reverse
NSMutableString *reversedString = [NSMutableString string];
NSInteger charIndex = [myString length];
while (charIndex > 0) {
charIndex--;
NSRange subStrRange = NSMakeRange(charIndex, 1);
[reversedString appendString:[myString substringWithRange:subStrRange]];
}
NSLog(@"%@", reversedString);
@TomLiu
TomLiu / NSAuthorization.h
Created June 19, 2013 05:29
Ask for privilege to execute command
//
// NSAuthorization.h
// OSXvnc
//
// Created by Jonathan Gillaspie on Fri Dec 12 2003.
// Copyright (c) 2003 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
@TomLiu
TomLiu / getWallPapper.m
Created May 15, 2013 14:38
Get Screen Wallpapper
NSScreen *mainScreen = [NSScreen mainScreen];
NSURL *imgURL = [[NSWorkspace sharedWorkspace] desktopImageURLForScreen:mainScreen];
@TomLiu
TomLiu / MethodSwizzle.h
Last active December 16, 2015 11:38
MethodSwizzle void MethodSwizzle(Class aClass, SEL orig_sel, SEL alt_sel); void MethodSwizzleClass(Class aClass, SEL orig_sel, SEL alt_sel);
/*
* MethodSwizzle.h
*
* Copyright (c) 2007-2011 Kent Sutherland
*
* 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,
@TomLiu
TomLiu / gist:5342242
Last active December 15, 2015 23:39
Get Finder Current Path & Current Selection using AppleScript
#import "AppDelegate.h"
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
NSDictionary *error = nil;
NSString *source = @"tell application \"Finder\"\ntry\nset dir to the target of the front window\nreturn POSIX path of (dir as text)\non error\nreturn \"/\"\nend try\nend tell";
NSAppleScript *script = [[NSAppleScript alloc] initWithSource:source];
//
// NSSharingServicePicker+ESSSharingServicePickerMenu.h
//
// Created by Matthias Gansrigler on 22.11.12.
// Copyright (c) 2012 Eternal Storms Software. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@interface NSSharingServicePicker (ESSSharingServicePickerMenu)
@TomLiu
TomLiu / CustomCursorButton.h
Created November 8, 2012 08:44
change NSButton cursor
//
// CustomCursorButton.h
// demo
//
// Created by 61 on 11/8/12.
// Copyright (c) 2012 61. All rights reserved.
//
#import <Cocoa/Cocoa.h>
<key>com.apple.security.temporary-exception.apple-events</key>
<array>
<string>com.apple.mail</string>
</array>
@TomLiu
TomLiu / test.m
Created July 26, 2012 16:27
test
this is a test