|
hooah posted:I'm writing some code to break up a large file into smaller files, but I'm having a hard time wrapping my head around the checks. Here's what the large file's format looks like, with specific markers at the end of each line: I think maybe something's being lost in your pseudocode translation. My approach would be to iterate over all the lines, break off the marker, then build up a dict with keys of marker and a list value containing your lines, using setdefault(): code:
This is ripe for use of generator one liners as well. yippee cahier fucked around with this message at 18:16 on Jul 18, 2015 |
# ? Jul 18, 2015 18:13 |
|
|
# ? Jun 5, 2024 04:01 |
|
I had no idea Matlab had dictionaries. Can the dictionary be sorted or accessed in a sorted manner by the first element in the list? That should help immensely, thanks.
|
# ? Jul 18, 2015 18:51 |
hooah posted:I had no idea Matlab had dictionaries. Can the dictionary be sorted or accessed in a sorted manner by the first element in the list? That should help immensely, thanks. I'm pretty sure sund's example is Python, not Matlab. You never specified a language in your original question, but your pseudocode looks suspiciously close to actual Python.
|
|
# ? Jul 18, 2015 19:46 |
|
Oh, whoops. I think I'd typed Matlab at one point and then deleted it. I just got done being a Python TA, so it must be leaking. I've already done what I have in Matlab, so continuing that would be nice, but not necessary. I just realized that a dictionary probably won't work, since the markers for b1 and b2 aren't actually different yet they need to be written to different files (that was poor explanation on my part). hooah fucked around with this message at 00:38 on Jul 19, 2015 |
# ? Jul 18, 2015 20:03 |
|
Haha, sorry, I assumed pseudocode replacement for more complicated operations and Python. Matlab? Can't help you there.
|
# ? Jul 19, 2015 04:43 |
|
Matlab actually did add a dictionary type at some point. It's somewhat limited but supports all of the basic operations.
|
# ? Jul 19, 2015 04:47 |
|
Is there any sensible way to approach working with a library that is downright insane? The current project I'm working on required working with an API (with a Java wrapper library to 'ease' development). The API itself is quirky in its own right, but the library is doing some rather odd things in general. There are at least 5 ways for this library to fail with a NullPointerException thrown somewhere deep inside the library. Other times, it will return an empty response object. As a result, I'm somewhat lost as to how to tackle this - the approach I'm currently taking is to have a general-purpose error handler to catch the NPE's and malformed objects and identify the possible sources of error (e.g. bad credentials, wrong IP, etc.) and point to the logs in order to locate the actual cause of failure, followed by use-case-specific error handling, but "Just read the drat logs" seems like a bit of a cop-out.
|
# ? Jul 20, 2015 15:32 |
|
I'm going to start writing my first project with a GUI. I'll be writing in Java, but how should I implement the frontend? Is Swing something that people actually use, or should I go with something else, like javascript instead? Also, can anyone recommend a guide on what's good practice when programming a GUI. I know the basic stuff like keeping the GUI separate from the backend logic, but I'm sure there's tons of ways of implementing it that are frowned upon.
|
# ? Jul 20, 2015 17:46 |
|
Dumlefudge posted:Is there any sensible way to approach working with a library that is downright insane? The current project I'm working on required working with an API (with a Java wrapper library to 'ease' development). The API itself is quirky in its own right, but the library is doing some rather odd things in general. There are at least 5 ways for this library to fail with a NullPointerException thrown somewhere deep inside the library. Other times, it will return an empty response object. What I've done in the past is write a wrapper with a sane API for the insane library. The wrapper handles all the bullshit the insane library does. It can retry operations or whatever it is that needs to be done. Then forget the insane library exists.
|
# ? Jul 20, 2015 17:50 |
|
Kuule hain nussivan posted:I'm going to start writing my first project with a GUI. I'll be writing in Java, but how should I implement the frontend? Is Swing something that people actually use, or should I go with something else, like javascript instead? Swing is what's usually used to create a GUI for a java application running on your system, yes. There are a few others (AWT (deprecated in favor of Swing), SWT, JavaFX) but Swing is the most common.
|
# ? Jul 20, 2015 17:54 |
|
Kuule hain nussivan posted:I'm going to start writing my first project with a GUI. I'll be writing in Java, but how should I implement the frontend? Is Swing something that people actually use, or should I go with something else, like javascript instead? If you don't mind targeting Java 8, I'd take a close look at JavaFX and make sure that it's capabilities meet your needs out of the box. If it does, I might try going that route as it's fairly modern conceptually. If you're looking to remain compatible with older versions of Java, or make use of the existing third-party libraries or code, I might stick with Swing given its overall popularity.
|
# ? Jul 20, 2015 18:24 |
|
Worth clarifying: AWT is Java's graphics foundation. Swing and anything else that doesn't punt to JNI calls is built on top of AWT. If you're using Swing, you will see AWT classes from time to time. AWT also encompasses Java2D, a quite serviceable canvas-style drawing API which is hardware-accelerated on many platforms. If you need to do something like custom graphing or a 2d game there's a good chance it can do what you need out of the box.
|
# ? Jul 21, 2015 17:32 |
|
.
goodness fucked around with this message at 06:42 on Dec 11, 2018 |
# ? Jul 22, 2015 01:44 |
|
goodness posted:I am looking to learn some code and completely new to all this. It would primarily just be used for small programs/web design. A language that would be useful to help program automated garden/aquarium systems, maybe a little robotics, create a web page to sell a product/show info, pair with electrical work to run a self-sufficient power grid, etc. Any suggestions where to start? I think Python is many peoples' default suggested first language these days. It's free, ubiquitous, and widely used and supported. It should be able to handle any of the things you mention here, though you might want/need to add in a web framework (like Django) to do web programming.
|
# ? Jul 22, 2015 14:37 |
|
Here's an easy question to start off the day. I'm pretty new to JQuery, and fumbling around with the selector. I'm not getting exactly what I want from a selection, but I'm not sure how to inspect the results of my query to see which elements are selected and which are not. I've been using the alert() function to display the size of the returned collection, and I can also use toArray() and then print out the join() of the resulting array, but this only shows me that it's an array of HTML Input Elements, not which elements. I tried using the name property of each object, but that doesn't return anything. What's the best way to see some identifying information on the elements being returned? I've been Googling around, getting close to the answer, but I just want to move on with my life at this point.
|
# ? Jul 22, 2015 14:43 |
Peristalsis posted:Here's an easy question to start off the day. Use the debugger and interactive console in your browser. IIRC both Firefox, Chrome and IE activate their debugging tools with F12. You can type Javascript directly into the console and have it evaluated line by line, then inspect the results. It all runs in the context of the page you opened the debugger from, so you can work on the live site like that. Since SA uses jQuery too, I can open the debugger right on this page, choose the Console tab, and enter: $("span") I then get an output similar to this: Object { 0: <span.nav_new>, 1: <span.mainbodytextlarge>, 2: <span.smalltext>, 3: <span.smalltext>, 4: <span>, 5: <span>, 6: <span>, 7: <span>, 8: <span>, 9: <span>, 25 more… } Except that it's interactive, I can point to the elements listed and have them highlited on the page, and I can click them to inspect them further. And yes you can also use variables from the console.
|
|
# ? Jul 22, 2015 14:59 |
|
nielsm posted:Use the debugger and interactive console in your browser. IIRC both Firefox, Chrome and IE activate their debugging tools with F12. Cool, thanks. Is there a property of the collected elements I could use to print their names/id, if I did want to throw them into a popup?
|
# ? Jul 22, 2015 15:03 |
|
Peristalsis posted:Cool, thanks. Selectors use the array indexing syntax to look up individual raw elements JavaScript code:
JavaScript code:
To iterate over the items in a selector, you can treat it like an array and use a regular for loop because selectors have a length property that tells you how many items they matched. JavaScript code:
JavaScript code:
|
# ? Jul 22, 2015 16:05 |
|
I am having a problem that involves scoping and Javascript and I'm having some issues figuring it out. code:
|
# ? Jul 22, 2015 19:00 |
|
JavaScript is weird. Use this.ssidHandler.bind(this) when you can the wizard.
|
# ? Jul 22, 2015 20:12 |
|
Suspicious Dish posted:JavaScript is weird. Use this.ssidHandler.bind(this) when you can the wizard. Holy crap you're the best. I was playing around with .apply but apparently not doing that right either. I didn't realize .bind was a thing.
|
# ? Jul 22, 2015 20:33 |
|
Where does one start if they want to get into generating 2d/3d graphics and they are coming from a background of building console apps / SAAS stuff in Java/Python?
|
# ? Jul 23, 2015 04:30 |
|
BlackMK4 posted:Where does one start if they want to get into generating 2d/3d graphics and they are coming from a background of building console apps / SAAS stuff in Java/Python? gaming? i'd try unity. or unreal engine. both are basically free (until you start making money with them)
|
# ? Jul 23, 2015 05:34 |
|
BlackMK4 posted:Where does one start if they want to get into generating 2d/3d graphics and they are coming from a background of building console apps / SAAS stuff in Java/Python? What does "generating 2d / 3d graphics" mean? Are you looking to do UI programming, image processing, offline rendering, real-time gaming, or what?
|
# ? Jul 23, 2015 07:43 |
|
Any thoughts on how to cleanly handle support for multiple versions of records in a web application? My new job gets government mandated changes annually and the code is a loving mess. "Info1", " Info2", "Info3" are all almost identical forms except each has a few different controls based on the record being accessed. And almost every page in the app has two or three variants. It's not always 1 form per record version, one form can handle more than one version in some cases. But it's only going to get bigger and uglier. The code just has a poo poo ton of IF statements comparing string literals for the different versions in almost every link to another page, determining which version of a page to send the user to. "V1.10.1", " V1.01A", "V1.2", " V1.3" in order of oldest to newest. I'd love to, at the very least, replace it allll with an enum instead but who has the time for that much of a change. That'd be easier to compare and add to going forward, I think. Luckily String.Compare (string, string) seems to work for our needs, so I'm going back and replacing every strVer == "xyz" with that, but goddamn it's messy. There's got to be a better way. Any ideas, or suggestions for what to read about? ASP / VB.NET fyi Sab669 fucked around with this message at 13:37 on Jul 23, 2015 |
# ? Jul 23, 2015 13:35 |
|
Suspicious Dish posted:What does "generating 2d / 3d graphics" mean? Are you looking to do UI programming, image processing, offline rendering, real-time gaming, or what? Image processing - something like generating a voronoi diagram on a jpg with points. Simple 2d pong. The usual raytraced scenes.
|
# ? Jul 23, 2015 16:23 |
|
So I am trying to set up an NFS on my linux box (running fedora) so I can connect to it from my MAC. The fedora is a virtual machine, on a bridge connection. I can connect and ssh into my fedora box no problem. The user I am using on my fedora box that does everything has a uid and gid of 1001. My mac user has a uid of 101, and gid of 20. This is in my /etc/exports: "/home *(rw,insecure,sync,no_root_squash,no_all_squash,anonuid=1001,anongid=1001)" I then restart the nfs-server.service, but my mac just won't connect to it. When I connect to my nfs server I use the mac finder GUI and enter "nfs://ems@10.211.55.9/home" (ems is the user on the fedora system). When I do this, is my client going to connect with the uid and gid of ems, or will it connect with the uid and gid of my mac's user? Regardless of that question, this does not work and I cannot connect to my fedora box, any help greatly appreciated.
|
# ? Jul 23, 2015 18:18 |
|
BlackMK4 posted:Image processing - something like generating a voronoi diagram on a jpg with points. Simple 2d pong. The usual raytraced scenes. Pick one. Those are all entirely different things with different codebases, strategies, techniques and things to learn.
|
# ? Jul 23, 2015 18:22 |
|
Suspicious Dish posted:Pick one. Those are all entirely different things with different codebases, strategies, techniques and things to learn. Okay, where is the entry to the voronoi diagram from an image? The latter two seem to be gated by OpenGL (as one method).
|
# ? Jul 23, 2015 19:05 |
|
Knifegrab posted:So I am trying to set up an NFS on my linux box (running fedora) so I can connect to it from my MAC. The fedora is a virtual machine, on a bridge connection. I can connect and ssh into my fedora box no problem. Make sure your virtual machine gets its own IP address on the lan , also make sure that the fedora firewall is turned off. TheresaJayne fucked around with this message at 05:52 on Jul 24, 2015 |
# ? Jul 24, 2015 05:42 |
|
BlackMK4 posted:Okay, where is the entry to the voronoi diagram from an image? The latter two seem to be gated by OpenGL (as one method). What? A voronoi diagram is generated from a set of points -- it graphs the entire 2D plane with the other points closest to that point. I don't know what generating it from an image would mean.
|
# ? Jul 24, 2015 05:51 |
|
Suspicious Dish posted:What? A voronoi diagram is generated from a set of points -- it graphs the entire 2D plane with the other points closest to that point. I don't know what generating it from an image would mean. Using the pixels of an image as the point set, and using color difference as the distance metric.
|
# ? Jul 24, 2015 06:00 |
|
BlackMK4 posted:Where does one start if they want to get into generating 2d/3d graphics and they are coming from a background of building console apps / SAAS stuff in Java/Python? https://www.processing.org/
|
# ? Jul 24, 2015 06:43 |
|
Sinestro posted:Using the pixels of an image as the point set, and using color difference as the distance metric. How do you embed that into the 2D plane though? I'm not speaking rhetorically, I've never heard of this.
|
# ? Jul 24, 2015 07:04 |
|
This is about writing GUIs with Unity, but I think it is a more general problem not worth putting up in the game programming thread. I'm wondering what are some things I should think about doing with this since the GUI system there is just so primitive. Any GUI I'm implementing just has one method that Unity calls, basically in a poll loop, with one event at a time. Common events I worry about are painting the GUI, keyboard stuff, and mouse stuff. If you just go through it procedurally without any design considerations, you wind up with a bunch of conditionals on all those event types to do all the random bits you want to in the custom GUI. The method that Unity calls can then hit quadruple digits of lines of code without paying too much attention. I figured out last night that wasn't good enough at least for mouse stuff. If had an operation where I wanted to extend a wall preview I intended to place when dragging the mouse across an area. So I was checking when dragging ended and a MouseUp event showed up. However, a repaint could happen in the middle and make things a mess. I ended up creating a little mouse helper object that looked at the event each loop and set a bunch of variables related to the mouse being down, up, dragging, and what it was doing previously. This took care of having a bunch of annoying variables flipping around inside the giant method call. I'm assuming that's another wheel reinvented, so I'm wondering if there's a nice compendium of lower-level GUI patterns that tend to crop up in this kind of thing. Normally I'm working with higher-level GUI frameworks and never see this layer. I don't mean doing stuff like MVC; that's IMO at the higher level. I'm talking about like I had to worry about here with tracking mouse clicks and that kind of crap. Other things like detecting dirty regions and reducing draw calls or whatever.
|
# ? Jul 24, 2015 19:04 |
|
Very cool, thank you
|
# ? Jul 24, 2015 21:33 |
|
GrumpyDoctor posted:How do you embed that into the 2D plane though? I'm not speaking rhetorically, I've never heard of this. This Stack Overflow answer does a good job of describing a good algorithm for this.
|
# ? Jul 24, 2015 21:49 |
|
Sinestro posted:This Stack Overflow answer does a good job of describing a good algorithm for this. This (finding Voronoi diagrams that approximate arbitrary images) is neat as hell, but neither part of this Sinestro posted:Using the pixels of an image as the point set, and using color difference as the distance metric. is involved in any of these solutions.
|
# ? Jul 25, 2015 00:40 |
|
It's almost like I wrote the first one on my phone not really thinking about it and just saying something that sounded right-ish, but then get home and responded with actual research and thought.
Sinestro fucked around with this message at 02:47 on Jul 25, 2015 |
# ? Jul 25, 2015 02:33 |
|
|
# ? Jun 5, 2024 04:01 |
|
I'm making a website and I want to use websockets, but I can't really figure out how much they'll get blocked on the client side. Web searches just seem to indicate that it is a problem, but I can't figure out the extent of it. And if they are blocked, how might I account for that? The last time I made a website beyond simple text and headers, full duplex for the web didn't exist afaik, so these are new waters for me.
|
# ? Jul 28, 2015 00:54 |