Skip to content

Instantly share code, notes, and snippets.

View valexa's full-sized avatar
💼
Open for work

Vlad Alexa valexa

💼
Open for work
View GitHub Profile
@valexa
valexa / ContentView.swift
Created November 21, 2023 18:59
NavigationStack example
//
// ContentView.swift
// sandbox
//
// Created by vlad on 21/11/2023.
//
import SwiftUI
enum Route {
@dry1lud
dry1lud / combine-retry.md
Last active November 27, 2023 10:07
Retry operation in Swift/Combine.

There is a function .retry() in Combine that helps to retry a request. Although it is not enough just to call retry() to achieve retring logic. The retry() function does not do another request but it re-subscribes only to a publisher. To make another request the tryCatch() might be used. In the code below if the first call fails there are three attempts to retry (retry(3)):

import UIKit
import Combine
import PlaygroundSupport

enum CustomNetworkingError: Error {
    case invalidServerResponse
}
@mishagray
mishagray / DefaultingJSONDecoder.swift
Created November 13, 2017 16:44
defines DefaultingJSONDecoder and CodingKeyWithDefaults
//
// DefaultingDecoder.swift
//
// Created by Michael Gray on 10/12/17.
//
import Foundation
// swiftlint:disable force_cast file_length
//
// RealmSwift+Codable.swift
//
// Created by Michael Gray on 8/16/17.
//
import Foundation
import RealmSwift
// swiftlint:disable line_length identifier_name
@erisdev
erisdev / Poser.m
Created March 11, 2012 04:09
Miss +[NSObject poseAsClass:]? Don't use this, you might hurt yourself or someone you love.
#import <objc/runtime.h>
#import <stdlib.h>
// declare some of the Objective-C runtime's private parts where we can see them
typedef struct _NXMapTable NXMapTable;
extern NXMapTable *gdb_objc_realized_classes;
extern void *NXMapInsert(NXMapTable *table, const void *key, const void *value);
@implementation NSObject (Poser)

[If you put this idea of mine in Mover, can we split revenue]

No.

I can't update Mover anymore anyway.

But even before I sold my soul out for the American Dream, there was a policy in place against this kind of deal. Ideas are a dime a dozen; executing them is where the value really is. Odds are I probably had the same idea, evaluated it and discarded it.

I'm not dismissing your idea. I'm sure that in the right context it's both feasible and great — regardless of what it was. But Mover was a very constrained context and an exercise in balancing usefulness and intuitiveness and, believe me, a veritable ton of ideas ended up on the cutting floor; odds are yours is there too in some form. That even includes ideas that could've been made into entire products of their own, and would've, if my new corporate masters hadn't paid staggering amounts of money to move me to Silicon Valley. Given this surplus of ideas, I simply don't see why I should pay others for theirs, especially when I'm going to have to do m

//
// MNDocumentConflictResolutionViewController.h
// MindNodeTouch
//
// Created by Markus Müller on 15.12.11.
// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
//
#import <UIKit/UIKit.h>
@class MNDocumentReference;
@0xced
0xced / CLAlert.h
Last active January 17, 2021 13:26
CLAlert
/*
* CLAlert is a drop-in replacement for NSAlert
*
* A CLAlert is exactly the same as a NSAlert, except for the alert style behavior
*
* - An alert with the informational style (NSInformationalAlertStyle) will always display a "Note icon" (kAlertNoteIcon)
* - An alert with the warning style (NSWarningAlertStyle) will always display a "Caution icon" (kAlertCautionIcon)
* - An alert with the critical style (NSCriticalAlertStyle) will always display a "Stop icon" (kAlertStopIcon)
*
* Tested on Mac OS X 10.5.8, 10.6.1 and 10.11.5