Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
DearSirXNORMadam
Aug 1, 2009

lifg posted:

You might like “The Architecture of Open Source Applications” https://aosabook.org/en/ where people who built (or helped build?) well known projects talk about the how. Each chapter is short, so it’s easy to browse through, and then you can read the actual code with a nice understanding of how it’s actually put together and why.

Another thingy to try, go back to very early versions of software. Like find the git repo for Git itself and go back to the earliest commit, when the entire documentation fit in a single small Readme. The core of a great piece of software is all there, without all the optimizations.

Amazing, thank you! Exactly what I was looking for

Adbot
ADBOT LOVES YOU

mondomole
Jun 16, 2023

kliras posted:

google, reddit, and so kinda suck for this, so does anyone know a good guides for getting into opencv for analyzing and tracking (e-)sports and other videogame progress? just for recorded video, no live stuff required

especially when there are multiple menu and scene changes and not just a constant game taking place

This doesn't cover the second part of "especially when there are multiple menu and scene changes" but take a look at https://github.com/Maknee/LeagueMinimapDetectionOpenCV if you haven't seen it before. The core logic of "sweep the grid looking for good matches against a fixed library of icons" is very simple: https://github.com/Maknee/LeagueMinimapDetectionOpenCV/blob/master/detection.py. The drawback of this approach is that you need a static or easy-to-fetch mapping of fixed assets you're looking for in the image. You can probably extend this to cover certain menu and scene changes as long as you have some clips of what you're trying to compare against.

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


This came up in another thread and it's a nice little puzzle:

smackfu posted:

I play a daily game where you have to guess a year that three things happened, and it tells you how close your guess was with a clue.

The clues are:
1-2 years off
3-5 years off
6-10 years off
11-25 years off

The question is whether there is an optimal strategy for subsequent guesses based on the clues?

For instance, I guess 1974 and it says 1-2 years off. That leaves four possible correct answers. What should I guess next?

Here's what I've got so far:
  1. Make a guess y_1.
  2. If that's not right, you have a range of possible years [a, b]. Guess a.
  3. If the error gets larger, you know you picked the wrong direction, so the range is now [y_1, b]. If it doesn't, you guessed the right direction, so the range is now [a, y_1].
  4. If the error range you got was the smallest possible, start linearly searching in that range until you get the answer.
  5. Otherwise, guess the midpoint of your current range and go to step two.
Of course, you stop when your guess is right.

Are there any errors I'm not seeing? Is it possible to improve on this?

ultrafilter fucked around with this message at 19:41 on Jun 24, 2023

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆

ultrafilter posted:

This came up in another thread and it's a nice little puzzle:

Here's what I've got so far:
  1. Make a guess y_1.
  2. If that's not right, you have a range of possible years [a, b]. Guess a.
  3. If the error gets larger, you know you picked the wrong direction, so the range is now [y_1, b]. If it doesn't, you guessed the right direction, so the range is now [a, y_1].
  4. If the error range you got was the smallest possible, start linearly searching in that range until you get the answer.
  5. Otherwise, guess the midpoint of your current range and go to step two.
Of course, you stop when your guess is right.

Are there any errors I'm not seeing? Is it possible to improve on this?

You're starting the linear search 1 step too early. You want to continue doing the binary search until the before and after ranges are both the minimum.
Though that only saves at most 1 guess in this case where the minimum bracket is 2 years.

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

Broadly I think the bsearch approach is asymptotically optimal. A few pedantic notes that I'm not even sure will necessarily improve the practical best case scenario (since the maximum range of dates is bounded to be 51 - worst case is you're 25 off in one direction or 25 in another, so you don't have that many iterations):

quote:

If the error range you got was the smallest possible, start linearly searching in that range until you get the answer.
Not sure you need the linear search: your base case should be when you've reduced the interval to a single year, and then you're done.

quote:

If the error gets larger, you know you picked the wrong direction, so the range is now [y_1, b]. If it doesn't, you guessed the right direction, so the range is now [a, y_1].
Technically, the ranges should be (y_1, b] and [a, y_1), since you know y_1 isn't in the interval. Using half-open intervals reduces the search space by one year per iteration.

quote:

If the error gets larger
Larger or stays the same, I think - you could already be in the case where your initial guess was already on "11-25 off", and if you guess the wrong bisection you'll remain in that "worst case" interval.

