Skip to content

Instantly share code, notes, and snippets.

Avatar

Stephan Partzsch StephanPartzsch

View GitHub Profile
@StephanPartzsch
StephanPartzsch / findPrintStatements.sh
Last active Oct 16, 2020
[Find all print statements] Used as run script build phase #Xcode #Swift
View findPrintStatements.sh
#!/bin/bash
SEARCH='print\(.*'
echo "Searching ${SRCROOT} for ${SEARCH}"
find "${SRCROOT}" \( -name "*.swift" \) -not -path "${SRCROOT}/Pods/*" -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($SEARCH).*\$" | perl -p -e "s/($SEARCH)/ warning: Print Violation (use logger instead): \$1/"
@StephanPartzsch
StephanPartzsch / gist:0ab2fd4755335c7cccaa
Last active Mar 19, 2020
[Extract UIColor] Extract UIColor value at a specific point in a given UIImage (#UI)
View gist:0ab2fd4755335c7cccaa
- (UIColor *)colorForImage:(UIImage *)image atPoint:(CGPoint)point
{
CGDataProviderRef provider = CGImageGetDataProvider(image.CGImage);
CFDataRef pixelData = CGDataProviderCopyData(provider);
const UInt8* data = CFDataGetBytePtr(pixelData);
int numberOfColorComponents = 4; // R,G,B, and A
float positionX = point.x;
float positionY = point.y;
float imageWidth = image.size.width;
@StephanPartzsch
StephanPartzsch / UntouchableUIViewContainer.h
Last active Mar 19, 2020
[UntouchableUIViewContainer] UIView that does not recognize any touch on itself. Only touches on subviews are detected. (#UI)
View UntouchableUIViewContainer.h
#import <Foundation/Foundation.h>
@interface UntouchableUIViewContainer : UIView
@end