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
set -eu -o pipefail | |
function show_code { | |
while read ERROR_LOCATION; do | |
echo "$ERROR_LOCATION:: error: Missing imageset with name $1" | |
done < <(find "$PROJECT_NAME" -name '*.m' -print0 | xargs -0 grep -n -o -e "\[UIImage imageNamed:@\"$1\"\]" | cut -d ':' -f 1,2) | |
} | |
function show_img { | |
echo -n $(find "$PROJECT_NAME" -name "$1.imageset") |
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
/* | |
* fizzbuzz.cpp | |
* | |
* Created on: Apr 25, 2012 | |
* Author: Brian Geffon | |
* | |
* Modified on: May 25, 2016 | |
* Author: Anton Bukov | |
* | |
* fizzbuzz solved without looping or conditionals using only template recursion. |
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 <QuartzCore/QuartzCore.h> | |
#import "Bike.h" | |
@implementation Bike { | |
} | |
- (id)initWithFrame:(CGRect)frame { | |
self = [super initWithFrame:frame]; |
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
# | |
# Reorder property attributes in one possible way | |
# | |
# @property (nullable, readonly, assign, nonatomic, getter=isReady) BOOL ready; | |
# | |
# 1. Move readonly to the BEGIN of attribute list | |
# 2. Move nullable to the BEGIN of attribute list | |
# 3. Move null_resettable to the BEGIN of attribute list | |
# 4. Move nonatomic to the END of attribute list | |
# 5. Move getter to the END of attribute list |
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 <Foundation/Foundation.h> | |
namespace cv { | |
class Mat; | |
} | |
@interface NSValue (CVMat) | |
+ (instancetype)valueWithCVMat:(cv::Mat)mat; | |
@property (readonly) cv::Mat CVMatValue; |
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
# Fetch | |
git clone https://github.com/username/reponame reponame | |
for b in `git branch -r | grep -v -- '->'`; do git branch --track ${b##origin/} $b; done | |
# Analyze | |
curl https://bootstrap.pypa.io/get-pip.py > get-pip.py && sudo python get-pip.py && rm get-pip.py | |
sudo pip install git-fat | |
git fat -a find 1000000 | |
git ls-tree -r -t -l --full-name HEAD | sort -n -k 4 |
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 UIImage (Grayscale) | |
UIImage *grayscaleImageFromCIImage(CIImage *image, CGFloat scale) { | |
CIImage *blackAndWhite = [CIFilter filterWithName:@"CIColorControls" keysAndValues:kCIInputImageKey, image, @"inputBrightness", @0.0, @"inputContrast", @1.1, @"inputSaturation", @0.0, nil].outputImage; | |
CIImage *output = [CIFilter filterWithName:@"CIExposureAdjust" keysAndValues:kCIInputImageKey, blackAndWhite, @"inputEV", @0.7, nil].outputImage; | |
CGImageRef ref = [[CIContext contextWithOptions:nil] createCGImage:output fromRect:output.extent]; | |
UIImage *result = [UIImage imageWithCGImage:ref scale:scale orientation:UIImageOrientationUp]; | |
CGImageRelease(ref); | |
return result; | |
} |
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
struct RefString | |
{ | |
RefString(const string & s, int i, int l) : s(s), i(i), l(l) {} | |
const char & operator [] (int x) const { | |
return s[i+x]; | |
} | |
size_t length() const { | |
return l; |
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
string add(const string & s1, const string & s2) | |
{ | |
int flag = 0; | |
string ret(std::max(s1.size(),s2.size())+1, '0'); | |
for (int i = 0; i < ret.size(); i++) { | |
int v = (i < s1.size() ? s1[s1.size()-1-i]-'0' : 0) | |
+ (i < s2.size() ? s2[s2.size()-1-i]-'0' : 0) + flag; | |
flag = v/10; | |
v -= flag*10; | |
ret[ret.size()-1-i] = v+'0'; |