Replies

This profile is from a federated server and may be incomplete. Browse more on the original instance.

chockenberry, to random
@chockenberry@mastodon.social avatar

Pro Tip: Get in the habit of annotating your tuples. In six months, you're not going to remember which string is which:

func apiKeys() -> (String?, String?)

You future self will be happier with:

func apiKeys() -> (clientId: String?, clientSecret: String?)

You can even annotate the return values if you have a lot of complex logic before the return:

return (clientId: “CHOCK”, clientSecret: “NOUNDIES”)

nicklockwood,
@nicklockwood@mastodon.social avatar

@chockenberry

Good: annotate the tuple arguments

Better: use typealiases for the key types:

typealias ClientID = String
typealias ClientSecret = String

Best: use unique type wrapper structs for each:

struct ClientID: RawRepresentable, Hashable {
var rawValue: String
}

struct ClientSecret: RawRepresentable, Hashable {
var rawValue: String
}

nicklockwood,
@nicklockwood@mastodon.social avatar

@jsq @chockenberry it depends what problem you are trying to solve. Using a struct to wrap both values is equivalent to labelling the tuple arguments, in that it ensures that at the point of access you won't get the clientid and secret mixed up.

What using separate struct wrappers solves is that when you pass your clientid and secret around as individual values you won't accidentally get them mixed up with some other string identifier in your application because the type system won't let you.

nicklockwood, to random
@nicklockwood@mastodon.social avatar

I'm wondering if anyone will recognize what this is

nicklockwood,
@nicklockwood@mastodon.social avatar

Disappointed but not surprised that nobody guessed this. Maybe this will make it easier 😅

rene, to random
@rene@social.fouquet.me avatar

Sometimes I wish I had the average person’s ignorance towards IT issues. Every time I tell my wife or friends who are not in It about some new problem, like AI training on user data, or companies doing cross-service tracking for detailed user profiling, they just shrug and keep scrolling through Instagram. Ignorance is bliss.

nicklockwood,
@nicklockwood@mastodon.social avatar

@rene I always think this when people give me the side eye for using DDG instead of Google for search.

I don't even proselytise about it except when they actively complain to me about Google and I point out that their problem doesn't exist on DDG, and then they still treat me the way I treat vegans

Daojoan, to random
@Daojoan@mastodon.social avatar

Nobody who has ever made a cake has a neutral opinion of fondant.

nicklockwood,
@nicklockwood@mastodon.social avatar

@Daojoan I'm not fond of it

pikuma, to random
@pikuma@mastodon.gamedev.place avatar

Was anyone else raised to believe the worst financial decision that would immediately bankrupt one's family was to consume an item from the Hotel mini bar?

I mean, a thief better steal the wallets & all bags from our room before opening a bag of peanuts from that fridge!

nicklockwood,
@nicklockwood@mastodon.social avatar

@pikuma I think I'm still afraid to take anything from the minibar to this day - even the complementary mineral water

ElleGray, to random
@ElleGray@mstdn.social avatar

being able to be funny while you're complaining is a very useful skill

nicklockwood,
@nicklockwood@mastodon.social avatar

@ElleGray I think this the basis of most standup comedy

mcc, to random
@mcc@mastodon.social avatar

Hello. My computer is not working. Can anyone give me some advice?

nicklockwood,
@nicklockwood@mastodon.social avatar

@mcc have you tried switching to Linux? Or if it's already Linux, have you tried switching to macOS?

finestructure, to random
@finestructure@mastodon.social avatar

30 hours into and it's great fun. It's not the most compelling story in the world but the graphics and the mechanics are great. An excellent space shooter, and native to the Mac to boot.

I'll be damned if Rockfish Games aren't looking into or even already working on Everspace for the Vision Pro. Feels like a no brainer. Surely Apple must be talking to them about it?

nicklockwood,
@nicklockwood@mastodon.social avatar

@finestructure the name Rockfish sounded vaguely familiar - it turns out they are a spinoff of the Fishlabs studio that made Galaxy on Fire 2, which was maybe my favorite ever space shooter.

(Shame Everspace isn't on iOS tho)

nicklockwood, to random
@nicklockwood@mastodon.social avatar

In a fit of madness I've agreed to give an internal talk about advanced Swift at my company. Has anybody got any favorite Swift tricks they'd like to share?

nicklockwood,
@nicklockwood@mastodon.social avatar

@ctietze this is a great tip - also other related for loop syntax quirks like for case let foo as type and where clauses

ctietze, to random
@ctietze@mastodon.social avatar

Objective-C professionals around the world, I summen ye 🗺️

Is there not a way to annotate an Objective-C method that returns a Foundation type like NSString to avoid automatic bridging to Swift.String?

I really want to stay in NSString-land.

(Actually, I probably even want to keep fiddling with an NSMutableString as a mutable string)

nicklockwood,
@nicklockwood@mastodon.social avatar

@ctietze I think that's an easier problem - NSMutableString doesn't bridge, so if you return that it shouldn't be converted to String by default

nicklockwood,
@nicklockwood@mastodon.social avatar

@ctietze otherwise, if you control the signature to the method then there are various (slightly ugly) workarounds I can think of, such as returning NSObject and casting it on the Swift side.

nicklockwood,
@nicklockwood@mastodon.social avatar

@ctietze another option might be to create an objc protocol that mirrors the NSString API and then conform NSString to it. If you work exclusively with that protocol, Swift wouldn't know how to bridge it

nicklockwood,
@nicklockwood@mastodon.social avatar

@ctietze I'm curious: if you call such a method by saying something like

mutableString.substring(…) as NSString

would Swift actually do a two-way bridging, or is the optimizer smart enough to recognize that the bridging is a no-op in that scenario?

ratkins, to random
@ratkins@mastodon.social avatar

I’m pleased you’re all angry about the StackOverflow announcement, I’m not because I couldn’t parse any meaningful information out of the corporate gobbledygook.

nicklockwood,
@nicklockwood@mastodon.social avatar

@ratkins it's unclear to me if they intend to use OpenAI to answer questions on StackOverflow (which will make it basically useless) or just use existing StackOverflow answers to train OpenAI (which should probably bother me, but tbh doesn't really)

  • All
  • Subscribed
  • Moderated
  • Favorites
  • megavids
  • rosin
  • thenastyranch
  • GTA5RPClips
  • tester
  • InstantRegret
  • DreamBathrooms
  • ngwrru68w68
  • magazineikmin
  • everett
  • Youngstown
  • mdbf
  • slotface
  • kavyap
  • JUstTest
  • cisconetworking
  • khanakhh
  • normalnudes
  • osvaldo12
  • cubers
  • tacticalgear
  • Durango
  • ethstaker
  • modclub
  • anitta
  • provamag3
  • Leos
  • lostlight
  • All magazines