I also wonder whether choosing a, the extrema of the range, is optimal; or rather, I wonder if you can infer more information than by just bisecting from the very end (and also wonder how the particular ranges that get handed back from the game could change what the right strategy is here), but I've been mulling it over for a few minutes and don't have a good intuition yet. Fun to think about, though.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
If your first guess is 1-2 off, you can’t do better than three extra guesses in the worst case: your second guess can’t give different answers for all four of the remaining possibilities, so there’s always at least two years for which you have the exact same information. In fact, guessing any of the four possibilities has the same formal outcomes: either your guess was correct or there’s exactly one year which you’ve just proven either correct or incorrect. So the optimal strategy is the obvious one: guess the one you think is most likely that you haven’t ruled out. The less obvious strategies all involve picking a less likely (or impossible) answer in order to get more information on a subsequent guess, which just can’t actually work in your favor if you assume your guesses have at least a 1-in-K likelihood of being correct.

I can’t be bothered to generalize that to less accurate first guesses; git gud.

DoctorTristan
Mar 11, 2006

I would look up into your lifeless eyes and wave, like this. Can you and your associates arrange that for me, Mr. Morden?

ultrafilter posted:

This came up in another thread and it's a nice little puzzle:

Here's what I've got so far:
  1. Make a guess y_1.
  2. If that's not right, you have a range of possible years [a, b]. Guess a.
  3. If the error gets larger, you know you picked the wrong direction, so the range is now [y_1, b]. If it doesn't, you guessed the right direction, so the range is now [a, y_1].
  4. If the error range you got was the smallest possible, start linearly searching in that range until you get the answer.
  5. Otherwise, guess the midpoint of your current range and go to step two.
Of course, you stop when your guess is right.

Are there any errors I'm not seeing? Is it possible to improve on this?

If you’re eg 3-5 years out then the range is the two disjoint intervals [y-5, y-3], [y+3, y+5].

Magnetic North
Dec 15, 2008

Beware the Forest's Mushrooms
Here's a question that's not technical: I am considering doing contract / contract to hire positions for the first time. I know every position will probably be different, but I have at least one question: are they still typically At-Will employment? If I find something better, I can still bail?

Cold on a Cob
Feb 6, 2006

i've seen so much, i'm going blind
and i'm brain dead virtually

College Slice

Magnetic North posted:

Here's a question that's not technical: I am considering doing contract / contract to hire positions for the first time. I know every position will probably be different, but I have at least one question: are they still typically At-Will employment? If I find something better, I can still bail?

When I was doing contract work this was spelled out in the contract. My understanding was I could be sued for leaving without following the contract so I made sure it spelled out a reasonable timeframe and that it was mutual, but this was based on the laws in my jurisdiction so ymmv.

Surprise T Rex
Apr 9, 2008

Dinosaur Gum
Are there any go-to recs for algorithms and data structures stuff? I know there’s a million courses and video series but that’s sort of the problem: I don’t know which ones are good and which are horrible, or what prerequisites they expect me to have.

I never did a CS degree or anything so I’m at a loss.

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

Surprise T Rex posted:

Are there any go-to recs for algorithms and data structures stuff? I know there’s a million courses and video series but that’s sort of the problem: I don’t know which ones are good and which are horrible, or what prerequisites they expect me to have.

I never did a CS degree or anything so I’m at a loss.

http://algorithms.wtf

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

Surprise T Rex posted:

Are there any go-to recs for algorithms and data structures stuff? I know there’s a million courses and video series but that’s sort of the problem: I don’t know which ones are good and which are horrible, or what prerequisites they expect me to have.

I never did a CS degree or anything so I’m at a loss.

Bob Sedgewick’s Coursera course is good to start. Imho the most important thing is to have an interactive component so you’re not just passively watching lectures and MOOCs are good for that. IIRC he has two algorithms MOOCs which would put you in very good stead; the first only assumes basic programming skills.

An alternative that I really like but might not be appropriate for a beginner necessarily is Eric Demain’s MIT OCW lectures.

lifg
Dec 4, 2000
<this tag left blank>
Muldoon
Wikipedia had very good animations of the different sorting algorithms.

raminasi
Jan 25, 2005

a last drink with no ice

Yak Shaves Dot Com posted:

Thanks for clearing that up! It sounds like I could make a couple of excel scripts, and if VB.NET comes up, feign familiarity and mention how close to C# it is. And wouldn't you know it, we're back in my comfort zone! I'll def look into WinForms, though.

If you know C#, you know VB.NET. The only things you can do in VB.NET that you can’t do the exact same way in C# are pretty minor and esoteric. All you have to do is learn some new keywords, most of which are actually more sensible in VB.NET once you get over the case insensitivity.

AlphaKeny1
Feb 17, 2006

Surprise T Rex posted:

Are there any go-to recs for algorithms and data structures stuff? I know there’s a million courses and video series but that’s sort of the problem: I don’t know which ones are good and which are horrible, or what prerequisites they expect me to have.

