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
extension UIImage { | |
func maxArea() -> CGRect{ | |
let provider = self.cgImage!.dataProvider | |
let providerData = provider!.data | |
let data = CFDataGetBytePtr(providerData) | |
var minX = 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
class KotlinActivity : Activity() { | |
val btn: Button? by find(R.id.button) | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super<Activity>.onCreate(savedInstanceState) | |
setContentView(R.layout.main) | |
btn?.setText("Hello from kotlin") | |
} |
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
import android.app.Activity | |
import android.support.annotation.IdRes | |
import android.view.View | |
fun <T : View> Activity.bind(@IdRes idRes: Int): Lazy<T> { | |
@Suppress("UNCHECKED_CAST") | |
return unsafeLazy { findViewById(idRes) as T } | |
} | |
fun <T : View> View.bind(@IdRes idRes: Int): Lazy<T> { |
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
let arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] | |
extension Array { | |
func splitBy(subSize: Int) -> [[Element]] { | |
return 0.stride(to: self.count, by: subSize).map { startIndex in | |
let endIndex = startIndex.advancedBy(subSize, limit: self.count) | |
return Array(self[startIndex ..< endIndex]) | |
} | |
} | |
} |
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
// | |
// DirectoryUtils.h | |
// PhotoCloud | |
// | |
// Created by liupeng on 14/11/2016. | |
// Copyright © 2016 liupeng. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> |
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
on run | |
set myVar to do shell script "defaults read com.apple.finder AppleShowAllFiles 2>/dev/null" | |
if myVar is "1" then | |
#display dialog "cuttent is show. will hide it" | |
do shell script "defaults write com.apple.finder AppleShowAllFiles 0" | |
do shell script "killall Finder" | |
else | |
#display dialog "current hidden. will show it" | |
do shell script "defaults write com.apple.finder AppleShowAllFiles 1" |
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
@implementation LogProvider | |
+(void)writeLogFile:(NSString* )message { | |
NSString *applicationCacheDirectory = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject]; | |
NSDateFormatter* formate = [[NSDateFormatter alloc] init]; | |
[formate setDateFormat:@"yyyy-MM-dd"]; | |
NSString* logFolder = [applicationCacheDirectory stringByAppendingPathComponent:@"SKPhotoCloudUploadLog"]; | |
NSString* finalPath = [logFolder stringByAppendingPathComponent: [NSString stringWithFormat:@"%@.log",[formate stringFromDate:[NSDate new]]]]; | |
NSFileHandle *output = [NSFileHandle fileHandleForWritingAtPath:finalPath]; | |
if(output == nil) { | |
if (![[NSFileManager defaultManager] fileExistsAtPath:logFolder]) { |
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 | |
# check for where the latest version of IDEA is installed | |
IDEA=`ls -1d /Applications/IntelliJ\ * | tail -n1` | |
wd=`pwd` | |
# Setup your working directory. Edit 'work' to your working directory. | |
working_dir=`ls -1d ~/work/$1 | head -n1` | |
# were we given a directory? | |
if [ -d "$1" ]; then |
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 | |
# check for where the latest version of IDEA is installed | |
IDEA=`ls -1d /Applications/IntelliJ\ * | tail -n1` | |
wd=`pwd` | |
# were we given a directory? | |
if [ -d "$1" ]; then | |
# echo "checking for things in the working dir given" | |
wd=`ls -1d "$1" | head -n1` |
NewerOlder