This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+(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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo -s | |
nginx=stable # use nginx=development for latest development version | |
add-apt-repository ppa:nginx/$nginx | |
apt-get update | |
apt-get install nginx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//邮箱 | |
+ (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]; | |
} | |
//手机号码验证 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#在 Mac 上打开 Terminal 输入如下命令并替换 /path/ 为目标路径,即可修改截屏路径。 | |
defaults write com.apple.screencapture location /path/ | |
#运行上一条后还需要在 Terminal 输入下述命令,才能让新路径生效: | |
killall SystemUIServer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UIButton *clearButton = [myTextField valueForKey:@"_clearButton"]; | |
[clearButton setImage:[UIImage new] forState:UIControlStateNormal]; |
OlderNewer