I never did a CS degree or anything so I’m at a loss.

Is this for interviewing purposes?

One thing that helped me was implementing data structures/algorithms myself and then solving problems with them. Like reverse the order of a stack, build your own hash map with collision resolution, make a linked list queue, write your own quick sort and pivot algo.

Surprise T Rex
Apr 9, 2008

Dinosaur Gum
Not for interviewing purposes. So far in my experience in the UK we don’t really seem to get those sorts of questions in interviews.

It’s mostly for my own curiosity because I feel like I’m quite senior and this sort of stuff is a pretty big gap in my knowledge, and also to recommend stuff to a direct report of mine who is curious as well.

Volmarias
Dec 31, 2002
Probation
Can't post for 2 hours!

Surprise T Rex posted:

Are there any go-to recs for algorithms and data structures stuff? I know there’s a million courses and video series but that’s sort of the problem: I don’t know which ones are good and which are horrible, or what prerequisites they expect me to have.

I never did a CS degree or anything so I’m at a loss.

If you are like me and have very little interest in the mathematical, formal proofs, etc aspects of it, the Head First series actually seemed to have a nice book about data structures. For the most part, a lot of these boil down to going to Wikipedia, looking at a chart of all of the relevant algorithms or structures for some specific aspect, and picking the right one based on whatever is most important running time wise once you understand the basic concepts of them.

Polio Vax Scene
Apr 5, 2009



I had a bunch of unsaved editors in Visual Studio Code and just left them unsaved because every time I re-opened the program it would re-open them. It got updated to a new version and now all the unsaved editors are gone. Any way to get them back?

necrotic
Aug 2, 2005
I owe my brother big time for this!
Save them next time? I doubt they guarantee pending buffers will remain through any restart.

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


Look at the recent documents list, and save your work from now on.

jawbroken
Aug 13, 2007

messmate king
don’t trust any software that loses any significant amount of user data on crash or restart

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
I would start looking for another text editor, yeah. Reflexively mashing the Save hotkey is so 2004.

I might give up on the search and come back resigned to vscode, but I'd still search.

Gin_Rummy
Aug 4, 2007
I’m putting together a little AI prompting challenge, where teams compete to solve a coding problem using a single prompt, and we compare results based on performance, length of prompt, solution complexity, etc. does anyone happen to have recommendations on a good problem to design against, without leaning directly into LeetCode? I’m afraid that using a LC problem would have a lot of solutions already baked into the training sets, and would really appreciate a problem that would introduce a lot of novel approaches and prompts.

Gin_Rummy fucked around with this message at 20:15 on Jul 11, 2023

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

Gin_Rummy posted:

I’m putting together a little AI prompting challenge, where teams compete to solve a coding problem using a single prompt, and we compare results based on performance, length of prompt, solution complexity, etc. does anyone happen to have recommendations on a good problem to design against, without leaning directly into LeetCode? I’m afraid that using a LC problem would have a lot of solutions already baked into the training sets, and would really appreciate a problem that would introduce a lot of novel approaches and prompts.

Implement the hit videogame "Asteroids"

mystes
May 31, 2006

Polio Vax Scene posted:

I had a bunch of unsaved editors in Visual Studio Code and just left them unsaved because every time I re-opened the program it would re-open them. It got updated to a new version and now all the unsaved editors are gone. Any way to get them back?
That sucks but I would highly suggest not relying on features like that as other people are saying

Also maybe people have different feelings about but imo don't even accumulate too many saved but uncommitted changes? You can always squash the history later for other people's consumption if needed

mystes fucked around with this message at 20:28 on Jul 11, 2023

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
I am very strongly of the opinion that if running git reset --hard would ever make you lose a meaningful amount of work then you went way too long without committing.

Polio Vax Scene
Apr 5, 2009



this wasnt anything super important, just chicken scratch ive accumulated over the months. just wondering if vscode maybe saves those "unsaved" editors somewhere. it must, if it can get them back after a restart, but I'm willing to accept that a version upgrade wiped out wherever they were.

gariig
Dec 31, 2004
Beaten into submission by my fiance
Pillbug

Polio Vax Scene posted:

this wasnt anything super important, just chicken scratch ive accumulated over the months. just wondering if vscode maybe saves those "unsaved" editors somewhere. it must, if it can get them back after a restart, but I'm willing to accept that a version upgrade wiped out wherever they were.

I'd be snarky and post a LMGTFY but too lazy and just found a SuperUser. I'd assume everything is deleted but who knows maybe it's just corrupted.

EDIT: However, I would say this is NOT the main use case of VS Code. You should find something that is always autosaving your data.

gariig fucked around with this message at 00:09 on Jul 12, 2023

