Skip to content

Instantly share code, notes, and snippets.

View maojj's full-sized avatar
🎯
Focusing

JiaJun Mao maojj

🎯
Focusing
  • yuantiku.com
  • BeiJing
View GitHub Profile
@maojj
maojj / gist:5318939
Created April 5, 2013 12:29
keyboard animation
- (void)keyboardWillShow:(NSNotification *)notification {
NSDictionary *info = [notification userInfo];
NSValue *aValue = [info objectForKey:UIKeyboardFrameEndUserInfoKey];
CGFloat duration = [[info objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue];
CGSize keyboardSize = [aValue CGRectValue].size;
CGRect viewFrame = CGRectMake(0,
0,
UI_SCREEN_WIDTH,
self.View.frame.size.height - keyboardSize.height);
@maojj
maojj / gist:5389322
Created April 15, 2013 16:24
inner shadow
gradient.frame = CGRectMake(0, 0, 100, 100);
gradient.startPoint = CGPointMake(1.0, 1.0);
gradient.endPoint = CGPointMake(1.0, 0);
gradient.colors = [NSArrayarrayWithObjects:(id)[[UIColorblackColor] CGColor], (id)[[UIColorclearColor] CGColor], nil];
[targenView.layerinsertSublayer:gradient atIndex:0];
@maojj
maojj / gist:5539672
Last active December 17, 2015 02:59
get Image from pasteboard for ios
#define WEB_ARCHIVE @"Apple Web Archive pasteboard type"
- (void)getImage {
if ([[[UIPasteboard generalPasteboard] pasteboardTypes] containsObject:WEB_ARCHIVE]) {
NSData* archiveData = [[UIPasteboard generalPasteboard] valueForPasteboardType:WEB_ARCHIVE];
if (archiveData)
{
NSError* error = nil;
id webArchive = [NSPropertyListSerialization propertyListWithData:archiveData options:NSPropertyListImmutable format:NULL error:&error];
if (error) {
@maojj
maojj / build.py
Created May 31, 2013 04:05 — forked from lexrus/build.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import json
import getopt
import urllib2
import commands
import string
#! /bin/bash
# File name : convertImage.sh
# Author: Mao Jiajun
#
# print usage
usage() {
cat << EOF
Usage:
cropcorner.sh <> <src file> <geometry> <dest file>
APP = LL
WORKSPACE = LL
CONFIG = AdHoc
SCHEME = LLAdHoc
ICON_NAME = "Icon@2x.png"
BASE_URL = http://ota.nsnotfound.com/
EMAIL_LIST = "newproject@lexrus.mailgun.org"
EMAIL_DOMAIN = "lexrus.mailgun.org"
SFTP_SERVER = lex@nsnotfound.com
-(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) {
# 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
@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];
@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];