Skip to content

Instantly share code, notes, and snippets.

View yourtion's full-sized avatar
🎯
Focusing

郭宇翔 yourtion

🎯
Focusing
View GitHub Profile
$pattern = "/height=\"[0-9]*\"/";
$content = preg_replace($pattern, "", $content);
$pattern = "/width=\"[0-9]*\"/";
$content = preg_replace($pattern, 'width="600"', $content);
@yourtion
yourtion / extName.php
Created December 25, 2013 09:36
PHP文件名、扩展名 From http://www.jb51.net/article/21878.htm
//php获取文件扩展名
function getExt($url)
{
$path=parse_url($url);
$str=explode('.',$path['path']);
return $str[1];
}
@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];