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
RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆

Tea Bone posted:

I need to generate a seemingly random alphanumeric string using an integer between 1 and 36^6 as the seed value. The string must be unique and I need to be able to regenerate that same string again by using the same seed.

For example, my_random_string_function(1) will always return 'hg3h76'

Because the string needs to be seemingly random I can't just make it so 1 = aaaaaa, 2 = aaaaa1, 3= aaaaa2 etc

My current line of thinking is to generate an array of [aaaaaa, aaaaa1, aaaaa2 ...] then somehow shuffle it in a predictable way, then I should be able to pull the same string out each time by passing the seed as a key. However generating an array that massive seems less than economical.

edit: I suppose what I'm after is a very basic DIY hashing function.

Wait, so do you need a random result, or do you need a 1-to-1 mapping between integers and strings? Something that's really random won't have a perfect distribution and will produce some strings for more than one input and some never at all.

Adbot
ADBOT LOVES YOU

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆

Tea Bone posted:

I suppose I'm not exactly trying to solve a problem. The specification I was given was simply to generate a unique alpha numeric id that was 6 characters long. A simple random string generator does the job as I don't expect to need more than around 10k ids and even then it's easy enough to validate uniqueness.

The added constraints are self imposed. It seemed like an easy enough task to map any integer to a unique random string which can be calculated at run time but I hit a wall trying to think of a way to actually do it.

Just use a hash function to get a big random hexadecimal value and then do some math to convert base-16 hex stuff into a base-36 alphanumeric key. It'll be longer than you need so just truncate after 6 characters.

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆

that's literally the exact opposite of nosql

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆
It's like a 3d array but with one more dimension.
In the same way that a 2d array is just a bunch of 1d arrays sitting next to each other in a row, a 4d array is just a bunch of 3d arrays next to each other. Same for 5d etc.
In the end a 200-dimensional array is not really any more complex to work with than a 2-dimensional array.

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆
There are a couple of open source "personal media server" projects that already do this. (Somehow extract series from the filename and identify the episode title etc from an api lookup on TVDB or whatever.) You might want to check Kodi or Plex and see what you can crib off of them.

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆

DoctorTristan posted:

There are any number of (paid) services that do things like scrape news sources for company names and push out a feed with the time stamp, ticker and some kind of sentiment score - the usual suspects in the financial data world (Thomson Reuters, Bloomberg, Factset, Nasdaq...) all offer something like this.

If you’re asking whether someone has put together a comprehensive historical dataset of financial news stories, combined this with (expensive) intraday equities data and made the results freely available on the internet, then the answer is no, not that I’m aware of.

It sounds like he's asking for a set of articles that make concrete measurable predictions, and then a dataset showing how accurate those predictions turned out to be.
Not a comprehensive list of every "Apple is good"/"apple is bad" blog alongside a graph of the apple stock price.

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆
So the A objects all know what their "default" options should be anyways, since they use those to initialize the options class, right?
Just make all the values in the optionsForAnA nullable, then have the A class use its own default value for fields that are null in the options.
Then rather than needing to populate the options class with appropriate defaults on construction, you just populate it with nulls, which'll work universally for any A.

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆
I really really doubt you need to set up a database for 50 whole rows of simple numbers.
Unless there are a bunch of different scratchoffs with different prizes from each state? I don't really know how all that works.

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆

Rocko Bonaparte posted:

I'm suffering the prep for the programming interview algorithm lottery and decided to look at the closest points problem based on experiences relayed from a friend. I implemented something that seems to work but actually slower than brute force. It looks like the number of distance calculations I compute is the dominant factor. When timing the code, the disparity is proportional to the number of distance calculations I make. I am making more distance calculations using what should be the more efficient solution that is dividing the space. I'm assuming I am doing something stupid so I thought somebody would want to play with it.

https://pastebin.com/SJei7PzV

I was scribbling that in Python 3. I compare the brute force to the planar search. Inside the planar search is a commented-out line to enable doing a brute force for the middle region, but I'm currently doing the optimized version that sorts the Y coordinates in the central strip. I haven't really thought through what it means to do it that way; I should be faster just brute forcing it instead and I'm not.

