Skip to content

Instantly share code, notes, and snippets.

@caiguo37
caiguo37 / ios_env.sh
Last active April 22, 2021 06:07
ios_env.sh
if xcode-select --install 2>&1 | grep installed; then
echo command line tools installed.;
else
echo please install command line tools first. use *xcode-select --install* command;
exit 1
fi
# Check for Homebrew,
# Install if we don't have it
if test ! $(which brew); then
@caiguo37
caiguo37 / proxy.rb
Created July 5, 2016 14:06 — forked from torsten/proxy.rb
A quick HTTP proxy server in Ruby.
#!/usr/bin/env ruby
# A quick and dirty implementation of an HTTP proxy server in Ruby
# because I did not want to install anything.
#
# Copyright (C) 2009-2014 Torsten Becker <torsten.becker@gmail.com>
#
# 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,
@caiguo37
caiguo37 / gist:6181962
Created August 8, 2013 06:27
parse http header date
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]];
dateFormatter.dateFormat = @"EEE, dd MMM yyyy HH:mm:ss zzz";
NSDate *date = [dateFormatter dateFromString:dateString];
@caiguo37
caiguo37 / gist:6154681
Created August 5, 2013 09:42
通过QQApi发送消息到qq好友
QQApiTextObject *text = [QQApiTextObject objectWithText:@"亲爱哒亲爱哒亲爱哒"];
QQApiMessage *message = [QQApiMessage messageWithObject:text];
[QQApi sendMessage:message];
@caiguo37
caiguo37 / gist:5069496
Created March 2, 2013 02:55
平面旋转
- (void) runSpinAnimationOnView:(UIView*)view duration:(CGFloat)duration rotations:(CGFloat)rotations repeat:(float)repeat;
{
CABasicAnimation* rotationAnimation;
rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 /* full rotation*/ * rotations * duration ];
rotationAnimation.duration = duration;
rotationAnimation.cumulative = YES;
rotationAnimation.repeatCount = repeat;
[view.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
inoremap <silent> = =<Esc>:call <SID>ealign()<CR>a
function! s:ealign()
let p = '^.*=\s.*$'
if exists(':Tabularize') && getline('.') =~# '^.*=' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
let column = strlen(substitute(getline('.')[0:col('.')],'[^=]','','g'))
let position = strlen(matchstr(getline('.')[0:col('.')],'.*=\s*\zs.*'))
Tabularize/=/l1
normal! 0
call search(repeat('[^=]*=',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))
endif
@caiguo37
caiguo37 / UILabel+dynamicSizeMe.h
Created October 11, 2012 02:52 — forked from danielphillips/UILabel+dynamicSizeMe.h
Adjust UILabel to change it's frame according to it's content
@interface UILabel (dynamicSizeMe)
-(float)resizeToFit;
-(float)expectedHeight;
@end
@caiguo37
caiguo37 / close keyboard
Last active October 8, 2015 09:17
close keyboard
[view endEditing:NO];
@caiguo37
caiguo37 / clear NSUserDefaults
Last active October 7, 2015 20:58
clear NSUserDefaults
NSString *appDomain = [[NSBundle mainBundle] bundleIdentifier];
[[NSUserDefaults standardUserDefaults] removePersistentDomainForName:appDomain];