Skip to content

Instantly share code, notes, and snippets.

View yourtion's full-sized avatar
🎯
Focusing

郭宇翔 yourtion

🎯
Focusing
View GitHub Profile
@yourtion
yourtion / countDown.m
Last active August 26, 2015 06:23
iOS倒计时正确的方法
+(void)countDown {
__block int count = 10;
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_source_t _timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
dispatch_source_set_timer(_timer, dispatch_walltime(NULL, 0), 1.0 * NSEC_PER_SEC, 0);
dispatch_source_set_event_handler(_timer, ^{
NSLog(@"Once");
if (count <= 0) {
#SublimeText 3
# AS
sudo apt-add-repository ppa:paolorotolo/android-studio
sudo apt-get update
sudo apt-get install android-studio
# SmartGit
sudo add-apt-repository ppa:eugenesan/ppa
sudo apt-get update
@yourtion
yourtion / newer.sh
Created April 9, 2014 08:40
Ubuntu install Nginx From http://wiki.nginx.org/Install
sudo -s
nginx=stable # use nginx=development for latest development version
add-apt-repository ppa:nginx/$nginx
apt-get update
apt-get install nginx
//邮箱
+ (BOOL) validateEmail:(NSString *)email
{
NSString *emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
return [emailTest evaluateWithObject:email];
}
//手机号码验证
@yourtion
yourtion / installApp.sh
Created April 24, 2014 03:24
安装 app 到 ios 模拟器的脚本 From http://testerhome.com/topics/461
#!/bin/sh
# Pick a uuid for the app (or reuse existing one).
if ! [ -f installApp.uuid ]; then
uuidgen > installApp.uuid
fi
UUID=$(cat installApp.uuid)
#create supporting folders
TOPDIR="/Users/Apple/Library/Application Support/iPhone Simulator/7.0/Applications/$UUID/"
mkdir -p "$TOPDIR"
mkdir -p "$TOPDIR/Documents"
@yourtion
yourtion / InterpolatedUIImage.m
Last active August 29, 2015 14:02
iOS7 Custom QRCode Generator
- (UIImage *)createNonInterpolatedUIImageFormCIImage:(CIImage *)image withSize:(CGFloat) size {
CGRect extent = CGRectIntegral(image.extent);
CGFloat scale = MIN(size/CGRectGetWidth(extent), size/CGRectGetHeight(extent));
// Since CoreImage nicely interpolates, we need to create a bitmap image that we'll draw into
// a bitmap context at the desired size;
size_t width = CGRectGetWidth(extent) * scale;
size_t height = CGRectGetHeight(extent) * scale;
CGColorSpaceRef cs = CGColorSpaceCreateDeviceGray();
CGContextRef bitmapRef = CGBitmapContextCreate(nil, width, height, 8, 0, cs, (CGBitmapInfo)kCGImageAlphaNone);
CIContext *context = [CIContext contextWithOptions:nil];
@yourtion
yourtion / post.php
Created June 6, 2014 05:16
PHP-WEB-CrackFile
<?php
define( "ROOTPATH", "../../" );
include( ROOTPATH."includes/admin.inc.php" );
include( "language/".$sLan.".php" );
include( ROOTPATH."includes/data.inc.php" );
$act = $_POST['act'];
switch ( $act )
{
case "getbordertemplist" :
needauth( 5 );
@yourtion
yourtion / ia32lib.sh
Created June 19, 2014 03:02
Ubuntu 14.04 ia32 lib
sudo -i
cd /etc/apt/sources.list.d
echo "deb http://archive.ubuntu.com/ubuntu/ raring main restricted universe multiverse" >ia32-libs-raring.list
apt-get update
apt-get install ia32-libs
rm /ia32-libs-raring.list
apt-get update
exit
#在 Mac 上打开 Terminal 输入如下命令并替换 /path/ 为目标路径,即可修改截屏路径。
defaults write com.apple.screencapture location /path/
#运行上一条后还需要在 Terminal 输入下述命令,才能让新路径生效:
killall SystemUIServer
@yourtion
yourtion / clearBtn
Created October 22, 2014 08:47
CustomClearButton
UIButton *clearButton = [myTextField valueForKey:@"_clearButton"];
[clearButton setImage:[UIImage new] forState:UIControlStateNormal];