The result has been coming up the same, but the points might be flipped. I also haven't done any major cleanup on this code so don't act like it's dressed for the prom. It might help to not work on this at 2AM too.

Your optimized solution is buggy because you've confused two different concepts of distance. The best_pair class is actually storing the square of distance, but then later on you're doing
code:
sorted_points[mid_i].x - sorted_points[mid_left_i].x > best.dist
(and in a few other places with y coordinates too)
Since you're not squaring the distance here, the check is incorrect and you end up going on to the expensive inner loop for lots of points that could not possibly be valid.

If your closest points have a distance less than 1, this will actually throw out valid results too and result in bad answers.

e: the paper also mentions creating the sorted list of y values once and just filtering it each time, whereas here you're sorting it again each time you recurse.

RPATDO_LAMD fucked around with this message at 23:18 on May 20, 2019

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆
The algorithm would still work if that wasn't true, though. The complicated moon elf crap is just for the proof that that border-check is O(1) time complexity

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆

Dumb Lowtax posted:

What on EARTH are you all talking about

Googling "moon elf magic" algorithm returns two results, both internet posts where it's someone's username, and none of the words "moon" "elf" or "magic" seem to appear in any of the documents you're linking

Am I going crazy

just scroll up

Rocko Bonaparte linked a paper describing an algorithm, and referred to a confusing step in the algorithm as magic.

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆
e: wrong thread

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆

Scionix posted:

this is maybe a really stupid question

is there a C# library of some sort where I can produce a random english dictionary word.

I'm filling a database with mock data, and would like to essentially "lorem ipsum blah blah blah" a few fields in my model, but have them be unique and filled with actual words.

I am imagining you probably have to just keep some sort of master list in your solution or something but I figured I'd ask if there was a more elegant way to do that

I googled "C# lorem ipsum generator" and apparently yes
e: here's another one

RPATDO_LAMD fucked around with this message at 07:36 on Nov 7, 2019

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆
Hash collisions are still relatively rare so you could get the benefit of cache-coherency for the common case and only have to deal with cache misses on the uncommon case that a key has collisions. :shrug:
Better for cache than making every bucket a linked list.
Or you could do the variant where the base node of the linked list is physically inside the hash table (instead of a pointer to the first node), so you again only have to deal with indirection / cache misses for keys that collide with something.

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆

Dominoes posted:

So uh... What's a monad? Or is this Worth Its Own Thesis?

Simplified bad answer:

Basically, it's a higher level type like "maybe" that can be used to create types like "maybe int" or "maybe butt", and it comes with a set of functions to do things like finagle using a "maybe int" with a function that just wants a normal int, so (fake syntax) map(square, maybe 2) produces "maybe 4" and map(square, none) produces none.

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆

Dominoes posted:

Do you use Vim and are under 40 years old, or do you know anyone who falls into this category? I've tried to like it because I hear good things about it on the internet, but my current hypothesis is it's exclusively used by guys who learned it decades ago and are either used to it, or are subject to the sunk costs fallacy.

I'm a CS student.
I use the vim keybinds extension in emacs just because the default emacs hotkeys are so ludicrously anti-ergonomic.
I've worked on group projects that were only buildable as Visual Studio solutions so I've used a "normal" IDE as well, and it's fine on a desktop with a proper mouse. But when I'm working on my laptop it's way nicer to be able to just do everything from the keyboard.

e: I was already used to the vim-style movement keys before I started programming because I played a lot of old roguelike games like Nethack and Angband when I was younger, and they used vim keys for movement. So maybe it's still Stockholm syndrome :shrug:

RPATDO_LAMD fucked around with this message at 07:12 on Mar 13, 2020

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆
Twitch chat definitely has some kinda API, since there are desktop apps for it.

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆
Might not be the issue but are you using the same version of python as the guide? Python2 and Python3 have enough differences that you'd run into a bunch of syntax errors if there was a mismatch

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆

credburn posted:

Right now my biggest problem is that some keys have multiple values. I can't for the life of me figure out how to update the key within the while loop in which all this is happening.

When you have a problem like this, you should stop and consider how you're structuring your data.

It sounds like currently when you get input like "20: Gunsmoke" you are using 20 as the key and gunsmoke as the value. In a dictionary, each key has to be unique, but values can be duplicated as much as you want.

