|
That.... makes a fair bit of sense, actually. Thanks!
|
# ? Jul 30, 2018 17:27 |
|
|
# ? Jun 8, 2024 09:41 |
|
flakeloaf posted:That.... makes a fair bit of sense, actually. Thanks! Yeah, examples drawn from container types are the best examples. They should use container types as the default inheritance/class design teaching tools, the "Animal/Dog/Cat" and "Vehicle/Boat/Car" ones are absolute piss garbage.
|
# ? Jul 30, 2018 17:29 |
|
We have a selection of about 1000 options on our web app that a user can choose and add from a list. I’m thinking it’s too big for a simple select element. What’s a better way to expose a large amount of options to a user? I was thinking of an autosuggest of some sort, but from what I can tell that either requires a specialized API endpoint or a front end framework that we don’t really have.
|
# ? Jul 30, 2018 18:49 |
|
An autocomplete isn't some deep dark magic. You just take the users input and filter your array of selections with what the user has inputted. You have everything you need to complete the task already at hand. You have the data from your selects, and you have javascript. Does the user have some potential idea of what they want to select where they can even start typing something relevant?
|
# ? Jul 30, 2018 18:56 |
Generate the webpage with a <select> with all 1000 elements in it, then on page load replace the <select> with a custom implementation that lets you type-find, just keeping all the options in memory. No need to have an endpoint to query and so on. If the number of elements starts passing 5k then don't put them in a <select> for loading, but in some JSON or similar structure. If you start passing 50k elements, an item search API endpoint might start becoming relevant. ... actually, measure you data size (in bytes) before deciding on a solution. Consider how much data you want to front load on the user. Maybe take a hybrid approach if there are some selections that are significantly more popular, so the popular options are loaded ahead of time, and the less popular are discovered via a search endpoint.
|
|
# ? Jul 30, 2018 19:03 |
|
Dren posted:That's called multiple inheritance and it is fine. It's legal, but reasonable people disagree as to whether multiple inheritance is ever a good idea.
|
# ? Jul 31, 2018 00:18 |
|
ultrafilter posted:It's legal, but reasonable people disagree as to whether multiple inheritance is ever a good idea. In C++ where there are no first-class interfaces multiple inheritance has at least 1 legit use case, allowing a class to implement multiple interfaces.
|
# ? Jul 31, 2018 18:53 |
|
So, I've been tasked with coming up with a bit of a script, and it's a step outside of my comfort level. I've been mulling this over, and this is less about specific code and more about the thought process behind it. The problem: I am going to be given a fairly large file with some simple data (Those in Healthcare and that have dealt with HL7 will recognize this): code:
ADT^AO1 MSH 1 1 (Required, non repeating - technically this is the max number of segments) EVN 1 1 PID 1 1 PD1 1 1 ROL 0 0 (Not required, repeating) NTE 0 1 (Not required, not repeating) PV1 1 1 And so on. Some notes. Order is important, so it will always be (according to the 3 lines above) - MSH, EVN, PID, PD1, ROL NTE, PV1 ... Then there isn't enough data to determine if OBX and DG1 are first, or NTE (or NTE is in the middle), but eventually there will be. If not, I'll have to mark it somehow. My convoluted way of thinking: The server is Linux (CentOS 6) I'll probably be doing this in Python (2.6 is the official install on these particular boxes). I also have access to bash, KSH93, other shell variants, C, C++, probably some others. However he wants it native so some of the other items I have will be out (PowerShell, .Net, etc). While C would run this much faster, I'm more familiar with Python as a general so I will be using it unless there is some huge reason why not to use it. The basic of this would be to load the file, loop over each line, then loop over each item in the list. It's obvious that if one iteration is the same as the previous, it's a repeat. if it's not, it's another segment. Now here's where things get fuzzy for me. Initially I was going to use a list matrix ( array=["MSH",1,1],["EVN",1,1] ), but then I started to realize there were probably going to be issues later on if I had to insert another segment in the middle. I could keep a simple counter of which 'step' I was on, but that may cause other issues (If it inserts in the wrong place, etc) A coworker was talking about using objects and setting a class and using the attributes in the object, but I suspect that would be similar, I'd still have to keep an ordered list to call the class later to return the results. While even typing this out, I realized a few potential issues, the main being making sure we were inserting any new segments in the correct place. So am I even stumbling down a remotely correct path or should I just turn my rear end back around and start from square one?
|
# ? Aug 8, 2018 01:28 |
|
Gothmog1065 posted:While C would run this much faster, I'm more familiar with Python as a general so I will be using it unless there is some huge reason why not to use it. I write C as my bread and butter daily driver language and would absolutely use Python for this. It's taking a bunch of text, the nitty-gritty details are a pita in C and native in Python. Get a CSV library to import it. I don't know what HL7 is but if A01 and A02 are patients, run far away.
|
# ? Aug 8, 2018 01:37 |
|
JawnV6 posted:I don't know what HL7 is but if A01 and A02 are patients, run far away. IANAL, TINLA, but if the data is free of personally identifying information (PII) then it should be safe to manipulate. So I would verify that there's no PII in there before starting work, but assuming there is not I wouldn't worry about it. As for your problem, it sounds broadly speaking like it boils down to 1) determine if tags always show up and if they can show up more than once in a row, and b) determine an ordering of tags. Item 1 is a lot easier: for each row, make a dict of tag to number of times it appears; if it's more than once, the tag is repeatable. For requiredness, keep a set of all tags that have shown up in every row thus far, and iterate over them at the end of each row iteration to make sure they all show up in the tag count dict. Item 2 is harder, and I don't have a good solution for it off the top of my head. I'm inclined to say you should maintain a mapping of tag to the tags you have seen it occur immediately after, and then write some logic to "minimalize" the mapping. Like, if you have this dataset: code:
code:
Hopefully applying that kind of logic will allow you to reduce the mapping until every tag maps to only a single other tag; otherwise your dataset is ambiguous.
|
# ? Aug 8, 2018 01:52 |
|
JawnV6 posted:I write C as my bread and butter daily driver language and would absolutely use Python for this. It's taking a bunch of text, the nitty-gritty details are a pita in C and native in Python. Get a CSV library to import it. No patient data, A01 and A02 are message types (Admit and transfer). We deal with patient data on a daily basis, and the HIPPA police will come kneecap us if we make the slightest wrong (Oh random clinic, you just dumped 40,000 live patients in our test system now we have to clean it up ) TooMuchAbstraction posted:As for your problem, it sounds broadly speaking like it boils down to 1) determine if tags always show up and if they can show up more than once in a row, and b) determine an ordering of tags. Item 1 is a lot easier: for each row, make a dict of tag to number of times it appears; if it's more than once, the tag is repeatable. For requiredness, keep a set of all tags that have shown up in every row thus far, and iterate over them at the end of each row iteration to make sure they all show up in the tag count dict. quote:Item 2 is harder, and I don't have a good solution for it off the top of my head. I'm inclined to say you should maintain a mapping of tag to the tags you have seen it occur immediately after, and then write some logic to "minimalize" the mapping. Like, if you have this dataset: You like poo poo being overly complicated? Because I do. Let's complicate it! code:
Each instance of a letter, if not in a direct sequence ( D D ) will be a separate 'instance' of the tag. So "B" could be a "NTE" (NOTE, get it ) that could follow after various other segments. So I'm probably going to have to tag them as something like MSH1 EVN1 PID1 NTE1 PV11 NTE2 (The first 3 characters being the actual segment, and the last would be a number defining where it goes. As for your mapping, that is a good idea. I'm going to have to mull over that for a bit. I'm already kind of formulating ideas on how to do it, but don't want to get too far ahead of myself. This code I am going to plan out more than I did my last basic script (Which was write by the seat of your pants).
|
# ? Aug 8, 2018 02:19 |
|
Can you get the "second" instance of a tag without having a first instance? And likewise, can you have the third instance without having both the first and second instance, etc. Like, is MSH EVN PID PV1 NTE a valid sequence (having removed the NTE from your example that was before the PV1)? Because if so, you're hosed.
|
# ? Aug 8, 2018 02:24 |
|
TooMuchAbstraction posted:Can you get the "second" instance of a tag without having a first instance? And likewise, can you have the third instance without having both the first and second instance, etc. Like, is MSH EVN PID PV1 NTE a valid sequence (having removed the NTE from your example that was before the PV1)? Because if so, you're hosed. MSH: [] EVN: [MSH] PID: [EVN] NTE: [PID, PV1] PV1: [NTE] At the end I could build from that dictionary in a while loop until it is finished. Since dictionaries in Python are in the order that you create them in, this could conceivably work. Augh just went through that in my brain and you are right. The only way I can see it working is by doing the number tag at the end, but even a cursory glance at doing that way shows there might be other issues.
|
# ? Aug 8, 2018 02:43 |
|
Is there no documentation or anything that would let you know a priori the syntax of each tag? If not, that blows.
|
# ? Aug 8, 2018 02:52 |
|
Do note that you need to use OrderedDict if you want to maintain sequence order in a dictionary in Python (at least, in Python 2; I'm unsure about 3). Otherwise iteration order is implementation-dependent and typically unreliable.
|
# ? Aug 8, 2018 02:53 |
|
TooMuchAbstraction posted:Do note that you need to use OrderedDict if you want to maintain sequence order in a dictionary in Python (at least, in Python 2; I'm unsure about 3). Otherwise iteration order is implementation-dependent and typically unreliable.
|
# ? Aug 8, 2018 06:12 |
|
On CentOS 6 do ‘yum install epel-release’ to get the epel repo. Python 3.4 is in epel. Install it with ‘yum install python34’. You may then run it using the command ‘python3’ instead of ‘python’. 2.6 is a bummer of a python version.
|
# ? Aug 8, 2018 12:22 |
|
Why is the marked value not being assigned to the array? Broken Loose fucked around with this message at 00:34 on Aug 11, 2018 |
# ? Aug 9, 2018 12:48 |
|
Only thing I can think of is that you paused execution before running that line instead of after.
|
# ? Aug 9, 2018 13:02 |
|
TooMuchAbstraction posted:Only thing I can think of is that you paused execution before running that line instead of after. the line was there specifically to break execution for this instance lol the answer was "ghosts" and i'm starting to get annoyed of them
|
# ? Aug 9, 2018 13:08 |
|
Broken Loose posted:the line was there specifically to break execution for this instance lol Don't edit out questions when you figure out the solution. Someone else might benefit from reading about your problem later. Also it makes the thread annoying to read when you only get half of the conversation.
|
# ? Aug 10, 2018 11:02 |
|
Is anyone out there doing integrations with LinkedIn? I'm trying to get some info on their new API and their documentation is either a)confusing or b)over my head. Looking for some clarity.
|
# ? Aug 10, 2018 16:26 |
|
So I have a makefile that builds my unit tests into individual executable files with a single rule. While my current solution works it seems like there should be a way to do it more efficiently. My source code is stored in the src directory, *.h files are stored in the include directory, and *.o files are stored in the obj directory which is a subdirectory of src. Here's what my makefile looks like:code:
code:
code:
|
# ? Aug 13, 2018 13:02 |
|
I decided I wanted to write a program to control Arduinos over the USB/serial connection. I did this in Visual Basic and it works, but I decided that eventually I wanted to use a Linux machine instead even though I don't currently have any Linux PC running right now. And I don't want to bother with running a Windows program on Linux. This program isn't a complicated thing so I'd rather just leave the Microsoft dependency totally. So I started playing with Python (on Win10) recently. With the Visual Basic and Python programs (for Windows) that I've found, to receive text automatically you must register a callback function that starts a new thread to handle reading the incoming serial message. This is the python example I am looking at: https://github.com/dalegambill/PythonTerminal Is this need for {callback+new thread} basically the same on Linux? I'm having a bit of trouble finding Linux PC-specific examples. I only seem to find RPi examples, that appear to be functioning like a real-time OS?... the programs don't seem to require threading: they just have a main program loop, that occasionally checks if there is any bytes in the serial port buffer and then does something if there is----but then I never had a RPi either so I know nothing of that. I know that the RPi runs Linux, but I don't know if there is any major difference between the version of Linux that a PC would have and what the RPi has. Like this page for example: https://www.raspberrypi.org/forums/viewtopic.php?t=106468 These examples for reading the serial port looks more like Arduino code than multi-threading OS code.... It seems radically different? There is no callback or multi-threading at all? Is Linux programming really that much easier? Or is this just some circumstance of the typical RPi environment?
|
# ? Aug 17, 2018 20:29 |
|
I can't remember where I found it, but these are the relevant parts of the properly-working Visual Basic.Net program. Most VB.net pages claiming to say how to automatically monitor the serial port don't really tell you that--they just show how to write a function to check a port for data when the function is called. code:
|
# ? Aug 17, 2018 20:50 |
|
edmund745 posted:serial port, vb, python, linux, windows Using a non-blocking function is one way. Which means it will return a "nothing waiting" type of value instead of waiting indefinitely for a message. Code will flow like: loop starts, you try to read, read returns right away, act if there is a message, repeat the loop. Using a blocking function is the other. Which means it waits/polls until a message comes or a timeout is reached. Which is more like: loop starts, call read, read waits until there is a message or for some pre-defined amount of time to return, handle the message or failure state, repeat the loop. Threading makes sense if you're using, or forced to use, a blocking function that polls for long periods. It allows your program to continue functioning normally while waiting for a message. With a non-blocking function, your program isn't stopping everything to wait for a message. It's just checking and then continuing on. The VB code you're using is likely blocking so it's done in a thread. The python calls might be blocking, but you can check if there are messages waiting and only call read when there are. This stack overflow post covers it in Python. If you do it this way, you can avoid needing a thread. There is also a cross-platform threading library in python and you can do it in a separate thread there too if you want. quote:linux vs windows easier At a deeper level than that, they're fairly similar. Both Linux and Windows treat serial ports like reading and writing to a file. If it's serial over USB, then they're still both similar but USB devices are more complicated to work with. Khorne fucked around with this message at 22:23 on Aug 17, 2018 |
# ? Aug 17, 2018 21:59 |
|
Khorne posted:Conceptually, there are two main ways to poll something. So the reason for putting the serial port check is put in its own thread is because that way it will always get checked at every turn it has. I never tried checking this advice however. It just seemed odd that so many of the "linux" (RPi) examples don't bother with it.
|
# ? Aug 20, 2018 10:33 |
|
edmund745 posted:I had read in the past that if the program has a GUI, then that program's GUI thread may occasionally get skipped in the OS's task list if it does not have focus on the desktop. I doubt that the linux kernel has a way of checking if a program has a UI. In windows, the UI is part of the kernel (well, they took it out somewhat, still heavily embedded within the system) so I can see it happening there. Additionally, windows programs can be marked as console or windows (UI) , so that definitely helps . ELF binaries don't have that flag as far as I'm aware.
|
# ? Aug 20, 2018 13:32 |
|
Volguus posted:I doubt that the linux kernel has a way of checking if a program has a UI. In windows, the UI is part of the kernel (well, they took it out somewhat, still heavily embedded within the system) so I can see it happening there. Additionally, windows programs can be marked as console or windows (UI) , so that definitely helps . ELF binaries don't have that flag as far as I'm aware. They do not, and Linux/Unix at the kernel level doesn't even have a concept of 'the UI' (which sort of UI do you even mean? X11? Wayland? Mir? NeWS if you're feeling oldschool?) That said Windows console programs still technically also have a UI - that console window is being drawn by something, after all. That said, having your UI thread be scheduled a little less frequently if it's in the background...really isn't something to worry or care about? It'll still get run often enough.
|
# ? Aug 21, 2018 12:14 |
|
Yeah, if you're planning your design around a particular thread being run exactly when you want it every time, you're probably going to have a bad time...
|
# ? Aug 21, 2018 12:53 |
Apart from that, Windows does have a "real time" priority level, which does in fact let you pretty much hog a CPU core entirely for yourself, nobody else getting a chance. Depending on the accuracy you need, there's also multimedia timers (which can have down to 1 ms precision, using e.g. a callback function the OS will schedule for you at every timer tick) and several other methods for regular processing. For a serial port I/O task, a high priority thread using blocking I/O is probably more than plenty. Do keep in mind that the serial port is handled on the hardware level by a buffering UART so you don't generally risk losing data by being a bit late.
|
|
# ? Aug 21, 2018 15:29 |
|
Looking for help writing a simple batch file. I'm trying to whip something up that would look at a file name in the same folder as the file and replace a space with a period. I know, it's incredibly stupid to replace a space in the middle of a file name with a period, but that's what I need. The backup process at my work does the reverse, replacing extra periods with spaces, but there's a required naming format for another office we work with that includes the period in the middle. All the files will be about the same, some variation of"2018AFirstname Lastname.msg" and I need to rename them to be "2018AFirstname.Lastname.msg". I feel like it's only a few lines of code but this is well and truly out of my wheelhouse. e: Nevermind, I was able to modify one I found online code:
LawfulWaffle fucked around with this message at 16:00 on Aug 21, 2018 |
# ? Aug 21, 2018 15:43 |
|
1-4A Rename has one of the worst UIs I've ever seen and it's still the best mass-renaming utility ever written for Windows.
|
# ? Aug 21, 2018 17:20 |
|
Oh also, thanks to your help I managed to squeak a 93 in my C++ course, which means I can now sign up for the ten or so other courses that have it as a prerequisite. Wheeeee!
|
# ? Aug 21, 2018 17:24 |
|
I need to analyze/port some Perl code, are there any tools that are designed for this type of thing? In the sense of just documenting the code flow, marking up the source, I don't know exactly. The code is spread out all over the file, function definitions in other files (custom Perl modules), other Perl scripts that get called, etc. Are there tools that exist that will help me make heads and tails of this, or do I just need to basically step through each line and port it line by line?
|
# ? Aug 21, 2018 20:01 |
|
I need to start creating front-end GUIs to my powershell applications. GUI development needs to be super quick though, as I need to spend a majority of my time building more / better powershell tools. Any recommendations on easy, fast, simple powershell GUI software? I'll likely be approved to buy one so it doesn't have to be cheap, I just need to make the right choice because I won't get to buy another if the first sucks.
|
# ? Aug 21, 2018 20:35 |
|
Judge Schnoopy posted:I need to start creating front-end GUIs to my powershell applications. GUI development needs to be super quick though, as I need to spend a majority of my time building more / better powershell tools. I have used this before and it did the trick: https://poshgui.com/ Lots of people recommend using Visual Studio to build GUI's as well, but I haven't tried it myself. If you just need a simple dialog box with a prompt and a couple buttons, this guy might do the trick. That being said, I feel like if you are making a GUI for a powershell script, someone somewhere is missing the point of powershell. The Fool fucked around with this message at 20:47 on Aug 21, 2018 |
# ? Aug 21, 2018 20:42 |
|
This is a bit of a hard question to articulate. Bear with me. It's about licensing. Let's say there's some GPL code which has a section in it which pretty much just involves feeding magic numbers to some hardware to wake it up. The magic numbers were pulled from some Chinese mystery licensed code. Now I come along and need to wake up the hardware using a completely different OS. GPL would make things difficult for me, and I only have interest in the magic dance, not the actual code because it is in C, and I am writing in assembly using a completely different framework. Where do I stand?
|
# ? Aug 24, 2018 06:09 |
|
Sounds like something you'd need to ask an IP lawyer.
|
# ? Aug 24, 2018 06:14 |
|
|
# ? Jun 8, 2024 09:41 |
|
Linear Zoetrope posted:Sounds like something you'd need to ask an IP lawyer. I was expecting an answer like that. I do have a couple of "outs" though. #1. I may not need the init sequence at all. U-Boot did the heavy lifting, but I'm not sure how much got unset a the end. #2. I just found what tries to pass as an official datasheet on the hardware which has information on the init sequence with an annotated flowchart. The datasheet does have register names for the ones that are marked as unknown in various sources I've seen. One thing does stand out that shows me it probably is official. There are a couple of registers not listed. One of which de obfuscates the inner layer of registers, which for reasons I can only speculate conceal the true nature of some well documented hardware.
|
# ? Aug 24, 2018 07:41 |