|
Pollyanna posted:This is a dumb question for me to ask so late into my career Jfc this is a dumb question. Slow the gently caress down and learn something instead of trying to check boxes. You're on your second job in the software industry. You have plenty of time.
|
# ? Oct 2, 2016 23:37 |
|
|
# ? Jun 3, 2024 22:25 |
|
TooMuchAbstraction posted:If you ever find yourself writing a "recognize an email address" function for serious applications, you are doing it wrong. Most people doing that preclude my email address from existance. i have a - in the email rather than a _ and it keeps getting denied as not being a valid email
|
# ? Oct 3, 2016 11:09 |
|
TheresaJayne posted:Most people doing that preclude my email address from existance. This right here is why email address validation/recognition gets so much hate: 99% of the time it's being used by idiots to "validate" emails being entered into a website. Where "validate" means "reject all sorts of valid emails because they have weird, alien characters like '.' or '-' or '+' in them". If you're really lucky you get a site that uses different validation code for different parts of the site! So it'll let you register with and email address that you can't log in with, or you can register and log in but the page for unsubscribing from their lovely mailing list doesn't work.
|
# ? Oct 3, 2016 13:46 |
|
I thought special marks like . and _ were ignored in emails?
|
# ? Oct 3, 2016 13:57 |
Pollyanna posted:I thought special marks like . and _ were ignored in emails? Depends entirely on the server. Google ignores them, but nothing about Internet email requires that they have meaning or are ignored.
|
|
# ? Oct 3, 2016 14:27 |
|
Blinkz0rz posted:Jfc this is a dumb question. Slow the gently caress down and learn something instead of trying to check boxes. You're on your second job in the software industry. You have plenty of time. Seriously. I'm 15 years into my career. I work with people that have been writing software for 30 or 40 years. We're all still learning new things. Relax.
|
# ? Oct 3, 2016 20:15 |
|
ToxicFrog posted:This right here is why email address validation/recognition gets so much hate: 99% of the time it's being used by idiots to "validate" emails being entered into a website. Where "validate" means "reject all sorts of valid emails because they have weird, alien characters like '.' or '-' or '+' in them".
|
# ? Oct 3, 2016 23:14 |
|
Another Django question here. I'm kind of new to this all overall, but I would suspect that there's something that can vomit a model's details in a view without me having to do much of anything--notably create an HTML template. Is this a thing? I'm working on a rather dry site where I have a lot of stuff like that. At best, I might just want to define order and create groupings. I saw django-tables2 to generate the master table for all of this stuff, and that has made me very happy. Is there something similar for vomiting a specific instance of a model?
|
# ? Oct 4, 2016 02:36 |
|
Pollyanna posted:I thought special marks like . and _ were ignored in emails? nielsm posted:Depends entirely on the server. Google ignores them, but nothing about Internet email requires that they have meaning or are ignored. The "local" part of an email address is more or less just like, say, your Apartment Number. There are some rules about how things should be named, but in practice different "complexes" (domains) structure them differently. Depending on the server a.b.c may or may not be equivalent to ABC, A.b.c, a.bc, or any other number of things. Email is more or less agnostic as to how the domain handles the resolution of the local part just so long as it conforms to a subset of the overall standard (though Google does allow one invalid construction due to their handling: two periods in a row outside of quotation marks, which are not technically allowed, but this is because double dots are ignored completely so theoretically an email validator could still be strict about this since if you're missing a period Google will still send it to the right place). For the same reason, there are some edge cases in a theoretical email validator you could safely exclude. For instance, parenthesized comments are allowed at the beginning and end of both the local and domain parts (that is (a)me(blah)@(comment)you.com(ex) is the same as me@you.com), but by spec are ignored completely (which is why they're called comments). The issue, of course, comes in what happens if a theoretical email service allows invalid constructs without ignoring them. Then you're in a spot where you may reject someone's "valid" email because the domain they're registered at is poorly implemented. Linear Zoetrope fucked around with this message at 02:42 on Oct 4, 2016 |
# ? Oct 4, 2016 02:38 |
|
Rocko Bonaparte posted:Another Django question here. I'm kind of new to this all overall, but I would suspect that there's something that can vomit a model's details in a view without me having to do much of anything--notably create an HTML template. Is this a thing? I'm working on a rather dry site where I have a lot of stuff like that. At best, I might just want to define order and create groupings. Is there some reason the admin pages don't do what you want? If I recall correctly, they should be able to basically let you browse your database via a web interface.
|
# ? Oct 4, 2016 02:44 |
|
TooMuchAbstraction posted:Is there some reason the admin pages don't do what you want? If I recall correctly, they should be able to basically let you browse your database via a web interface. I pretty much want a read-only presentation with that kind of power, with the admin page available under the hood.
|
# ? Oct 4, 2016 03:22 |
|
Rocko Bonaparte posted:I pretty much want a read-only presentation with that kind of power, with the admin page available under the hood. Pretty sure the admin page is written in Django, so you could just go diving into the internals to find what renders that, and make a copy with all the write tools ripped out. Otherwise, you're looking at reflection, which is super easy in Python. Analyze __dict__ for the model instances, print key names and corresponding values. Only issue is that the model probably has a bunch of "hidden" keys (from parent classes) that you don't care about. But there may be a array or set or something that enumerates all the keys that correspond to model attributes; it's been awhile since I dug into this stuff.
|
# ? Oct 4, 2016 04:24 |
|
Rocko Bonaparte posted:Another Django question here. I'm kind of new to this all overall, but I would suspect that there's something that can vomit a model's details in a view without me having to do much of anything--notably create an HTML template. Is this a thing? I'm working on a rather dry site where I have a lot of stuff like that. At best, I might just want to define order and create groupings. There's a Django thread.
|
# ? Oct 4, 2016 15:45 |
|
Is there a good simple way to track who is doing what on the servers so people don't knock me off my RDP session or I don't ask IT to physically reboot something someone is working on? I assume slack channel is the default but slack is effectively banned where I work. Mixed network win/mac/linux, mostly VM but some physical machines.
|
# ? Oct 4, 2016 19:53 |
|
mr_package posted:Is there a good simple way to track who is doing what on the servers so people don't knock me off my RDP session or I don't ask IT to physically reboot something someone is working on? I assume slack channel is the default but slack is effectively banned where I work. Gold standard for simplicity is just using the OS specific tools on the server to find out who is logged in etc, correct? Ex. tasklist /fi "SessionName ne Services". Edit: Do IT departments at places really just reboot poo poo without warning, assuming no one was using it for anything important? Fergus Mac Roich fucked around with this message at 21:40 on Oct 4, 2016 |
# ? Oct 4, 2016 21:38 |
|
Fergus Mac Roich posted:Edit: Do IT departments at places really just reboot poo poo without warning, assuming no one was using it for anything important? Go read the "poo poo That Pisses You Off" thread in SH/SC. People do pretty much every possible stupid thing. Is there such a thing as too much commenting, assuming you're not trying to do it? For example, in a game project, I've got loops that create a grid, then loops that create pathfinding triggers, and then a statement that creates the player. I've got comments for each, basically saying the same thing that I just said. It goes like this: C# code:
|
# ? Oct 4, 2016 22:04 |
|
22 Eargesplitten posted:Go read the "poo poo That Pisses You Off" thread in SH/SC. People do pretty much every possible stupid thing. Try not to comment things that SHOULD be obvious to a competent developer. Doing //declare X is useless. Comments should be more focused around WHY you are doing something, and/or explaining non-obvious code. In the above case, I don't think it's bad, though I would also consider moving the commented sections to their own CreateEnemies() and CreateAsteroids() methods.
|
# ? Oct 4, 2016 22:21 |
|
22 Eargesplitten posted:Is there such a thing as too much commenting, assuming you're not trying to do it? For example, in a game project, I've got loops that create a grid, then loops that create pathfinding triggers, and then a statement that creates the player. I've got comments for each, basically saying the same thing that I just said. It goes like this: Yes, there is such a thing as too much commenting, but no, you're not guilty of it here. This would be too much commenting: C# code:
Peristalsis fucked around with this message at 23:58 on Oct 4, 2016 |
# ? Oct 4, 2016 22:21 |
|
Looks about right to me. Descriptive, could skim them to figure out the flow without having to read code, not so verbose that future maintainers won't bother updating them. The one thing that sticks out is the float constants. There's 21, 21.0, 20.5, 10.5, 1.5 and it's not clear from this section where those come from or why some stop short. If we doubled the board size, what would have to change? How would I know that? Think of comments like the mental context you have in RAM that'll get lost when the next dev pulls from disk, comments let you save the context off in an easily restored way. If there's any choice you made or reasonable substitution that wouldn't work, comments can help others be aware & avoid those pitfalls.
|
# ? Oct 4, 2016 22:31 |
|
22 Eargesplitten posted:Is there such a thing as too much commenting, assuming you're not trying to do it? For example, in a game project, I've got loops that create a grid, then loops that create pathfinding triggers, and then a statement that creates the player. I've got comments for each, basically saying the same thing that I just said. It goes like this: I'm more for the literate coding. For me that's 3 functions called: createAsteroidFields() createEnemies() createPlayer() Then there's no need for the comments.
|
# ? Oct 4, 2016 22:50 |
|
That's actually a good point about the methods. I'm going to do that. Probably create minX, minY, maxX, and maxY variables as well. That's what the foo.5 numbers are for. The board goes from x = 0 to x = 21 and y = 0 and y -21, but the objects are centered on the .5s. Maybe I should do it differently, but I wanted to have a corner at the origin. Maybe I should do y from 0 to 21, I'll think about that.
|
# ? Oct 4, 2016 23:20 |
|
JawnV6 posted:Looks about right to me. Descriptive, could skim them to figure out the flow without having to read code, not so verbose that future maintainers won't bother updating them. The one thing that sticks out is the float constants. There's 21, 21.0, 20.5, 10.5, 1.5 and it's not clear from this section where those come from or why some stop short. If we doubled the board size, what would have to change? How would I know that? Further, code should be as self-descriptive as possible, which means that constants should at least be given something like #define START_X_POS 1.5 So that your reference to the number also demonstrates its purpose.
|
# ? Oct 5, 2016 01:23 |
|
Another way to think of it is that the code should be describing as much of the 'what' as possible. CreatePlayer, CreateAsteroids, START_X_POS, etc. That leaves comments for a requirement statement at the top of the file, ambiguous 'whats', 'whys', describing alternatives that seem sensible but won't work for reasons.
|
# ? Oct 5, 2016 03:17 |
|
Stinky_Pete posted:Further, code should be as self-descriptive as possible, which means that constants should at least be given something like #define TEN 10
|
# ? Oct 5, 2016 06:01 |
|
typedef enum YESNO {NO,YES} YESNO; the syntax is a little different, but this is real code running on real airplanes right now Stinky_Pete fucked around with this message at 17:10 on Oct 5, 2016 |
# ? Oct 5, 2016 17:08 |
|
Stinky_Pete posted:typedef enum YESNO {NO,YES} YESNO; That line of code never runs.
|
# ? Oct 5, 2016 17:23 |
|
Fine, real code compiled for real airplanes
|
# ? Oct 5, 2016 17:30 |
|
Okay, I'm working with Visual Basic. What I need to know is how to access the data in a user entered list that can be of any length and how I can access data that is between a certain number range i.e. if I want to average a group of numbers between 10 and 25, how do I select only those numbers and add them. In addition, how do I select the highest and lowest numbers, for example If I need to calculate the range.
|
# ? Oct 5, 2016 18:52 |
Mycroft Holmes posted:Okay, I'm working with Visual Basic. What I need to know is how to access the data in a user entered list that can be of any length and how I can access data that is between a certain number range i.e. if I want to average a group of numbers between 10 and 25, how do I select only those numbers and add them. In addition, how do I select the highest and lowest numbers, for example If I need to calculate the range. Is this Visual Basic .NET, Visual Basic 6 ("classic" VB), or Visual Basic for Applications (macros in Word, Excel, Access), or perhaps even VBScript? They're all distinct but related languages, VB.NET probably being the most different beast, but also the most desirable for modern/new development. The user data, are they in a file, in a text box, added to a list box, or how are they stored right now? In general what you will need is to make a loop that can iterate over the data one item at a time. When your data is in a list with N items, each item will have an index typically numbered from 0 to N-1. You can then make a loop that repeats the same block of code for all index values from a starting point to an ending point (e.g. from index 9 to 24) and calculate the sum, minimum and maximum.
|
|
# ? Oct 5, 2016 19:52 |
|
nielsm posted:Is this Visual Basic .NET, Visual Basic 6 ("classic" VB), or Visual Basic for Applications (macros in Word, Excel, Access), or perhaps even VBScript? It's Visual Basic 2016, the newest one. The data has been added to a list box by the user. The data can be in any order so the loop you have mentioned won't work because the values of the data do not correlate to their index number.
|
# ? Oct 5, 2016 20:47 |
Mycroft Holmes posted:It's Visual Basic 2016, the newest one. The data has been added to a list box by the user. The data can be in any order so the loop you have mentioned won't work because the values of the data do not correlate to their index number. So each item has an "entry number" and a value, but the items may not be in entry number order on the list? For that case you would most easily make a loop over the entire contents of the list, and ignore all items with entry numbers outside the relevant range. The items would be processed in the arbitrary order they are in on the list, but for the processing you described the order should be irrelevant.
|
|
# ? Oct 5, 2016 21:06 |
|
nielsm posted:So each item has an "entry number" and a value, but the items may not be in entry number order on the list? Ok, so I'm having trouble figuring out how to set up the function to do that. I need to find the number of students with As in the list. An A is between 100 and 90. The code I have so far is: 'number of students with As and percentages Function StudentNumberA(ByRef dblAStudents, ByRef dblAPercent) As Double Dim I As Double Dim dblCount As Double For I = 0 To lstGrades.Items.Count - 1 If >= 90 And <= 100 Then dblCount += 1 End If Next Return (dblAStudents = dblCount)(dblAPercent = (dblCount / lstGrades.Items.Count)) End Function My question is, what do I put as the variable that corresponds to the current item on the list, given that it will change with every loop? Also, how do I find the lowest and highest numbers? Mycroft Holmes fucked around with this message at 00:39 on Oct 6, 2016 |
# ? Oct 6, 2016 00:14 |
|
Stinky_Pete posted:Further, code should be as self-descriptive as possible, which means that constants should at least be given something like Why exactly are you using the preprocessor instead of "const double START_X_POS{1.5};"
|
# ? Oct 6, 2016 03:24 |
Mycroft Holmes posted:Ok, so I'm having trouble figuring out how to set up the function to do that. I need to find the number of students with As in the list. An A is between 100 and 90. The code I have so far is: Tip first: Put your code in code tags, then it retains formatting. You can also add a language name to the code tag to get syntax highlighting. Your I variable should be Integer rather than Double, since it's an index. You don't have non-whole-number indices, it's better to use an integer when you don't specifically need floating point (decimal) arithmetic. You can get the value of an individual item in the list with the Items property: Visual Basic .NET code:
|
|
# ? Oct 6, 2016 07:27 |
|
Ok, I did some more coding, but when I run it, the output is zero.code:
|
# ? Oct 6, 2016 14:56 |
You have to consider what you're actually returning and how. In VB, the = operator is only used for equals comparison, not assignment. Using = for assignment is a statement form that just looks deceptively like a comparison expression. What you have in your Return statement is a series of comparisons chained with logical And, not assignments. From how your function is declared, I assume you mean to have it return four values by taking in references to variables to fill. You have to assign those four as separate statements. After that, you can really change the Function to be a Sub instead, because you don't actually produce a "return" value, you rather modify four passed-in variables.
|
|
# ? Oct 6, 2016 15:26 |
|
You're also just checking the first student in the collection over (I assume VB automatically initializes things, anyway) and over instead of incrementing. intIndex should be your loop control variable. And prefixing every variable with its type makes me retch but that's just me.
|
# ? Oct 6, 2016 16:01 |
|
Nevermind, fixed it.
Mycroft Holmes fucked around with this message at 17:53 on Oct 6, 2016 |
# ? Oct 6, 2016 17:50 |
|
fritz posted:Why exactly are you using the preprocessor instead of "const double START_X_POS{1.5};" That was my "at least."
|
# ? Oct 6, 2016 19:30 |
|
|
# ? Jun 3, 2024 22:25 |
|
Not exactly a programming question but figured this might be the best place to ask. We sell a Linux 'applicance'. This device has an embedded web server for configuration. We'd like to support HTTPS out of the box but I'm not sure the best way ( if even possible ) to ship with a usable certificate. Options I've come up with
|
# ? Oct 7, 2016 17:20 |