When you organize your data like this, you are basically implicitly saying "there can only be one show with 20 seasons, and it is gunsmoke". Then when you get "20: Law & Order" as input later, you get problems. On the other hand, if that code got "21: gunsmoke" as an input, it would be perfectly happy storing that since 21 is a new unique key.

The problem is that your key, "20" is not actually a unique identifier for the TV show. Multiple tv shows might have 20 seasons, and a show's season count might even change after the fact. So using the season count as your dictionary key causes problems.

To fix it you have to change how you organize your data. The simplest solution is to use the tv show as the key and the season count as the value in your dictionary -- there's only ever one instance of each tv show, and duplicate values are fine.

Another solution would be to use a list of pairs instead of a dictionary, like this:
code:
tv_show_pairs = []

my_first_pair = (20, "Gunsmoke")
tv_show_pairs.append(my_first_pair)

my_second_pair = (20, "Law & Order")
tv_show_pairs.append(my_second_pair)

for pair in tv_show_pairs:
	# do something
There is a lot decision making that goes into choosing between arrays vs dictionaries vs queues vs heaps etc at a higher level, but basically either should work just fine for this problem. Typically, arrays are easier when you have to iterate through and touch everything, but dictionaries are easier when you want to quickly find one specific entry since you can just look it up by its key.

edit: spoilered the "answer" since you might not want to just hear it

RPATDO_LAMD fucked around with this message at 03:40 on Mar 14, 2022

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆

Gin_Rummy posted:

Well the issue I run into there is that I can’t run the code independent of their powershell script. I’d be just fine if I could debug via VS Code or whatever (i don’t even think I can use pdb since the shell will probably collect that output as well?), but the only way to execute anything without getting a dependency error right off the bat is through executing run (runs the program) or test (initiates pass/fail checks on their automated unit tests) on their script.

For the record though, printing to stdout is not technically part of their assignment and I can probably do it without… but it will just make it much more of a pain to sort through.

OK but how does the powershell script actually call your python program? Like what is the specific line of the script that calls it? That is the important detail for figuring all this out.
If it is just redirecting stdout into a file like .\mypythonthing.py > output.txt you can just modify it to use the powershell buildtin "tee".
.\mypythonthing.py | tee --filepath output.txt will send your program output to both stdout and the file.

You can also connect your debugger to an already-running process. Stepping through with a debugger and being able to inspect variable values, step one line at a time etc is way more helpful than stdout-based "printf debugging" anyways. If your program isn't interactive, you might need to add some temporary bit in your program to wait for user input before beginning so you have time to attach the debugger before it runs.

RPATDO_LAMD fucked around with this message at 21:21 on Mar 22, 2022

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆
Those are features in Jetbrains' upcoming editor, "Fleet". But it's currently in "closed preview" state and you can't buy it. Keep an eye out for when it becomes available, I guess.

https://www.youtube.com/watch?v=ow5kdhDa_pk

The video shows off the multi-person editing stuff at 2:48 and 5:21, including running some tests and seeing output in the latter section.

RPATDO_LAMD fucked around with this message at 21:56 on Apr 2, 2022

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆

KillHour posted:

The goal is to offset by the normal, yes. And it's definitely not working right. You're right - it's going along the tangent of the curve sometimes instead of the normal of the curve, because the normal is the tangent rotated 90 degrees, which is the same as flipping either the x or y of the tangent (depending on the direction you want to rotate). So what's happening is my logic for "when do I want to flip the x or y or both tangent signs to get the correct normal?" is wrong, and it's wrong because I don't know enough about the underlying math to know what the correct algorithm is, and Google is dropping me into the middle of a calculus / matrix algebra lesson.

To distill down my question - what are the rules I need to follow to know which tangent to invert before I stick it in my vector calculation? I know it's "always exactly one of them" because otherwise, as you noticed, you get lines offset by the tangent instead of the normal (and the circle just happens to be a situation where my original set of incorrect rules works because exactly one of them is always flipped, and it happens to always be the correct one), but trying to turn that knowledge into a set of discrete math operations I can put into a graph is making my head hurt.

