Mr Shiny Pants posted:Sounds like you need a queue. No, that's not what I meant by specific order. I want to be able to dictate that for every set of mutations on the database, the order will always, without exception, be the same (e.g. Table1, then table2, then table3, never table2, then table 1 etc.)
|
|
# ? Dec 2, 2019 12:14 |
|
|
# ? May 18, 2024 03:51 |
|
Jewel posted:Oh jeez, I forgot this was so soon. My plan this year was to learn F# or Rust, I'm not mentally prepared yet https://learnxinyminutes.com/docs/rust/ https://learnxinyminutes.com/docs/fsharp/
|
# ? Dec 2, 2019 17:07 |
|
Ty for these! I more meant I'm in the process of studying/learning another non-programming thing right now and don't have the mental capacity for both at once but this will help when I come back around to it!
|
# ? Dec 2, 2019 19:17 |
|
Jewel posted:Ty for these! I more meant I'm in the process of studying/learning another non-programming thing right now and don't have the mental capacity for both at once but this will help when I come back around to it! If you know C#, you're already an F# dev, you just don't realize it yet.
|
# ? Dec 4, 2019 19:28 |
|
Cuntpunch posted:If you know C#, you're already an F# dev, you just don't realize it yet. That was pretty much my mindset, like, "I abused the hell out of Linq during the other years' AoC, why not just go full-throttle" but I'm worried full-functional is gonna be rough for every situation, which is why rust was the other option.
|
# ? Dec 4, 2019 19:36 |
|
Jewel posted:That was pretty much my mindset, like, "I abused the hell out of Linq during the other years' AoC, why not just go full-throttle" but I'm worried full-functional is gonna be rough for every situation, which is why rust was the other option. F# is pretty flexible, there's a lot of OO-style stuff in there if you want to use it - you can do everything with classes and methods and mutable variables if you really want. So you might find moments where the functional approach is a bit tough, and you can dip into the OO side of things to smooth it over Here's a couple of links if you're interested! 13 ways of looking at a turtle - maybe you only wanna look at the first couple but it shows OO vs functional approaches to the same problem in F# Type extensions - add methods to types because you can
|
# ? Dec 5, 2019 01:42 |
|
F# is a beautiful language, I really like working with it. The community is also great: Fable, Paket, Fake etc. etc. When I sit down to write F# code I feel happy, I like how it looks and how it works.
|
# ? Dec 5, 2019 20:09 |
|
Jewel posted:That was pretty much my mindset, like, "I abused the hell out of Linq during the other years' AoC, why not just go full-throttle" but I'm worried full-functional is gonna be rough for every situation, which is why rust was the other option. I mean it more literally than that. Not 'you have the potential to be', not 'you're close'. Nope, if you are comfortable/fluent with C# you're an F# dev also. There's nothing about F# that demands some sort of weird functional-burrito-purity, go ahead and write C# style code and use C# libraries - but you get at the bare minimum the advantage of a terser syntax and a stronger type system.
|
# ? Dec 5, 2019 20:35 |
|
Anyone know some particular algorithms or data structures I should use to efficiently find the intersection points of a series of 2D line segments? The most basic implementation would be testing each pair of edges for (n^2) complexity, but I guess if I ordered them in some meaningful way, maybe it could be done in (n*log n) ? I just can't really picture a way to compare/sort them that makes sense. Would a BSP or quad tree be ideal? I've never tried implementing one, just vaguely know of them. Some more specifics of what I'm doing, in case there's even more specialized ways to do it: This would basically be part of a 2D CAD "Offset" operation, where polygon edges are moved in or out along their normals depending whether the offset value is negative or positive. So the output after this offset could intersect in lots of ways which I need to clip to avoid self-intersecting contours, but I also need to make a sorted list of the exact intermediate offset values and the corresponding edges/vertices invloved, where each intersection happens.
|
# ? Dec 7, 2019 01:29 |
|
A simple ordering is by X coordinate of the leftmost endpoint. You can then take a given line segment, and process forward until it finds a segment whose left endpoint is right of the current segment's left endpoint; at that point they can't possibly intersect. The more involved solution would be a quadtree for 2D, or octtree for 3D.
|
# ? Dec 7, 2019 01:34 |
|
TooMuchAbstraction posted:A simple ordering is by X coordinate of the leftmost endpoint. You can then take a given line segment, and process forward until it finds a segment whose left endpoint is right of the current segment's right endpoint; at that point they can't possibly intersect. Otherwise, a trivial counterexample would be: Black is current segment, red's left is to the right of black's left. Also I might try a kd-tree, (which I had confused with BSP before), which AIUI is generally preferred over quadtrees? That is, if I decide to go beyond a simple single component sort suggested above. peepsalot fucked around with this message at 03:04 on Dec 7, 2019 |
# ? Dec 7, 2019 03:01 |
|
Er, right. Whoops.
|
# ? Dec 7, 2019 03:09 |
|
peepsalot posted:Anyone know some particular algorithms or data structures I should use to efficiently find the intersection points of a series of 2D line segments? This is a well studied problem. Here's one: https://en.wikipedia.org/wiki/Bentley%E2%80%93Ottmann_algorithm
|
# ? Dec 7, 2019 21:16 |
|
This is in C. I am trying my hand at building a finite state machine for a class exercise. We have to write a program that asks for a number of seconds and plays a noise. We are learning about GPIO in embedded systems. Very simple thing, but I am happy that, for the first time, I sat down and sketched the whole flow graph and the whole thing and what's coming up is a result of that. So: I defined an array of structs. Each member looks like this code:
So quick questions: - Every member of the array has an identical pointer to the same int that signifies the current state. code:
- Should I use the restrict or register keywords on the members of the array ? I think restrict on function pointers doesn't work, but I am a beginner. - Is it ok to try and bind an inbuilt function into a function pointer like so ? code:
Thanks a lot in advance Dawncloack fucked around with this message at 13:26 on Dec 8, 2019 |
# ? Dec 8, 2019 13:23 |
A small syntax detail: You only use parentheses after a function pointer member variable when you want to call the pointed-to function. When you want to act on the function pointer variable (i.e. change where the variable points to) you do not use parentheses.C++ code:
|
|
# ? Dec 8, 2019 14:04 |
|
I wanted to go back to the topic of learning discrete math for programming and how it doesn't really correlate to day-to-day work. I did not see the correlation for years and it had more to do with my lovely math background than any real lack of a connection. I got absolutely hosed transitioning from my Catholic elementary school to public middle school in math. We had not done any pre-algebra and I was screwed all the way through until my senior year of high school. Meanwhile, I was programming just fine and was writing a software audio synthesizer with an FFT for filtering. People would say programming is very mathematical and I would dismiss it because it didn't explain how I could do it. When I got to college, I actually did fine with calculus and statistics since it was something like a reset. However, I was poo poo at discrete math and I still don't know why other than that I very rarely had to do anything with proofs before that and was paralyzed with whether I had achieved proper truth or something. Meanwhile, I was programming just fine. I got a real complex about all this when I recently was building some stuff while also doing some 3d with Unity. I had been horrible at geometry and trigonometry before but I start getting all these spatial visualizations I never had before. I have brought this up before in particular regards to algebra. To this day, if I have to solve for x in something taking more than five lines of scribbles then I. Will. gently caress. It. Up. I figured out it usually happens with a division, but that's about it. I can model things quite easily but the math afterwards is a trainwreck. I think the problem with good programmers that are had at math is that the programming is coming from the part of the brain that does the math but the purely mathematical stuff is not. In the case of programming, there is a certain sense of logistics and temporality ("these things fit together in this order") that dominates the line-by-line stuff. I have some notion that a lot of abstraction in OOP intersects with set theory and discrete math ("this and that are related in this way but not that way therefore I can use this interface here to get what I need out of them"). So if I had to try again I would have more specific goals of trying to create those kind of mental models to solve the problems instead of trying to cram it into the part of my head that regurgitates things. I am pretty sure that was my problem growing up because the biggest thing I remember from pre-college math was cramming arithmetic tables because we had to do so many in 10 minutes in a drill or get detention. This was the obsession of our nun principal in elementary school. Hell, I would practice by sorting the exercises in a way that made it is faster to write down which was definitely more advanced math, but I didn't recognize it that way. So IMO doing math stuff indeed is very valuable but you do need a goal unless you have mind that already puts math stuff in the right part of your head. I think that trying to code for some problems that could be better addressed with certain mathematical methods helps because it grounds these problems and grounds them particularly in the right part of your head where they will be useful later.
|
# ? Dec 8, 2019 16:06 |
|
Dawncloack posted:
This doesn't compile. If you really mean unsigned int8_t, then just write uint8_t. Same goes for the int32_t. For current_state_func, if that isn't taking any arguments, leave out the * next to void. Dawncloack posted:- Should I use the restrict or register keywords on the members of the array ? I think restrict on function pointers doesn't work, but I am a beginner. Dawncloack posted:- Is it ok to try and bind an inbuilt function into a function pointer like so ?
|
# ? Dec 8, 2019 20:32 |
|
Thanks for the notes guys! Sorry the code doesn't compile, it's all in the draft state.
|
# ? Dec 8, 2019 21:02 |
|
Are there linear time algorithms for checking whether or not a 2d polygon self-intersects? Cause I think I came up with one. I'm not 100% sure its correct yet, but seems like it would work so far. Trying to judge how big a deal that is if correct, and if I should try to publish a paper or something. I'm not in academia so idk anything about writing papers etc. Do fame and fortune await me?
|
# ? Dec 10, 2019 04:35 |
|
peepsalot posted:Are there linear time algorithms for checking whether or not a 2d polygon self-intersects? Cause I think I came up with one. I'm not 100% sure its correct yet, but seems like it would work so far. Trying to judge how big a deal that is if correct, and if I should try to publish a paper or something. I'm not in academia so idk anything about writing papers etc. Do fame and fortune await me? Read my reply to your previous question. More information here, including specifically the question of detecting if a polygon is simple (not self-intersecting): https://www.webcitation.org/6ahkPQIsN Also it's (apparently) been shown that you can't do better than O(n log n) for line segment intersection. I'm not if that also applies to polygons but it seems likely. Edit or not, see below HappyHippo fucked around with this message at 05:09 on Dec 10, 2019 |
# ? Dec 10, 2019 05:00 |
|
peepsalot posted:Are there linear time algorithms for checking whether or not a 2d polygon self-intersects? Cause I think I came up with one. I'm not 100% sure its correct yet, but seems like it would work so far. Trying to judge how big a deal that is if correct, and if I should try to publish a paper or something. I'm not in academia so idk anything about writing papers etc. Do fame and fortune await me? There is a linear time algorithm for triangulating a polygon that can be used for detecting whether there is a self-intersection in linear time (https://www.cs.princeton.edu/~chazelle/pubs/polygon-triang.pdf) but no one uses it because frankly that is one dense loving paper and no one's got time to write code that does that especially given there are a bunch of easy (albeit slower) alternatives and computers are fast.
|
# ? Dec 10, 2019 05:07 |
|
https://arxiv.org/abs/0812.0893 A polygon is an example of a connected graph.
|
# ? Dec 10, 2019 05:31 |
|
Bruegels Fuckbooks posted:There is a linear time algorithm for triangulating a polygon that can be used for detecting whether there is a self-intersection in linear time (https://www.cs.princeton.edu/~chazelle/pubs/polygon-triang.pdf) but no one uses it because frankly that is one dense loving paper and no one's got time to write code that does that especially given there are a bunch of easy (albeit slower) alternatives and computers are fast. It's a difficult paper to implement. It falls back in a few places on the old mathematicians trick of hand waving that something can be done because someone else showed you can do it on the dual of the thing they're talking about and good luck. Edit: Earlier in my career I spent 4 days trying to implement that paper and failed. Then I spent an hour and got ear clipping to work and gave no shits about the imperceptible cost differences in my ~1-2k vert polys. leper khan fucked around with this message at 14:42 on Dec 10, 2019 |
# ? Dec 10, 2019 14:39 |
|
Thanks for the replies. I just read up a little on ear-clipping and realized that my idea was sort of a variant of that, with my own flawed definition of an "ear" which was not robust (and can't be easily fixed in linear time). That said, the fast self-intersecting polygon check was just sort of a distraction from my original goal that I thought was interesting, but not something I directly needed to implement for my problem.
|
# ? Dec 10, 2019 18:18 |
|
Can I get an opinion on something? I've gone back to an old project of mine. Porting RISC OS to an unsupported SBC. I'm just pushing forward, doing it my way. I figured I'd tackle I2C to get back into things. The OS supports low level bit banging and high level transfers. I opted to start with the bit banging version. The I2C hardware supports it like a not GPIO. Ie I can set input and output, read and write the lines. I did the first build and test of ny port since February last night. My IIC code didn't work right. This didn't surprise me. I'm after an opinion on this: quote:Sets the SDA and SCL lines on the specified bus. A 0 value represents logic LOW, 1 logic HIGH. The function then reads back and returns the values present on the bus, to permit arbitration. https://www.riscosopen.org/wiki/documentation/show/HAL_IICSetLines Is the read after writing done after setting SDA and SCL back to input to see what's on the bus? Or is it checking it while it's still an output? If it is doing it while it's an output that's not a whole lot of time for anything to happen, but otherwise it makes more sense.
|
# ? Dec 11, 2019 22:32 |
|
So I'm getting interested in one of my old projects again: making a deckbuilder for Kingdom Hearts Re: Chain of Memories. So basically, in COM there are sleights you can use to do special attacks, and building a sleight deck is essentially the only tolerable to play the game (in my opinion). Sleights operate on the following principle: you have an ordered (non-shuffled) deck chosen from a larger card list of yours. During combat if you choose an ordered set of 3 cards in the deck whose properties meet some constraint (usually related to something analogous to card "suit" or "color" and sum of the card "ranks"), you permanently remove the first card in the set from combat, temporarily discard cards 2 and 3 (which will be restored next time you go through your deck), and then execute an attack. The "sleight deck": is basically abusing this mechanic so you can spam the sleight button and win. So for instance, Sonic Blade is a popular sleight for bosses, and to use it you need three cards whose "ranks" (0-9) sum to 20-23 (inclusive), and are all of different "suits" (there are 8 or 9 different attack card suits). So to build a Sonic Blade sleight deck you basically just get out a sheet of paper, write down your cards, and find some order that, for multiple reduction passes discarding the first of 3 cards, the next pass will still have cards that sum between 20-23, and all attack cards are still of different types/suits, for as many passes as possible. There's also a deck limit, but instead of being number of cards, each card has its own cost and your deck has a cost limit. A more complex folding sleight, which I only used for the final boss and is a pain to make, is a lethal frame deck. Lethal frame involves specifically the magic card "stop", followed by any two attack cards, rank/suit agnostic. So the trick there is to build the deck so that the first pass is all lethal frames, and then after that it reduces into a normal sleight deck (e.g. Sonic Blade above). I'm wondering if anyone has any ideas for how to approach this. It seems like a cursed, even harder mashup of the subset sum and knapsack problems since we have 1. a cost limit, 2. the need for subsets to sum to a given range, 3. a hard size of the subset, 4. subsets-of-subsets to consider, 5. order matters, and 6. elements have additional constraints (tags like attack type, magic, etc). I'm leaving out some of the fuzzier constraints you can do when building by hand (e.g. "when we get to the last reduction it's acceptable for me to press left or right once or twice to get more mileage out of the reduction so they don't need to be strictly in order"), because it would just make it even harder. Can anyone think of any strategies for this? The additional constraints break almost every existing DP or approximate solution to subset sum and knapsack I can think of. I'm guessing it'd have to have some sort of heuristic-driven guess and check component because there's absolutely no way to solve it exactly, as well as just hardcoding certain things ("when building this sleight don't even bother to guess cards with value/type <X>"), but the multiple reduction step is the primary thing eluding me. I'm thinking the easiest way would be to build up the "last" reduction first, and then only insert things in the "discard" slots for the higher level, but then there's still the issue of backtracking in case there's a better option. Linear Zoetrope fucked around with this message at 23:55 on Dec 11, 2019 |
# ? Dec 11, 2019 23:49 |
|
Linear Zoetrope posted:So I'm getting interested in one of my old projects again: making a deckbuilder for Kingdom Hearts Re: Chain of Memories. Have you considered getting obsessed with a different game The most popular/successful set of techniques for highly constrained discrete programming problems like this are so-called ‘state-space relaxation’ methods. Unfortunately I don’t know these nearly well enough to teach them, and the iirc usual approach is ‘Find a professor who knows about state-space relaxation and agree a consulting fee’. You might be able to get somewhere with a combination of brute force, heuristics and branch and bound. You didn’t say anything about how big is the card list from which you choose the deck, but if it’s (say) 400 cards, then the number of ordered 3 card combos is about 63 million, and presumably most of those aren’t feasible solutions, so you may be able to get a few steps in (e.g find all feasible 3, 4 card decks) via brute force. After that I’d try tightening the constraints then progressively loosening them, so eg if you want to solve for decks with a maximum value of 100, do something like: 1) brute force solutions for 3,4 card decks, store them 2) set MaxValue = 1 3) Find candidate solutions by adding cards to the ‘tighter constraint’ solutions found in previous steps, 4) remove any candidate solutions that breach constraints 5) heuristically filter the set of solutions down filter if necessary (if it’s getting too large) 6) store all the solutions for this MaxValue 7) set MaxValue += 1 and repeat from (3) This may or may not work, and there are a lot of details that it will be up to you to figure out, but it might give you a reasonable starting point.
|
# ? Dec 12, 2019 17:32 |
|
This isn't a question. It's just a warning. I spent this morning writing a struct in a header which matches the structure of a workspace in assembly. I save regularly. I just went back to it to add a final entry, and it was gone. There was a permissions issue. There was only a zero byte file. I was using Code::Blocks. Apparently saves can fail silently.
|
# ? Dec 13, 2019 02:52 |
|
That's a bummer, I hope getting it back proves easier than expected and fear that you haven't done it quite the same way doesn't ruin your day. Notepad++ used to have a similar bug of sometimes silently writing a file of all zero bytes over an existing file.
|
# ? Dec 13, 2019 03:15 |
|
Dumb Lowtax posted:That's a bummer, I hope getting it back proves easier than expected and fear that you haven't done it quite the same way doesn't ruin your day. Notepad++ used to have a similar bug of sometimes silently writing a file of all zero bytes over an existing file. It did cause me some irritation, but it's just a personal project and not for money so it's no big deal. Typing out huge headers of "#define"s or various data structure are some of my least favourite things, programming-wise. In the same project I have headers that took many, many hours of reading datasheets and implementing. So this one is only a minor loss. Btw, I'm tempting fate by working on the current files on an NFS mount, because I want to use an IDE with things like autocomplete, and I can't use it on the same device which has the toolchain. Okay, technically I can kind of sort of because some clever people made a linux hosted version of the same OS, but for some reason its performance has gone through the floor in the past ??? months, year? I don't know.
|
# ? Dec 13, 2019 23:48 |
|
Have you considered working on files locally, and setting up the build config to sync everything up to the device before kicking off the toolchain?
|
# ? Dec 14, 2019 01:16 |
|
General_Failure posted:Can I get an opinion on something? It's letting you check for a bus peripheral ACK. You'd write a '1', read back a '0' in the ACK case. You don't really 'drive' a 1 on I2C, you just let go and rely on the pull-up. Are you setting the in/out state (is it 1 bit or two?) or are you just trying to understand what it's doing?
|
# ? Dec 16, 2019 19:25 |
|
JawnV6 posted:It's letting you check for a bus peripheral ACK. You'd write a '1', read back a '0' in the ACK case. You don't really 'drive' a 1 on I2C, you just let go and rely on the pull-up. Trying to figure out how to do this without copypasting chunks of a datasheet. On the device it has I2C hardware. It can do high level and line control mode. The operating system can also do both. From my perspective, low level is a good stepping stone. We have: SDA_CTL_EN and SCL_CTL_EN, which can allow control of SDA and SCL. SDA_CTL and SCL_CTL, which set the line level. SDA_STATE and SCL_STATE which read the current state of the pins. What I'm trying to work out is if it would make more sense for the function to be reading the line state while the CTL_EN bits are enabled, to check whether it happened, or whether they should be disabled first and then read. Also should I be leaving SCL_CTL_EN enabled maybe? Bear in mind I'm only interested in master mode at this point. My last attempt at trying to get meaningful information out of the bus didn't quite work so I'll have to sprinkle some debugging feedback around. There really aren't many other choices in this circumstance.
|
# ? Dec 16, 2019 23:47 |
|
I'm trying to build a program for administering a betting game for myself and some friends. I wrote a little 500 word post up about it but I'm not sure where to post it. I'm basically looking for advice/resources on it's implementation. Should I post it here or go into project.log or...?
|
# ? Dec 23, 2019 20:13 |
|
Maybe updates once you get started should go in project.log, but feel free to ask for advice or questions or whatever.
|
# ? Dec 23, 2019 20:20 |
|
I don't really know where to ask this... Does anyone know if a simple thing exists to give a HTTP frontend to an arbitrary local executable? I imagine something that takes a query string maybe, parses them for the command arguments, runs the command with arguments, and returns the command output. I could write this easily enough, but it seems like something that'd just exist already.
|
# ? Dec 24, 2019 00:02 |
Thermopyle posted:I don't really know where to ask this... Classic CGI? Maybe with a light wrapper around the actual program. https://httpd.apache.org/docs/2.4/howto/cgi.html
|
|
# ? Dec 24, 2019 00:04 |
|
Thermopyle posted:I don't really know where to ask this... It's been a while since we've seen a hand rolled arbitrary execution exploit being made
|
# ? Dec 24, 2019 00:12 |
|
Thermopyle posted:I don't really know where to ask this... Node.js
|
# ? Dec 24, 2019 00:50 |
|
|
# ? May 18, 2024 03:51 |
|
Thermopyle posted:I don't really know where to ask this... I mean, maybe I’m not getting what you are trying to do but to me it seems like this could be solved by a bunch of things, from curl to electron.
|
# ? Dec 24, 2019 00:57 |