Skip to content

Instantly share code, notes, and snippets.

Krzysztof Zabłocki krzysztofzablocki

View GitHub Profile
@krzysztofzablocki
krzysztofzablocki / FindFinalClasses.swift
Last active Apr 16, 2020
Swift makes classes final if possible
View FindFinalClasses.swift
#!/usr/bin/env bash
<% for type in types.classes { -%>
<%_ if type.attributes["final"] != nil || type.attributes["open"] != nil || types.based[type.name]?.isEmpty == false { continue } -%>
<%_ _%>git grep -lz 'class <%= type.name %>' | xargs -0 perl -i'' -pE "s/class <%= type.name %>(?=\s|:)/final class <%= type.name %>/g"
<% } %>
View something.swift
button.onTouchUpInside(context: self) { context in
// doStuff
}
@krzysztofzablocki
krzysztofzablocki / template.stencil
Last active Jan 14, 2017
AutoEquatable template
View template.stencil
// swiftlint:disable file_length
fileprivate func compareOptionals<T>(lhs: T?, rhs: T?, compare: (_ lhs: T, _ rhs: T) -> Bool) -> Bool {
switch (lhs, rhs) {
case let (lValue?, rValue?):
return compare(lValue, rValue)
case (nil, nil):
return true
default:
return false
View Capture.swift
import UIKit
import XCPlayground
XCPlaygroundPage.currentPage.needsIndefiniteExecution = true
func perform(initial: Int) {
var value: Int = initial
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1), dispatch_get_main_queue()) { [myConstant = value] in
print("constant in first block \(myConstant)")
print("captured \(value)")
value = initial * 2
View UINavigationItem+KZAdditions.h
@import UIKit;
@interface UINavigationItem (KZAdditions)
@property (nonatomic, copy) NSDictionary *kz_titleTextAttributes;
@end
View gist:f5f597f04b2efcb711c7
require 'mechanize'
require 'moving_average'
mechanize = Mechanize.new
login_page = mechanize.get 'https://www.myfitnesspal.com/account/login'
form = login_page.forms.first
# noinspection RubyResolve
form.field_with(id: 'username').value = "username"
form.field_with(id: 'password').value = "pass"
form.submit
View gist:0ad07583dcfdb9dd8634
IDEBundleInjection.c: Error 3587 loading bundle '/Users/merowing/Library/Developer/Xcode/DerivedData/GeekFitness-gtvztnsddwdauobsjnmkmeurgqks/Build/Products/Debug-iphonesimulator/GeekFitnessTests.xctest': The bundle “GeekFitnessTests” couldn’t be loaded because it is damaged or missing necessary resources.
DevToolsBundleInjection environment:
XCInjectDiagnostics: (null)
XCInjectBundleInto: /Users/merowing/Library/Developer/Xcode/DerivedData/GeekFitness-gtvztnsddwdauobsjnmkmeurgqks/Build/Products/Debug-iphonesimulator/GeekFitness.app/GeekFitness
XCInjectBundle: /Users/merowing/Library/Developer/Xcode/DerivedData/GeekFitness-gtvztnsddwdauobsjnmkmeurgqks/Build/Products/Debug-iphonesimulator/GeekFitnessTests.xctest
TestBundleLocation: /Users/merowing/Library/Developer/Xcode/DerivedData/GeekFitness-gtvztnsddwdauobsjnmkmeurgqks/Build/Products/Debug-iphonesimulator/GeekFitnessTests.xctest
TMPDIR: /Users/merowing/Library/Developer/CoreSimulator/Devices/39DF8175-6F30-4946-9B23-8B27018F1CE4/data/Containers/Data/Applica
View gist:4d35818d176536655193
when_modified((@[self.counterLabel, self.textView]), ^(id weakSelf) {
[weakSelf updateCharacterLimit];
});
View gist:3c6b9cba4dda976b3ce3
@implementation KZPropertyMapper (MyAppBoxing)
+ (NSDate *)boxValueAsDateSince1970:(id)value __used
{
if (value == nil) {
return nil;
}
AssertTrueOrReturnNil([value isKindOfClass:NSNumber.class]);
return [NSDate dateWithTimeIntervalSince1970:[value floatValue]];
}
View gist:c8ba13b7fd4d36eb3ec0
//! raw builder
TMTween(self.view).animate(@"frame.origin.x", ^(TMTween *tween) {
tween.from = tween.view.left;
tween.to = 110;
tween.duration = 1.5;
tween.options = PMTweenOptionNone;
tween.easing = easing;
}).animate(@"backgroundColor.blue", ^(TMTween *tween) {
tween.from = 0.3f;
tween.to = 1.0;
You can’t perform that action at this time.