lifg
Dec 4, 2000
<this tag left blank>
Muldoon
Vi auto saves pretty well. And there’s never a reason to upgrade, so there’s no worry about a new version breaking anything.

I seriously keep a tab open with Vi all day, just for notes.

necrotic
Aug 2, 2005
I owe my brother big time for this!
VSCode can auto save if you tell it to, like most editors these days. Several different triggers selections, even!

Intentionally leaving unsaved data in a tool that is not explicitly for that just seems misguided. If you don’t want some modifications to end up in a branch then stash is a great way to quickly push it to the side, and bring it back later. Or make a temp branch to commit to and go back, branches are cheap and quick to use!

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

lifg posted:

Vi auto saves pretty well. And there’s never a reason to upgrade, so there’s no worry about a new version breaking anything.

I seriously keep a tab open with Vi all day, just for notes.

I don't even use tmux anymore after vim added :term

necrotic
Aug 2, 2005
I owe my brother big time for this!
NeoVim is good if only because it got the vim dev to actually do anything.

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

necrotic posted:

NeoVim is good if only because it got the vim dev to actually do anything.

Neovim is worse than vim though

necrotic
Aug 2, 2005
I owe my brother big time for this!

leper khan posted:

Neovim is worse than vim though

“If only”

necrotic
Aug 2, 2005
I owe my brother big time for this!
The only thing neovim can do now that vim can’t, that matters to me at least, is be a fully embedded editor in VSCode. I get actual vim not some dumb emulator inside of vscode!

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

necrotic posted:

VSCode can auto save if you tell it to, like most editors these days. Several different triggers selections, even!

Intentionally leaving unsaved data in a tool that is not explicitly for that just seems misguided. If you don’t want some modifications to end up in a branch then stash is a great way to quickly push it to the side, and bring it back later. Or make a temp branch to commit to and go back, branches are cheap and quick to use!

https://code.visualstudio.com/docs/editor/codebasics#_hot-exit says "VS Code will remember unsaved changes to files when you exit by default." It is explicitly a tool for that.

It doesn't work, apparently, but why is that op's fault? I've kept untitled documents open for years in editors that actually work.

necrotic
Aug 2, 2005
I owe my brother big time for this!

pokeyman posted:

https://code.visualstudio.com/docs/editor/codebasics#_hot-exit says "VS Code will remember unsaved changes to files when you exit by default." It is explicitly a tool for that.

It doesn't work, apparently, but why is that op's fault? I've kept untitled documents open for years in editors that actually work.

I did not know they explicitly documented this as a thing, though it still doesn’t guarantee it’ll work beyond updates. And it fortunately lists where to find these files if needed.

I’ll rescind my “wrong tool for the job” but still find it misguided to assume it will always forever have those “unsaved” files. If you definitely want a thing… save it to where _you_ control?

edit: to expand, features like this are usually to prevent crashes of the app or computer from losing data. Not “I haven’t saved my changes for three weeks and it should always be there”.

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆

Gin_Rummy posted:

I’m putting together a little AI prompting challenge, where teams compete to solve a coding problem using a single prompt, and we compare results based on performance, length of prompt, solution complexity, etc. does anyone happen to have recommendations on a good problem to design against, without leaning directly into LeetCode? I’m afraid that using a LC problem would have a lot of solutions already baked into the training sets, and would really appreciate a problem that would introduce a lot of novel approaches and prompts.

To avoid training data contamination you can use problems posted after 2021. It appears to much worse at those

RPATDO_LAMD fucked around with this message at 11:02 on Jul 12, 2023

my cat is norris
Mar 11, 2010

#onecallcat

hello i am not a developer

I use VS Code to modify JSON files from time to time. The biggest thing I have to correct in the JSON is a bunch of values that have been transmitted to our software as 0's instead of as incrementing numbers.

For example, every block of revenue information starts with this line:

code:
"linenumber": 0,
Every time this line appears in the JSON, that 0 needs to be n+1, incrementing from the value of the previous instance of linenumber. Sometimes there are hundreds of these.

I'm currently doing that with find + replace. It's not horrible but I'm sure it could be done more quickly. Is there a way to do that with some kind of script or tool in VS Code?

(yes this is in a sprint to be fixed in the actual system so i no longer need to worry about it but i think it's fairly low priority so it's not gonna get worked in the immediate future)

Adbot
ADBOT LOVES YOU

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe
The way I would automate that would be to write a program to ingest the JSON, modify it, and then spit it back out. I don't know of any editors that are able to do the kind of incrementation that you want, though it wouldn't surprise me if emacs could do it. But also, that would require learning emacs, which is more work than the first solution I described.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply