|
I have a bunch of immutable game data (specialty fantasy playing card data, like magic) I need to load into my statically compiled game engine What's the best way to handle this? In python I would just have a card_data.yaml or json file, then serialize that into card objects on start
|
# ? Apr 17, 2022 02:18 |
|
|
# ? Apr 19, 2024 16:50 |
|
What's the language and what do you want to accomplish? You could still load from a serialized file at runtime, embed the file in the binary and load from that, or generate a file with all the objects you need statically built.
|
# ? Apr 17, 2022 02:23 |
|
Yeah, there's nothing about a compiled language that prevents you from doing any kind of data storage technique you could do with a JIT language. I would still do some kind of external serialized file so you don't need to recompile a new build any time you wanted to update or release a card. JSON or XML are pretty standard for that. Also, come visit us in the game design thread!
|
# ? Apr 17, 2022 02:27 |
|
cum jabbar posted:generate a file with all the objects you need statically built. Ooh, I like this It's in rust, it's just an ncurses clone of slay the spire (roguelike) to keep my skills from getting too dull I think I'll just write a file generator like you suggested, and add the ability to import a file on start
|
# ? Apr 17, 2022 02:35 |
|
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.
|
# ? Apr 17, 2022 07:19 |
|
Instead of using chromium to handle rendering the webpage, can't you just interact with the webserver directly? Take a look at the login page and see how the credentials are submitted. As long as that page doesn't have a captcha or something, Spotify shouldn't care if you're a person or not. If it does have some kind of captcha, you might have to manually auth on one device, capture the access and refresh tokens, and manually store them in your app. Edit: vv That's a good way to do it KillHour fucked around with this message at 07:38 on Apr 17, 2022 |
# ? Apr 17, 2022 07:32 |
|
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? 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 |
# ? Apr 17, 2022 07:34 |
|
Hadlock posted:Ooh, I like this Looking at rust things, you could use serde_json or the binary version to do the same card_data.json idea as in python. You could even have a json file locally and write a small tool that converts it to the binary form, and distribute that one (since it should load faster)?
|
# ? Apr 18, 2022 02:40 |
|
RPATDO_LAMD posted: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. KillHour posted:Instead of using chromium to handle rendering the webpage, can't you just interact with the webserver directly? Take a look at the login page and see how the credentials are submitted. As long as that page doesn't have a captcha or something, Spotify shouldn't care if you're a person or not. If it does have some kind of captcha, you might have to manually auth on one device, capture the access and refresh tokens, and manually store them in your app. Oh yup, thank you! This seems much lighter weight than the Spotipy/chromium version. I figured there had to be a better way but I kept looking at the Spotipy docs instead of Spotify API, whoops. I've done some stuff with Express in the past so hopefully can figure it out w/o too much trouble.
|
# ? Apr 18, 2022 02:41 |
|
KillHour posted:Edit: It really looks like the blue and white (both tangents negative or both tangents positive) are always wrong and the cyan and magenta (one tangent negative and one positive) are correct.
|
# ? Apr 18, 2022 21:39 |
|
I think this belongs in here... A few years ago a Goon I believe did a blog post about creating software that allows courts to have a version of their floorplans accesable to users, sort of like a touchscreen kiosk. Does anyone remember the Goon / what the software was called? I could be imagining this. Thanks
|
# ? Apr 21, 2022 14:38 |
|
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:
Doesn't work, it just prints the unsorted list out.
|
# ? Apr 27, 2022 21:42 |
|
Gothmog1065 posted:I'm having a dumb, and google isn't giving me a good answer. This is in shell, KSH 93 mainly. 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:
RPATDO_LAMD fucked around with this message at 22:09 on Apr 27, 2022 |
# ? Apr 27, 2022 22:06 |
|
That and the quotes I kept forgetting to add. Thank you!
|
# ? Apr 27, 2022 22:16 |
|
Is there a function I can use in C or python that would let me read text from a program in one window then input a text command depending upon what the text was?
|
# ? Apr 29, 2022 00:11 |
|
As in try to find where in memory that text is stored and read it or grab the screen pixels and try to OCR them?
|
# ? Apr 29, 2022 00:39 |
|
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.
|
# ? Apr 29, 2022 00:55 |
|
Azuth0667 posted:Is there a function I can use in C or python that would let me read text from a program in one window then input a text command depending upon what the text was? If you want to automate your wrong voting just say that, no need to beat around the bush.
|
# ? Apr 29, 2022 01:06 |
|
^^: I would love for it to be something fun like that. This is drudgery that we could resolve if we were willing to update 70s era instruments but the budget people are gaping assholes so that will never happen.KillHour posted:As in try to find where in memory that text is stored and read it or grab the screen pixels and try to OCR them? I'm a novice at best so I am not sure which approach is best. Its a proprietary application that has a window with two boxes one shows text and the other is for the input of commands. The text is either it updating the progress of the program, some action the program is taking or the result of the action. The text is usually less than a page but most of what it displays is not useful for decision making. I've only got a few commands I'd use for it so I'd like to automate my responses and let it run over night.
|
# ? Apr 29, 2022 01:09 |
|
Azuth0667 posted:^^: I would love for it to be something fun like that. This is drudgery that we could resolve if we were willing to update 70s era instruments but the budget people are gaping assholes so that will never happen. Pyautogui is super neat: https://pyautogui.readthedocs.io/en/latest/ It basically is a module that allows you to screenshot whatever, process it, do OCR, picture matching, and then also it has the ability to enter keyboard or mouse commands as needed. I used it back in the day to write a frame work that would look at screenshots of Android phones and autoclick through apps to get points in games or giftcards. It works really well. It's a pretty simple python module as well, so it's a nine babies first step into an actual python application. There's another product, memory escapes me, but it basically is a headless Chromium browser that exposes webpages as static PNG images. These two tools together are super powerful to web scrape and act on the output. Embarrassingly, we used to have a sales exec that wanted a specific page from JIRA sent to him every day, but it required a little bit of data entry, so one of our guys (he's a goon that watches this thread, maybe he'll answer) wrote a little app with those two libraries that browsed to JIRA, made the search he wanted, screenshotted and emailed the result. It was a really poor idea, but it worked for him.
|
# ? Apr 29, 2022 02:19 |
|
Azuth0667 posted:^^: I would love for it to be something fun like that. This is drudgery that we could resolve if we were willing to update 70s era instruments but the budget people are gaping assholes so that will never happen. Seconding AutoHotkey, this sounds like a perfect use.
|
# ? Apr 29, 2022 02:30 |
|
I have a small deployment question about Docker. Running a program which uses a python library that takes a file and splits the file into two separate files. This library is being run through an os.system command and spits out a few annoying and uninteresting versioning warnings during this process, so while coding the program these warnings were pipelined to dev/null with no issue. When trying to set this up with Docker, this then creates a problem where the program, on hitting this line, does not wait for the library to finish splitting the file. Since the very next line of code is using one of the two resulting files - that does not yet exist - this gives us a big ol stinking error. If the pipeline is removed, everything waits politely as it does locally but with the disgusting warning text once again cluttering the screen. I don't know that much about VM but I understand it's a quirk of containerized machines. Is setting up a subprocess solution the best way to deal with this, or is there an easier/cleaner solution?
|
# ? Apr 29, 2022 10:06 |
|
I'm trying to help someone with a legitimate business who's adopted a pay-what-you-want model. After a couple weeks of accepting payments via Paypal donate button, their account was frozen and Paypal's customer care team has been predictably terrible. Can anyone recommend payment processors that allow pay-what-you-want, ideally as a no-code hosted form? It seems possible to code up something with Stripe or Square, but I'd rather deliver something generic today instead of something custom next week since revenue has come to a standstill. e: Square's "hosted checkout link" feature ought to do the trick spiritual bypass fucked around with this message at 19:28 on May 3, 2022 |
# ? May 3, 2022 19:18 |
|
cum jabbar posted:I'm trying to help someone with a legitimate business who's adopted a pay-what-you-want model. After a couple weeks of accepting payments via Paypal donate button, their account was frozen and Paypal's customer care team has been predictably terrible. Places like Itch and HumbeBundle are probably the closest to what you want, since they were built with that model in mind. I know his business probably isn't a video game but I'd start there.
|
# ? May 3, 2022 20:16 |
|
cum jabbar posted:I'm trying to help someone with a legitimate business who's adopted a pay-what-you-want model. After a couple weeks of accepting payments via Paypal donate button, their account was frozen and Paypal's customer care team has been predictably terrible. It’s not really a donation right? Couldn’t the customer enter what they want then be processed normally (i.e. not donation) through paypal for that amount?
|
# ? May 3, 2022 20:17 |
|
"Donation" is a red herring here. It's a Paypal payment link. Any further money given to Paypal is potentially going to end up being stolen by Paypal at this point since the account has been frozen for nearly a week.
|
# ? May 3, 2022 20:27 |
I frequently need to delete Windows profiles that build up overtime and clog up drives. Doing this manually is time consuming since a profile is thousands of little files and Windows chugs when you try to make it do that, especially when you do it dozens of time over. Anybody got a Powershell script lying around that could do this? I've heard that using anything other than File Explorer to delete is faster, is that true?
|
|
# ? May 5, 2022 20:53 |
|
I would learn how to write this yourself and double your value to the company then go ask for a raise You're asking the right questions, I could write this script for you in 5 minutes but I think there's a lot of value in doing it yourself If it's faster? I dunno. PowerShell is going to call the same filesystem API as explorer. It's not going to get distracted and wander off half way through though. It may be 5% faster? This is a good exercise though
|
# ? May 5, 2022 21:04 |
|
Just don't do what I did when I first started learning how to automate stuff and run the script without testing on my company's production network. You don't want to accidentally delete everyone's windows account...
|
# ? May 5, 2022 21:06 |
|
Oh yeah, test locally, show it to your boss and be like "hey this worked, we're going to do this from now on" PowerShell has changed a lot in the last 8 years but I think there's some hoops you need to jump through to damage other networked computers, unless your user just has full super admin, which is entirely possible. Beware thar be dargons
|
# ? May 5, 2022 21:11 |
Hadlock posted:I would learn how to write this yourself and double your value to the company then go ask for a raise This is true, and yea I managed to figure out the process of filtering based on lastwritetime well enough. Now it's saying I don't have the permissions to delete anything, even though I launched as admin. -Credentials is specifically not allowed for remove-item. The error is a loving red herring talking about PSdrives, which seem to just be a way to alias and that didn't help either. Now I'm reading I have to take ownership of all the profiles first, which makes a job that takes one line of code into a monstrosity.
|
|
# ? May 5, 2022 21:33 |
skooma512 posted:I frequently need to delete Windows profiles that build up overtime and clog up drives. Use the WMI interface for it. code:
You can use the Special and Loaded properties to filter out special system profiles, and determine which ones are loaded/logged in right now. Beware that the LastUseTime property is generally not reliable, if you want to know when it was last used you're better off looking at the modification date of the file system folder for the profile (the LocalPath property).
|
|
# ? May 5, 2022 21:44 |
|
So wanted to kind of bounce an idea to make sure I'm not going down a path this not completely wrong. I'm looking to compare two folders to see what is different between the two folders. The basic call is going to be as follows (KSH 93): code:
|
# ? May 6, 2022 13:48 |
I think maybe rsync can do it for you, if you ask it to do a dry run and print what it wants to do. Otherwise, merge the lists to a single and compare that to each of the sides. That makes it the easiest to figure out extra and missing files. Of course, all lists should be sorted.
|
|
# ? May 6, 2022 14:46 |
|
Gothmog1065 posted:The plan is to loop over the lists, check to see if the file exists in the opposite directory, then compare the files themselves (file1=$(${path}/file); file2=$(${path}/file) then if [[ ${file1} != ${file2} ]]; echo messages), echoing out the differences if there are any. I know it's a small snippit of code, but any suggestions are welcome. 1. If you want to generate a list of files that aren't the same between the two directories (and why, whether they only exist in 1, in 2, or if there's deltas) you can abuse rsync(1) to generate that list for you: code:
2. You can also do a 'diff -rU0 "$1" "$2"' to give you a list of differences although with a different format, and not one file per line. 3. If you prefer to do the comparisons manually on each file with cmp, you can iterate over each list but if there's a lot of files in common between the two you'll be performing the comparisons twice. To make that more efficient you want to generate a difference set of the files in the second directory and the first and then iterate over that difference set for the second loop.
|
# ? May 6, 2022 14:49 |
|
Thank you both. I'll definitely look into rsync. I don't expect there to be a glut of files in each directory, I'm talking small <50 files. I'm not really looking to see what the difference are, just that there are differences. While you guys replied, I slapped this (VERY UNTESTED, likely to be some very stupid mistakes) together: code:
code:
code:
Gothmog1065 fucked around with this message at 15:25 on May 6, 2022 |
# ? May 6, 2022 15:23 |
|
Gothmog1065 posted:While you guys replied, I slapped this (VERY UNTESTED, likely to be some very stupid mistakes) together: I didn't evaluate the script too closely, but the one thing I did catch was the use of "continue" in compare(). I'm not sure off hand if that actually works, but even if it does I wouldn't use continue statements far away from the loop. Gothmog1065 posted:And another unrelated question. I don't do a lot of text formatting for the most part, is there a general preference between printf using %s and just calling the variable inside the quotes?
|
# ? May 6, 2022 15:56 |
|
ExcessBLarg! posted:So, when you say you want to "compare the files themselves", you mean you want to figure out if there's differences in the contents of the file, right? The '"${curFile}" == "${compFile}"' comparison just determines if the two strings are the same (which they would be since you've just constructed them as such). To actually compare the files you'll need to use cmp(1). Thanks again! The continue was one of the 'stupid' mistakes I've already fixed. I've been adding \n's in the printf, but if echoes are more typically used in these scenarios, not difficult to switch.
|
# ? May 6, 2022 16:00 |
|
Gothmog1065 posted:And another unrelated question. I don't do a lot of text formatting for the most part, is there a general preference between printf using %s and just calling the variable inside the quotes? The correct solution is just write code that doesn't need text formatting. elseif: printf "WARN: The two items are the same" is enough information in most cases
|
# ? May 7, 2022 02:18 |
|
|
# ? Apr 19, 2024 16:50 |
|
Hadlock posted:The correct solution is just write code that doesn't need text formatting. elseif: printf "WARN: The two items are the same" is enough information in most cases Which two out of these 1000 things, or even just 5 things? No context in output frustrates the hell out of me.
|
# ? May 7, 2022 16:36 |