Skip to content

Instantly share code, notes, and snippets.

View krzysztofzablocki's full-sized avatar

Krzysztof Zabłocki krzysztofzablocki

View GitHub Profile
@krzysztofzablocki
krzysztofzablocki / FindFinalClasses.swift
Last active August 22, 2021 12:12
Swift makes classes final if possible
#!/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"
<% } %>
button.onTouchUpInside(context: self) { context in
// doStuff
}
@krzysztofzablocki
krzysztofzablocki / template.stencil
Last active January 14, 2017 15:22
AutoEquatable template
// 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
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
@import UIKit;
@interface UINavigationItem (KZAdditions)
@property (nonatomic, copy) NSDictionary *kz_titleTextAttributes;
@end
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
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
when_modified((@[self.counterLabel, self.textView]), ^(id weakSelf) {
[weakSelf updateCharacterLimit];
});
@implementation KZPropertyMapper (MyAppBoxing)
+ (NSDate *)boxValueAsDateSince1970:(id)value __used
{
if (value == nil) {
return nil;
}
AssertTrueOrReturnNil([value isKindOfClass:NSNumber.class]);
return [NSDate dateWithTimeIntervalSince1970:[value floatValue]];
}
//! 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;