This file contains hidden or 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
// I'm using snapkit | |
// You can add to viewDidLoad | |
let address = UITextView(frame: CGRectZero) | |
address.text = restaurant.address | |
let sizeThatFits = address.sizeThatFits(CGSize(width: view.frame.width, height: CGFloat(MAXFLOAT))) | |
mainView.addSubview(address) | |
address.snp_makeConstraints { (make) -> Void in | |
let superview = mainView | |
make.top.equalTo(superview.snp_top) | |
make.left.equalTo(superview.snp_left) |
This file contains hidden or 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
Show hidden characters
{ | |
"cmd": ["bash", "-c", "g++ '${file}' -o '${file_path}/${file_base_name}' && open -a Terminal.app '${file_path}/${file_base_name}'"], | |
"selector" : "source.c", | |
"shell" : false, | |
"working_dir" : "$file_path" | |
} |
This file contains hidden or 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
// C programming | |
#include <stdio.h> | |
#define IN 1 | |
#define OUT 0 | |
int main(int argc, char const *argv[]) | |
{ | |
int c, i, nwhite, nother; |
This file contains hidden or 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
#define RGB(r, g, b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1] | |
#define HEXCOLOR(c) [UIColor colorWithRed:((float)((c & 0xFF0000) >> 16))/255.0 green:((float)((c & 0xFF00) >> 8))/255.0 blue:((float)(c & 0xFF))/255.0 alpha:1.0] | |
#define UIColorFromRGB(rgbValue) \ | |
[UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \ | |
green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \ | |
blue:((float)(rgbValue & 0xFF))/255.0 \ | |
alpha:1.0] | |
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) | |
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) |
This file contains hidden or 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
// find depth key in NSDictionary | |
- (id)findKey:(NSString *)keyname inObject:(id)object { | |
for (id subKey in object) { | |
id subObject = [object objectForKey:subKey]; | |
if ([subKey isEqualToString:keyname]) { | |
return subObject; | |
This file contains hidden or 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
#if Debug | |
#define DLog(...) NSLog(@"%@(%d),%@),__PRETTY_FUNCTION__,__LINE_,[NSString stringWithFormat:__VA_ARGS__]) | |
#elif Release | |
#define DLog(...) | |
#endif |
This file contains hidden or 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
validateName(name: String) { | |
if (name) { | |
if (/^[A-Za-z0-9][a-z0-9._\-]*$/.exec(name)) { | |
return true; | |
} | |
} | |
return false; | |
} | |
validateEmail(email: String) { |
This file contains hidden or 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
package main | |
import ( | |
"fmt" | |
"reflect" | |
) | |
func main() { | |
checkType() | |
} |
This file contains hidden or 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
I'm using MacOSX Siera 10.12 | |
sudo ln -s /usr/local/Cellar/pcre/8.40/include/pcre.h /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/pcre.h | |
If you do not install "pcre" , you can using brew | |
brew install pcre |
This file contains hidden or 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
package main | |
import ( | |
"errors" | |
"database/sql" | |
"encoding/json" | |
"fmt" | |
_ "github.com/go-sql-driver/mysql" | |
) |
OlderNewer