You haven't shown any of the actual math forumulas you're creating these shapes with so I'm pretty unclear on this, but when you say "tangent" do you mean the trigonometric tan function or the tangent line to the curve? It seems like you are using those two interchangeably.

What you actually want is a vector that is tangent to the curve in a calculus sense of the word tangent, not the trig tan function. Then you can simply rotate that vector by 90 degrees and you will get the exact normal you want: a vector pointing perpendicularly out from the curve that's on a consistent side every time. (Make sure to normalize it first though so it is a consistent length)

To rotate a vector <x,y> by 90 degrees you just transform it into either <-y, x> or <y, -x> depending on whether you want to rotate counterclockwise or clockwise. If you do that you should get the behavior you want.

If your curve is defined by y = sin( at + b) and x= cos(ct + d), the tangent vector v at t should be v_y = a * cos (at + b) and v_x = -c * sin (ct + d)

RPATDO_LAMD fucked around with this message at 06:43 on Apr 11, 2022

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆
What does it look like on a non-circle shape? Circles can hide a lot of errors with this kind of thing, like with the tan thing above. But it looks like your "rotate" section is not actually rotating the vector. The important thing is that you have to swap the values of x and y, not just multiply x by -1 as you're doing here. For example, if a vector's value was <100, 2> going very far to the +x direction and a tiny amount in the +y direction, the perpendicular vector would be <-2, 100>, going very far in the +y direction and a small amount in the -x direction. If you swapped it to <-100, 2> instead, you would get a vector that was almost horizontal, just like the original -- not rotated by 90 degrees at all.

RPATDO_LAMD fucked around with this message at 08:49 on Apr 11, 2022

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆

KillHour posted:

I edited my post above with a more complex example. I just switched it back to a circle temporarily to reduce the number of variables in what could have been causing the wobbling. I'm swapping the x and y on the normalize function under the rotate section. Here's the final (working) graph.



Oh nice, congrats!

KillHour posted:

Finally gently caress. Thanks for the help. I probably would have literally sat there and built some kind of ridiculous truth table to figure out how to force tan to do what I want when there was a much simpler algorithm (although I have no loving idea how it works)

That formula is just a regular old-fashioned derivative. I don't think there is a way to make the tan thing work.

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆

foutre posted:

Not sure if this is the best spot for this, but is there any way to use the parts of the Spotify API that require user authorization without actually loading up a browser with the redirect url at some point?

Basically, I'm trying to make a button that you can just click to save songs on spotify (using the Spotipy library) but the weak little Raspberry Pi Zero W I'm using can't actually load the authorization page in Chromium - it can make calls that don't require authorization just fine though.

Worst case, I could use a different Raspberry Pi - basically, just want a box with a button I can press without having to open my phone.

Rather than running a web browser on your raspberry pi it seems like you should run a web server (which should be more lightweight). Serve a webpage on your local network that has a "log in through spotify" button and then just visit that page on your phone.

That's the method Spotify shows off on their own web api tutorial page at least.

Their examples are in nodejs w/ Express but you should be able to do basically the same thing in Python with Flask.

RPATDO_LAMD fucked around with this message at 07:38 on Apr 17, 2022

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆

Gothmog1065 posted:

I'm having a dumb, and google isn't giving me a good answer. This is in shell, KSH 93 mainly.

Simply put, I'm collecting a list of words from directory filenames into a variable, then I want to unique sort that list to do other stuff. In essence:

code:
list="a\nb\nq\nd\nf\na\nc\na"

sortList=$(echo $list | sort -u)
printf $sortLIst


Doesn't work, it just prints the unsorted list out.

Echo does not interpret escape sequences like \n, so it's outputting the literal characters '\' and 'n' rather than the whitespace sort wants.

It seems like
code:
sortList=$(printf "$list" | sort -u)
should do what you want.

RPATDO_LAMD fucked around with this message at 22:09 on Apr 27, 2022

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆
Yeah uh this sounds like the typical X-Y problem where you have one thing you're trying to do, you've decided OCRing the screen from C is somehow the best solution, and now you're asking about how to do ocr in C instead of asking about your actual end goal.

I'd suggest looking into autohotkey if you're trying to mess around with graphical windows programs somehow but really I have no idea what you're trying to do.

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆

