Coding in #JS again (need to, SDK to $service only available in JS) and I'm frequently using #hoogle to look up what kind of function I'd use in #Haskell (foldMap, unzipWith, ...) and then looking for JS packages that implement them.
@greg Unfortunately not, since the actual use-case is to do some additional post-processing (which also changes the type) in case the predicate is true. Basically:
decider deal = if (hasPage) then Left (deal, page Id) else Right (deal)
So I'm doing two things, partitioning and conditional mapping, ideally in linear time.
Friends in native iOS development. I’d love advice.
I’ve been writing code for over two decades, but never native iOS. Nor C. Nor anything related. But I’m beginning the journey.
Can you recommend a favorite resource for helping folks begin from the ground floor? I can spend all day in an editor and my terminal. But Xcode and iOS is an entirely new world for me.
@bitbonk I feel you and I'm with you. Hopefully we get something eventually. That also reminds me of decades ago when I used #CodeSmith generator. It's still around, but it's not free not updated I think.
@michael I don't think you're missing anything: the formula for calculating colour contrast doesn't always reflect the way we perceive colour.
I'm not an expert (at all!) on this, but I know that the W3C plans to revise the formulas and guidelines for colour in #WCAG 3.
The new version will analyze "perceptual" contrast instead of just "luminance". And it will account for the "polarity" effect of light text on dark backgrounds.
Am I ever... ever going to be able to fundamentally understand what I'm doing? In #React, or any "modern" framework-based #frontendDevelopment for that matter?
I feel like I'm swimming in a mass of imports, props and hooks and the ((mysterious) => ({ useOf({ so, many }); }, [brackets, braces]);
I know people say knowing the web fundamentals will serve me beyond the current transient trends, but there's such a lot of this particular trend to learn, and frankly, it's paying my bills.
@sarajw Based on the experiences our team regularly encounters in the wild, a lot of “modern” framework-based developers don’t know what they’re doing either. 😅
I say: Learn just enough to fake competency, rely mostly on vanilla fundamentals, use search engines to fill in the rest!
#Programming in #Python question:
This should be easy, but I can’t find a straightforward solution anywhere. How can one ask the user to select one **or more ** directories using a graphical interface?
There is “tkFileDialog.askdirectory()” in the Tkinter module but it only allows to select one directory. Any implementations of that function that allow for directory multiselection?
(Yes, I could do a loop and call the same function multiple times but I wouldn’t call that straightforward)
@elduvelle Somewhat of a nitpick: it might be worth thinking of this more as a <your graphical toolkit> question than a Python question, because it's the toolkit that determines the capabilities of the file chooser, and you might get better suggestions form people who know the toolkit well than from Python developers in general.
One of the things that bug me about Rust is that you never feel like you just finished doing something, you're never "done". In most other languages, after you work on something, you can be quite certain you implemented it in the best way. In Rust, there's always a shorter, built-in or more performant way to do it, and you always have to worry that you didn't use the best possible one.
@gregorni
Perhaps this is because Rust lets you go into the depths a lot further than most languages, while still offering fairly high level abstractions. At some point to make Python code faster you have to write an extension in another language. Rust is one of the languages you can use for that.
But just because you can make some code faster doesn't mean you have to; only if it's not fast enough.
@Crocmagnon@preslavrachev this is how I reason about pointer vs value too, as a form of documentation and a hint for developers. For receivers I tend to always end up with pointers anyway so I stick to that. Structs that end up with methods tend to have some form of state. Otherwise the method could've been a func.
Heap vs stack I don't care until someone proves to me that it's an issue.
@dwardoric seeing too deep nesting and the code running off the screen to the right kinda screams at you to try and simplify it earlier and to move things to other functions 🤔
@ragb it's easy to mix them. For understanding when and how to use them you need a deep understanding of what they are meant to be used for, which newbies won't know or understand earlier in their career.
It happened a lot having parameters that you want to align and variable declarations and other things, but then having the tab key not expanding automatically to spaces means that you will use it in the middle of code to try to align things accidentally and inherently things will end up mixed.
I was experimenting with colour distances at work today. I need to find out how similar two colours are, so I wrote a little test program and it was surprisingly pretty.
The algorithm is simple:
Fill the canvas with random colours.
Set the first pixel (top left) to red.
For all pixels, find the most similar pixel and move it next to the current pixel.
To determine the similarity, I calculated the 3D distance in the RGB, HSV and YUV color spaces, which brought very different results. Now, it's quite possible that my HSV and YUV conversion functions were just broken, but that's okay.
I also tried turning the comparison function around, such that it looks for the furthest colour instead of the closest one, which also resulted in some interesting patterns.
The final conclusion is that simply calculating the distance in RGB space seems to be the fastest and most accurate method to detemine perceived similarity.
Hey my programming friends, I have a question. My daughter is taking a C class in college and is using CLion to write her stuff. One of the comments her professor keeps saying is “remember to work in a Unix environment.”
I’ve always used an IDE when I program so I’m not sure what that means. Anyone able to help?
@kylewritescode You should be able to work any ANY environment. I've written code in with just ed before - it is a terrible choice, but it was the only hammer I had available. I've written C on OS/2 (showing my age), MacOS, windows, and several flavors of unix. I know others who have done so on mainframe systems. Some were clearly worse than others, but I got the job done. Do not lock yourself into any one environment!
You do not know what you will do after college so you need to be flexible enough to adjust. That means you should only write standard portable code that runs on any machine where possible. where it isn't possible (mostly user interface classes, but also database) you should use several different machines so that you don't get locked into how one ecosystem does things.
In short, I don't know what your professor means, but I default to assuming they are doing students a disservice.