Skip to content

Instantly share code, notes, and snippets.

View darrarski's full-sized avatar
:octocat:
🍏🦕

Dariusz Rybicki darrarski

:octocat:
🍏🦕
View GitHub Profile
@import UIKit;
@interface UINavigationItem (KZAdditions)
@property (nonatomic, copy) NSDictionary *kz_titleTextAttributes;
@end
@kv109
kv109 / ruby-aes-gem-test.rb
Last active January 1, 2017 10:19
ruby AES gem test
require 'aes'
# Obvious part
plain = "Very important message"
full_valid_password = "password"
encrypted = AES.encrypt(plain, full_valid_password)
decrypted = AES.decrypt(encrypted, full_valid_password)
plain == decrypted #=> true, obviously
# Now the sad part
@coolio107
coolio107 / gist:f843789e5225c1f6fc9b
Last active November 17, 2017 05:54
relativeInterfaceOrientationFromRotationAngle class extension for UIViewController
- (UIInterfaceOrientation)relativeInterfaceOrientationFromRotationAngle:(CGFloat)angle {
NSArray * conversionMatrix = @[ @(UIInterfaceOrientationPortrait),
@(UIInterfaceOrientationLandscapeRight),
@(UIInterfaceOrientationPortraitUpsideDown),
@(UIInterfaceOrientationMaskLandscapeLeft)];
NSInteger oldIndex = [conversionMatrix indexOfObject:@(self.interfaceOrientation)];
if (oldIndex == NSNotFound)
return UIInterfaceOrientationUnknown;
NSInteger newIndex = (oldIndex - (NSInteger)roundf(angle / M_PI_2)) % 4;
@Angles
Angles / Open-source-iOS-apps.md
Created July 25, 2012 19:21
real iOS apps with GitHub open source repos

Real iOS Apps in AppStore, with source on GitHub:

thanks 4 putting source for a noob to learn a little

I've used these:

@capttaco
capttaco / Fetchable.swift
Last active May 3, 2019 17:28
A utility protocol for custom NSManagedObjects that makes querying contexts simpler and more convenient. Requires Swift 2.
import CoreData
protocol Fetchable
{
typealias FetchableType: NSManagedObject
static func entityName() -> String
static func objectsInContext(context: NSManagedObjectContext, predicate: NSPredicate?, sortedBy: String?, ascending: Bool) throws -> [FetchableType]
static func singleObjectInContext(context: NSManagedObjectContext, predicate: NSPredicate?, sortedBy: String?, ascending: Bool) throws -> FetchableType?
static func objectCountInContext(context: NSManagedObjectContext, predicate: NSPredicate?) -> Int
@krzyzanowskim
krzyzanowskim / define_for_all_pods
Last active March 26, 2020 09:42
Disable NSLog with all CocoaPods with post_install hook.
post_install do | installer |
print "Updating #{installer.sandbox.target_support_files_root}/Pods/Pods-environment.h\n"
open("#{installer.sandbox.target_support_files_root}/Pods/Pods-environment.h","a") do |file|
file.puts <<EOF
// Disable logs
#ifndef DEBUG
#define NSLog(...)
#endif
EOF
end
@erica
erica / 00-dragndrop.swift
Last active June 28, 2020 14:52
Building an OSX Drag and Drop Playground: Throw the dragndrop.swift into shared Sources and then test out the examples in individual playgrounds. Make sure the assistant is open and set to the timeline. I prefer vertical assistant stacking for this.
import Cocoa
// Support Foundation calls on String
public extension String { public var ns: NSString {return self as NSString} }
/// Custom Labeled Playground-Based Drag-and-Drop window
public class DropView: NSTextField {
// Default action handler
public var handler: ([String]) -> Void = { paths in Swift.print(paths) }
import SwiftUI
import PlaygroundSupport
struct showArt: View {
@Binding var isPlaying: Bool
var body: some View {
VStack {
VStack {
RoundedRectangle(cornerRadius: 16)
.shadow(color: Color(UIColor.black.withAlphaComponent( isPlaying ? 0.3 : 0.1)), radius: 20, x: 0, y: 10)
@Inferis
Inferis / orientation.m
Last active September 19, 2020 21:02
Calculate InterfaceOrientation from a transition coordinator transform
- (UIInterfaceOrientation)orientationByTransforming:(CGAffineTransform)transform fromOrientation:(UIInterfaceOrientation)c
{
CGFloat angle = atan2f(transform.b, transform.a);
NSInteger multiplier = (NSInteger)roundf(angle / M_PI_2);
UIInterfaceOrientation orientation = self.interfaceOrientation;
if (multiplier < 0) {
// clockwise rotation
while (multiplier++ < 0) {
switch (orientation) {
@JadenGeller
JadenGeller / ClassReflection.swift
Last active March 8, 2021 18:10
Swift Class Reflection Without Valid Instance
/* -fno-objc-arc
CFTypeRef _unsafeCreatePartiallyInitialized(Class c) {
Method method = class_getInstanceMethod([NSObject class], @selector(init));
IMP imp = method_getImplementation(method);
return ((id (*)(id, SEL))imp)([c alloc], @selector(init));
}
void _unsafeDestructPartiallyInitialized(CFTypeRef x) {
Method method = class_getInstanceMethod([NSObject class], @selector(dealloc));
IMP imp = method_getImplementation(method);