cheetah7071 posted:

this is an idle curiosity more than something truly important but: what is the actual algorithm for dynamic memory allocation? When I call new or malloc, what does the assembly that generates actually do?

I assume it uses a heap data structure but when I try to google it I get lots of articles about the advantages and disadvantages of dynamic memory, and about the heap data structure (which I assume is the data structure that the heap uses because of the name, though it's not clear to me how that data structure would be helpful for the problem), which are far more useful but don't satisfy my idle curiosity on a topic whose answer is essentially meaningless to me

e: and of course immediately after hitting post I stumble on the right term to google to get useful answers, though I'm still interested in hearing more easy-to-understand answers than technical papers

It's typically an intrusive linked list, or more often a collection of several linked lists containing free chunks of different sizes.
You might have one linked list each for memory chunks of 16, 32, 64, etc etc bytes and just hand out the smallest size that fits what the caller needs. If a caller allocates close to 512 bytes, you just pull an arbitrary node outta the 512-byte free list. Different allocators will have different strategies for how they choose this arbitrary node to achieve goals like keeping cache locality for back-to-back allocations or minimizing fragmentation or etc etc.

You also need logic for handling splitting up chunks of memory (e.g. if you only have 512-byte chunks left and a user tries to allocate 32 bytes, you don't want to waste tons of memory) and for coalescing adjacent small chunks back together into big chunks again (e.g. after the user allocates and frees a few thousand 32-byte objects, they might try to allocate a 512-byte object again, which means you need some efficient logic that can figure out when a bunch of smaller chunks of free memory are all adjacent and can be combined into one larger chunk). And if you're totally out of memory you grab another memory page from the OS/kernel.

I had to write a little toy memory allocator for my data structures class, although it only had to deal with one size of allocation so I didn't get into all the crunchy memory coalescing algorithms.

For example here is the struct glibc's malloc.c uses:
code:
/*
  This struct declaration is misleading (but accurate and necessary).
  It declares a "view" into memory allowing access to necessary
  fields at known offsets from a given base. See explanation below.
*/

struct malloc_chunk {

  INTERNAL_SIZE_T      mchunk_prev_size;  /* Size of previous chunk (if free).  */
  INTERNAL_SIZE_T      mchunk_size;       /* Size in bytes, including overhead. */

  struct malloc_chunk* fd;         /* double links -- used only if free. */
  struct malloc_chunk* bk;

  /* Only used for large blocks: pointer to next larger size.  */
  struct malloc_chunk* fd_nextsize; /* double links -- used only if free. */
  struct malloc_chunk* bk_nextsize;
};
It keeps free memory in a doubly-linked list. Note that the next and previous pointers are in the same memory area that the user would normally write to. That block of allocated memory just gets reinterpreted as a malloc_chunk when malloc actually touches it. So if you write to a pointer after freeing it, you will actually be clobbering the internal linked-list pointers and corrupting the heap, which is why use-after-free can be so catastrophic.

Glibc uses different "bins" (linked lists) for chunks of different sizes, according to this scheme:
code:
/*
   Indexing

    Bins for sizes < 512 bytes contain chunks of all the same size, spaced
    8 bytes apart. Larger bins are approximately logarithmically spaced:

    64 bins of size       8
    32 bins of size      64
    16 bins of size     512
     8 bins of size    4096
     4 bins of size   32768
     2 bins of size  262144
     1 bin  of size what's left

    There is actually a little bit of slop in the numbers in bin_index
    for the sake of speed. This makes no difference elsewhere.

    The bins top out around 1MB because we expect to service large
    requests via mmap.

    Bin 0 does not exist.  Bin 1 is the unordered list; if that would be
    a valid chunk size the small bins are bumped up one.
 */

RPATDO_LAMD fucked around with this message at 07:50 on May 24, 2022

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆

Sirocco posted:

I'm rendering sprites to two different textures in OpenGL, one's for the main game, and the other is for a cutscene. The point of this is so that I can run a shader program to have a transition effect where the cutscene moves onto the screen and pushes the gameplay screen off. For testing purposes, I've rendered a single small sprite to the centre of the second texture. But when I try to sample from that texture the sprite's not small but fills up the whole of it and I can't quite seem to figure out why. The transition works fine, but instead of a black screen coming down with a small sprite in the centre, I just get an enormous sprite filling up the screen.

Any ideas where I'm going wrong here?

You're pretty light on details here, and the exact issue is probably somewhere in the details.
Render-to-texture should work out just the same as rendering to a framebuffer. Does that single small sprite show up as the correct size etc if you render it to the main framebuffer instead of the texture?

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆

cheetah7071 posted:

Is there any way to configure git to handle committing to two repositories simultaneously in a coherent way? I have a project where the main branch is still in constant flux, but as part of a deadline issue I'm sprinting to make a version of it that's suitable for internal use before then, which would, in better circumstances, be a private fork of the main branch because it will have some stuff that doesn't belong in the public repository.

Ideally, I'd like a situation where by default, when I make a commit, for most of the files (the ones that belong in the main branch) it commits to both the main and the private versions, and for a small subset of the files, it only commits to the private version. Ideally I'd do this without having two copies of the code to keep in sync on my harddrive.

Is there a reason why your fork needs to be an entirely separate repository and not just another branch in the first repo? As long as you make sure to make separate commits for changes touching the universal files vs the project-specific stuff you can just cherry-pick all the relevant stuff back to the main branch.

RPATDO_LAMD fucked around with this message at 02:28 on Jun 23, 2022

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆
Git doesn't have any internal concept of public or private.
When you want to publicize things later down the road you can fork this current repo and delete all the branches and commits with private stuff in them. Hopefully by then you won't be simultaneously developing 2 versions of the same software? Otherwise it will be a pain and you'll have all the same problems you have right now all over again.

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆

LongSack posted:

It may be, and there are a number of good suggestions in that thread, so thanks for that link.

I started playing around with Rider, but it is missing one feature (that people have been asking for for four years) - auto format on save, and i really miss that. It also occasionally has problems indenting JSX elements properly. VS Code has this problem, too, but at least the auto format on save fixes it.

Other jetbrains IDEs have this feature under "actions on save" in the settings

I would really be surprised if Rider was missing it since afaik their ides for different languages are mostly based on the same codebase with just a few tweaks

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆

rjmccall posted:

Note that if this is an MMO or something like it, this sort of pattern is not at all unlikely to get detected and get your account banned.

Presumably the reason you can't use autohotkey is "the anticheat detects autohotkey and complains"?
So yeah if you are gonna program your own thing your first step is to reverse engineer the whole anticheat system, understand how it works and figure out a way to bypass it.

Which is a lot of work! The people who do that sort work often sell their cheats for realmoney online.

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆
Yeah the big thing you have to watch for when rewriting your "technical debt" in new trendy language/framework of choice is that you're not just losing out on the main functionality but also on what's at this point 30-40 years of bugfixes and special handling for weird edge cases.

There is no technical reason to ever use COBOL in a new project, it's just a very old language that used to be pretty popular and is now extremely unpopular.
But there is no business reason to throw out and remake the 40 year old system you have in maintenance mode that still works fine. Especially for banks where reliability and correctness are worth way more to them than efficiency -- it doesn't really matter if it's running on a crappy old ancient mainframe and can't scale up the way a cool cloud-based containerized microservice thing could. It's still fast enough to do what it needs to do, and unlike e.g. Google the hardware costs are a negligible part of their total business. Having their fancy new java backend go down for an hour due to some unknown new bug introduced in development would probably cost the bank more money than maintaining the old COBOL crap for 10 more years.

Although a lot of non-bank tech companies make this mistake anyways and throw out their 3-to-5 year old projects for full rewrites at the behest of their devs. It's a lot of fun for the devs! And probably better for the devs' careers too since they get to put whatever trendy modern framework they used in their resume. But it usually isn't too helpful for the actual business part of the business.

RPATDO_LAMD fucked around with this message at 22:17 on Sep 19, 2022

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆
Circle buffers are cool!

Suppose you want to store the last 20 results of some operation, and wherever a new result comes in you want to kick out the oldest piece of data. With a normal array you would have to constantly reorder it whenever you made a change. But if you use a circle buffer, instead of having a fixed head and tail position you keep track of a moving head pointer. Then the tail (the oldest piece of data) is always gonna be at (head + 1) % 20. So when a new piece of data comes in you just overwrite the tail and bump the head pointer forward by 1. The modulo makes sure that it loops around, so if the head is at 19 and you push something, the head ends up at 0 again. Push 20 more things and it'll loop all the way around and back to where it started. You can keep writing data forever and never run out of space.

Modulos are also used for some cool math stuff, for example RSA Encryption is based on modular arithmetic. The public and private keys are chosen alongside some modulus m such that, for any x, ((x ^ pub) ^ priv) % m = x. But the kinds of numbers used for serious encryption won't fit in a 64-bit int so your language's built-in % operator probably can't be used to implement it, unless you use Python.

RPATDO_LAMD fucked around with this message at 08:35 on Oct 3, 2022

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆
The situation of "a commit I thought was gone came back and jumpscared me" can happen if you reset or rebase away the original commit instead of just reverting it.

Those operations both 'rewrite history' instead of adding on to the end of it, which is why they should only really be used locally, and why you can't do them on a remote repo without using force-push. So probably won't be an issue on your remote Repo A unless somebody is force pushing crap inappropriately.

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆
So your problem is that you are ordering by date but there are several rows with the exact same date field. You want to pick the latest or the lowest-row in the spreadsheet or whatever, but ORDER BY is a stable sort, so it never changes the order of things which actually have equal values in the ordered-by column.
As an example, here is "select * order by A asc" and "select * order by A desc", you can see that the values which have the same date / "A" value actually stay in the same order between each:


Seems like your best bet is to add an extra automatically-generated index column that has no dupes or equal values, and order by that.

So add an index column that counts up from 1 to infinity, ORDER BY that index, and then you can do limit 1 with ASC or DESC to actually capture the first/last element guaranteed.

RPATDO_LAMD fucked around with this message at 16:34 on Oct 17, 2022

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆

pokeyman posted:

Really? Why do people avoid let? I remember var's scoping rules being pretty baffling. Though maybe I shouldn't be surprised about a community that rallied around automatic semicolon insertion.

It's let vs const, not let vs var. It's just a question of not making variables mutable when they don't need to be.
Rust has the right idea with everything defaulting to its version of const and needing a specific keyword to make it mutable.
Like every other language has a best-practices styleguide of "use const whenever you can unless you specifically need a non-const variable" but many programmers just don't do it just because it's an extra keyword and more effort.

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆

Dominoes posted:

Why is that I can compile a rust program using `cargo build`, and even if it has GUI, 3d graphics etc it'll just work on any modern version of the OS brand I compiled on, but when I try to compile C-based OSS software, it's a nightmare and usually doesn't work?* What does this have to do with the language and system dependencies? Could someone make a Cargo for C/C++?

*Related: Why is so much C OSS compile-it-yourself, when, for example, making a Win binary and Lin binary and hosting is an issue of `cargo build --release`; open WSL and do the same?

Because cargo is a centralized package manager which can automatically fetch the correct versions of dependencies from one authoritative centralized source. When the metadata files (cargo.toml) say your program depends on version a.b.c of serde, cargo knows exactly where it can find that package (and all the versions of it) -- https://crates.io/crates/serde. So it can easily automatically download the exact files your program needs.
Same for js's npm, go's built in dependency manager, python's pip (kinda, but the fact that packages are systemwide instead of local is a huge PITA and needs its own workarounds with venv etc), and pretty much any other modern language

C and C++ have no central package manager or official package repository -- they require you to janitor the dependencies yourself, and to run all over the place finding the "correct" versions of all the source files and binaries you need. Or using some ad-hoc hacky system that tries to do the same thing automatically.

Adbot
ADBOT LOVES YOU

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆
There is a windows version of git, you don't need to install linux or whatever crazy stuff.
https://git-scm.com/download/win

Of course it's still a command line interface, if you want a friendlier gui there are many third-party gui clients. Github desktop is pretty crap, I recommend Git Extensions or maybe the free versions of git fork / gitgraken.
Github, btw, is just a company that offers a git hosting service. So it's just a regular ol' git repo that works with any non-github-affiliated git tool, there's nothing special about being a 'github repo' besides the fact the url has github.com in it.

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