Skip to content

Instantly share code, notes, and snippets.

View maojj's full-sized avatar
🎯
Focusing

JiaJun Mao maojj

🎯
Focusing
  • kanyun.com
  • BeiJing
View GitHub Profile
@maojj
maojj / BuildDmg.sh
Last active February 19, 2022 23:03
#!/bin/sh
# BuildDmg.sh
# Build OS X .dmg install file
# Author maojiajun
set -eu
###################################################################################
# config, change for you app.
/**
* Several macros simplifying use of weak references to self inside blocks
* which goal is to reduce risk of retain cycles.
*
* Example:
* @code
@interface Example : NSObject{
int _i;
}
# xcode-build-bump.sh
# @desc Auto-increment the build number every time the project is run.
# @usage
# 1. Select: your Target in Xcode
# 2. Select: Build Phases Tab
# 3. Select: Add Build Phase -> Add Run Script
# 4. Paste code below in to new "Run Script" section
# 5. Drag the "Run Script" below "Link Binaries With Libraries"
# 6. Insure that your starting build number is set to a whole integer and not a float (e.g. 1, not 1.0)
# ~/.lldbinit
...
command script import /usr/local/bin/fblldb.py
command alias reveal_load_sim expr (void*)dlopen("/Applications/Reveal.app/Contents/SharedSupport/iOS-Libraries/libReveal.dylib", 0x2);
command alias reveal_load_dev expr (void*)dlopen([(NSString*)[(NSBundle*)[NSBundle mainBundle] pathForResource:@"libReveal" ofType:@"dylib"] cStringUsingEncoding:0x4], 0x2);
command alias reveal_start expr (void)[(NSNotificationCenter*)[NSNotificationCenter defaultCenter] postNotificationName:@"IBARevealRequestStart" object:nil];
command alias reveal_stop expr (void)[(NSNotificationCenter*)[NSNotificationCenter defaultCenter] postNotificationName:@"IBARevealRequestStop" object:nil];
@maojj
maojj / emoji.mm
Created July 30, 2013 02:10
enable emogi
NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:
@"../../Library/Preferences/com.apple.Preferences.plist"];
NSMutableDictionary *dict =
[NSMutableDictionary dictionaryWithContentsOfFile:path];
[dict setObject:[NSNumber numberWithBool:YES] forKey:@"KeyboardEmojiEverywhere"];
[dict writeToFile:path atomically:NO];
@maojj
maojj / JSON.h
Created July 15, 2013 04:26
系统json解析
#import <Foundation/Foundation.h>
@interface NSString (JSON)
- (id) JSONValue;
@end
@implementation NSString (JSON)
- (id) JSONValue {
    NSError *error = nil;
    id obj = [NSJSONSerialization JSONObjectWithData:[self dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableContainers error:&error];
# 1.install gource using HomeBrew
$ brew install gource
# 2.install avconv
git clone git://git.libav.org/libav.git
cd libav
# it will take 3-5 minutes to complie, be patient.
./configure --disable-yasm
make && make install
-(UIImage*)getGrayImage:(UIImage*)sourceImage
{
int width = sourceImage.size.width;
int height = sourceImage.size.height;
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceGray();
CGContextRef context = CGBitmapContextCreate (nil,width,height,8,0,colorSpace,kCGImageAlphaNone);
CGColorSpaceRelease(colorSpace);
if (context == NULL) {
APP = LL
WORKSPACE = LL
CONFIG = AdHoc
SCHEME = LLAdHoc
ICON_NAME = "[email protected]"
BASE_URL = http://ota.nsnotfound.com/
EMAIL_LIST = "[email protected]"
EMAIL_DOMAIN = "lexrus.mailgun.org"
SFTP_SERVER = [email protected]
#! /bin/bash
# File name : convertImage.sh
# Author: Mao Jiajun
#
# print usage
usage() {
cat << EOF
Usage:
cropcorner.sh <> <src file> <geometry> <dest file>