Skip to content

Instantly share code, notes, and snippets.

View alexrepty's full-sized avatar
🌈
Andrà tutto bene!

Alexander Repty alexrepty

🌈
Andrà tutto bene!
View GitHub Profile
import Foundation
func extractTimeInterval(from string: String) -> TimeInterval? {
let formatter = DateFormatter()
formatter.dateFormat = "HH:mm:ss,SSS"
guard let date = formatter.date(from: string) else { return nil }
guard let referenceDate = formatter.date(from: "00:00:00,000") else { return nil }
let interval = date.timeIntervalSince(referenceDate)
return interval
@alexrepty
alexrepty / mac_apps.md
Created November 16, 2016 11:43
Some beautifully designed and crafted macOS apps in 2016
@alexrepty
alexrepty / blockxit.md
Created July 16, 2016 11:18
stern.de "BLOCKxit" Campaign

stern.de finances their free content with advertisements. In order for us to continue to provide content at our usual level of quality on our website and to continue to continually improve our product, we ask our readers to disable their ad-blockers for stern.de.

The "BLOCKxit"-Campaign

In order to provide education on the topic of ad-blockers, stern is launching "BLOCKxit". The campaign is meant to be seen as tongue-in-cheek, but still means to inform about the serious consequences of ad-blocking. Whoever views stern.de using an ad-blocker will be presented with one of four BLOCKxit campaign images. Members of the stern editorship Christian Krug, Uli Jörges and Philipp Jessen as well as author Mickey Beisenherz act as testimonials and tell the stories of how they managed to break free from ad-blocking. Also included are instructions on how to disable ad-blockers for particular websites.

Images

"I'm Uli and I quit blocking." - Uli Jörges, talkshow guest

@alexrepty
alexrepty / CustomUITableViewCell.m
Created December 22, 2014 11:56
One way to use a custom reorder control in iOS 8 apps.
- (void)addSubview:(UIView *)view {
// For the system-supplied reorder control, we want to eliminate the default
// image and instead use our own. In order to achieve this, we need to use
// the somewhat hacky way of confirming that this is indeed a system-created
// UITableViewCellReorderControl by checking the class name. Icky? Icky.
NSArray *relevantClassnameParts = @[@"ReorderControl"];
NSString *viewClassname = NSStringFromClass([view class]);
for (NSString *classname in relevantClassnameParts) {
if (![viewClassname containsString:classname]) {
@alexrepty
alexrepty / PlaceholderOrder.m
Created September 26, 2014 12:50
I learned about %1$@, %2$@ etc. today thanks to Wordcrafts
#import <Foundation/Foundation.h>
int main(int argc, char *argv[]) {
NSAutoreleasePool *p = [[NSAutoreleasePool alloc] init];
NSString *foo = @"foo";
NSString *bar = @"bar";
NSString *oldSkool = [NSString stringWithFormat:@"%@ %@", foo, bar];
NSString *original = [NSString stringWithFormat:@"%1$@ %2$@", foo, bar];
@alexrepty
alexrepty / main.m
Created October 8, 2013 14:14
Notification Inheritance Issues
#import <Foundation/Foundation.h>
NSString *const kNotificationName = @"NotificationName";
@interface Foobar : NSObject
@end
@implementation Foobar
- (id)init {
self = [super init];
@alexrepty
alexrepty / gist:5183042
Created March 17, 2013 18:54
Useful macappstore:// links
Updates page: macappstore://showUpdatesPage?scan=true
Featured page: macappstore://itunes.apple.com/
Direct app link (1): macappstore://itunes.apple.com/app/id%@?mt=12 (ex. macappstore://itunes.apple.com/app/id537386512?mt=12)
Direct app link (2): macappstore://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=%@&mt=12 (ex. macappstore://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=537386512&mt=12)
@alexrepty
alexrepty / gist:1392024
Created November 24, 2011 19:07
Amazon.de on Diablo III Release Date
Guten Tag,
Amazon.de hat eine wichtige Nachricht zu Ihrer aktuellen Amazon.de-Bestellung
Ihre Bestellung enthält diesen Titel:
=====================================================================
Diablo III
www.amazon.de/gp/product/B0041O5LNM
=====================================================================
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
UIImageView *thumbImageView = (UIImageView *)context;
if ([keyPath isEqualToString:kARPageScrubberViewKeypathFrame]) {
self.bubbleView.pageNumber = self.pageIndex + 1;
CGRect bubbleViewFrame = self.bubbleView.frame;
bubbleViewFrame.origin.x = thumbImageView.frame.origin.x - round(bubbleViewFrame.size.width / 2) + _slider.frame.origin.x + round(thumbImageView.frame.size.width / 2);
bubbleViewFrame.origin.y = thumbImageView.frame.origin.y - bubbleViewFrame.size.height;
self.bubbleView.frame = bubbleViewFrame;
if (self.bubbleView.hidden && _slider.tracking) {
- (void)show:(BOOL)animated {
self.alpha = 0.0f;
self.hidden = NO;
if (animated) {
[UIView beginAnimations:nil context:nil];
}
self.alpha = 1.0f;