Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Volguus
Mar 3, 2009

The Dark Wind posted:

Recursion is cool. I haven't seen it in anything at my job yet, but I remember during my bootcamp I ended up using it for a few things, such as rendering nested comments. Also if you believe everyone who says functional programming is the future, then in functional languages (like Elixir, for example), you'll often see tons of recursion as alternatives to loops.

Recursion is not cool. It is most often than not (depending on your compiler or JIT) a waste of cpu cycles and stack space. Usually (not always) an iterative algorithm can solve the same problem faster and cheaper. However, recursion is trivial to reason about, nice to look at and read. And sometimes, the iterative algorithm does not provide such gains to justify for the increase in complexity. Use recursion with care.

Adbot
ADBOT LOVES YOU

Volguus
Mar 3, 2009

Dominoes posted:

I dunno; 'git init', 'git add .', 'git clone https://github.com/...' , and 'git commit -am "updated things"' are the only commands I'm familiar with.

add git pull to the list and you're a git master. nothing to worry about anymore.

Volguus
Mar 3, 2009

Grump posted:

okay cool. Looks like this was the problem:

"Error:SSL certificate problem: self signed certificate in certificate chain"

I went ahead and added, which fixed it:

PHP code:
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
Is there any way I can configure my local server to not do an SSL check at all?

Didn't you already do that by setting the SSL verify to 0?

Volguus
Mar 3, 2009

Those people were selling their bots. I think the rules are quite more relaxed if you use it just for yourself from a legal point of view. But I wouldn't try it though.

Volguus
Mar 3, 2009
Google's Protobuf, how I love thee.

Let's assume that I have a message like this (proto3):
code:
 message Foo {
 int32 a=1;
string b=2;
}
Life is good, everything works out nicely, and the API is being used by a few developers. Now, I would like to change the API (and the messages) to accommodate future expansions. What I want right now is something like this:
code:
message Bar {
  repeated Foo foos=1;
  //and later one will be
 repeated OtherFoos otherFoos=2;
....
}
Can I, somehow, determine at runtime if I am being sent a Foo directly or a Bar that contains Foos? According to everything that I have read out there it's not possible. What happens right now is that I successfully read a Bar, that simply doesn't have any Foos in it, and then I know that I can try to read a Foo.
Is there a way to validate the type of message that's being sent over the wire? Does protobuf have any kind of metadata around the messages that it sends and receives? How does it protect against the client lying, something like: "the repeated message will contain 100 Foos, but I'm only sending 10"?

Also, how come that the C++ API does not have "ParseDelimited..." and "WriteDelimited...". They can be added, but is quite a hassle.

Volguus
Mar 3, 2009

TooMuchAbstraction posted:

Then your code would get handed a binary blob, you would tell the library "here, try to turn this blob into a Bar", and it would either say "here you go" or "nope, that's not a Bar", and in the latter case you return an error to the client.

That's exactly what I expected as well. But the protobuf library, when told to "make a Bar out of this blob of bytes" it made a Bar even if it had a Foo. It did fail when I sent a blob of bytes all 0x01, or completely random. That was invalid blob. But if I sent a Foo or even half a Foo (I just cut the blob of bytes in half) it worked . And then I had to step in and say: In order for Bar to be valid it has to have at least one Foo.

TooMuchAbstraction posted:

So far as I'm aware, you can't have a single method that takes either a Foo or a Bar. Certainly even if it's possible I don't think it's a thing you should do. There should be one correct way to use your library.

I am not using gRPC at the moment, it is just simply reading the stream of bytes from the network. I agree that there should only be one correct way to use it, I just want to change that way (deprecate the old way) and not inconvenience the 3 people that are still using the old way, not for a while at least. I should have had the Bar message from the start, but is too late now.

Volguus
Mar 3, 2009

nielsm posted:

What if you add an int32 version field to the start of Bar, would it then still eat a single Foo buffer?

If I do that then it fails as expected. But, looking at the exception thrown, it fails when it reads the string of the Foo, since it is no longer a valid UTF8 starting from that byte. Hmm, it seems that the library (at least the Java one) it does its best to provide an object from whatever it has been given. If two messages are close enough in structure, on the receiving end you may not be any wiser of what you have been sent.

I guess it does make sense, but I am surprised to be honest. I would have thought there must have been some metadata around the message, something that if I send a Foo when I expect a Bar (even if Foo and Bar have an identical structure) the library would yell at me. But yes, at scale, all those extra bytes would add up. Oh well, lesson learned.

Volguus
Mar 3, 2009
Hmm, that could work. To be honest though, rather than doing that, for my case and my usage so far, I'd rather inconvenience those 3 users. The Bar message would look ugly and scream "Bad decisions were made, now we live with regrets".
Declaring that a Bar is invalid when there are no Foos present is enough for me right now, as it makes sense from a business logic point as well. And when a single Foo is sent, then there are no Foos in the Bar.

Would gRPC solve this problem better? I've never used it (and I believe there aren't C embedded libraries for it, but i could be wrong there), but could one declare something like:
code:
Response processFoo(Foo foo);
and later on just come and say:
code:
Response processBar(Bar bar);
as a brand new method while leaving the old one intact?

Volguus
Mar 3, 2009

Jabor posted:

Worth noting that it wouldn't necessarily be a long-term thing - after enough time that you expect all clients to have updated (and/or you're willing to stop supporting the ones that haven't), you delete the backcompat logic and change the definition to:
code:
message Bar {
  repeated Foo foo = 3;
  reserved 1, 2;
}
It's not unusual to see reserved tag numbers from previous api versions - it's just an acknowledgment that apis change over time. If you get in the habit of making backwards-compatible api changes now when it's largely inconsequential, you'll find it easier to do later on when it's important to get right.

That said if you control all the code that calls this api, or you're willing to immediately break backwards compatibility (and can ensure that all clients are going to update), you totally can just start fresh.

Yes, that's good advice, thanks, I'll keep that in mind. While I do not control all the code that calls this API, and I wanted to not inconvenience those few clients ... theyr'e very few clients and they know they're testing my API (beta and all that) so I just may start fresh and tell them to change their stuff. 2 developers are chinese and one is indian, I have no idea how they're gonna react, but I can tell the business guy to just make it work.

Volguus
Mar 3, 2009

TooMuchAbstraction posted:

That was my original suggestion: make a new API method with the desired signature, and delete the old method once people have had sufficient time to switch over.

...oh, was the reason you were having problems because you were just getting a binary blob on a socket and had to determine what its contents were at runtime? Yeah, gRPC would handle automatically dispatching to the appropriate server method depending on what proto you receive. At least, it does that for me in Python.

No, I am not using gRPC. One of the reasons is because I had to write an implementation in FreeRTOS on an ARC board using both lwip and bluetooth as communication mechanisms, and while looking around it didn't seem that gRPC and nanopb were working together. So, I abandoned the idea completely and I just read the message directly now.

The https://github.com/nanopb/nanopb/pull/248 pull though does gives me hope of this being implemented in the future, at which point (with a different endpoint than now, of course) i can probably provide a gRPC server.

Volguus
Mar 3, 2009

downout posted:

I can't help you but your av is pretty sweet.

Edit: to ask a question ->

Does anyone have suggestions for an application that would provide forms that can provide validation (formio style) and allow users to go back and reference entries and edit them? Basically an easily modifiable/editable validation grid?

First time I've heard about form.io. Looking at their page ... what is it exactly that they're providing here? A form designer? They call it "application"? Whose application? Where is it hosted? Where's the database? Who sees the data? How ... what? It looks extremely confusing.

Volguus
Mar 3, 2009

TooMuchAbstraction posted:

I'm using an HTML canvas with a Javascript script for visualization of the output of a procedural map generator. However, for some reason I only can have one map in a given file. Can anyone tell me why this HTML doesn't draw anything on the second canvas?

This:
code:
<canvas id="2" width="82" height="62" stroke="black"/>
should become this:
code:
<canvas id="2" width="82" height="62" stroke="black">
</canvas>
everywhere.

Volguus
Mar 3, 2009

Acidian posted:

I need to do some work on updating a book database, and instead of using an external developer (expensive), I might try and do it myself.

I want to get information from an XML file, CSV file or a .txt file (which would be sepparated by comma or tab), which will be headed by an ISBN number (Which will be my identifyer), then I want to find the same ISBN in an excel list I have exported from my database, then move information from the CSV/XML/TXT file, to the correct cell (all cells will be to the right of the ISBN). An example would be moving information about author from a predesignated field in the CSV/XML/TXT to the designated "author" field in the same row as the identifyer (ISBN) in my excel sheet.

I am thinking that the best way to do this would either to create a script in Excel, or to create a program in python to read the file and inserting it into the excel file?

I do not know how to script in Excel, other than some copy pasting of macros, and I have only done some really really basic python in a bioinformatics course, so I will basically teach myself how to do it. What do you guys think is the best option for me?

If you already have the book data in a database (I assume a relational database? MySQL or something similar?), why bother exporting it to Excel? Work with the database directly. Then you can use whatever language you're comfortable with (if none, python would be a decent start for a beginner). If you absolutely have to use Excel, then I would think that you pretty much have to use Excel's VBA. There are libraries out there that can manipulate Excel sheets (Apache POI for Java for example), but for a beginner VBA is probably the easiest way.

Volguus
Mar 3, 2009

Acidian posted:

The data is currently in a SQL database, but I do not have access to it directly. I have to export it to excel, then I can import again via excel. I can double check with the company maintaining the server. Anyway, we will be changing system in a couple of months, and I think I will have access to the SQL database directly in the new system (if I ask for it). However, I do not want to wait until it is in place before I start this work. Is VBA very similar to basic/visual basic?

I guess you can't use python to read and write into excel files?

Getting komma sepperated information into excel is relatively easy, so I guess the easiest vill be to use VBA to sort it from one table to the other within the same sheet.

Edit: Is there another programming language that I could use? I feel like learning VBA is a bit limiting for what I can do with it in the future, so if I am going to spend alot of time learning somthing then VBA seems uninteresting, but if I could teach myself C++ (I do know a little C++ and Java), or javascript, then that would be better. Maybe the easiest solution is exporting the excel file to txt, then manipulating a txt file with all the information in python, then import back into excel, then back into the database.

Oh, so if you want to learn a programming language to use after this particular endeavor, then VBA is probably not what you want. Like pokeyman said, python can manipulate Excel files and in Java there is the excellent Apache POI library. Pick your poison.

Volguus
Mar 3, 2009

Dominoes posted:

Hey dudS. Learning C. For context, I'm fluent N Python, A modern JS.

So far, it seems similar to Python, but W curly bracS, semicolons, verbose loops, enforcD type decs, A fewer/more-basic builtin funcNs A data structurS. (ie doesn't have neat thGs like comprehensions, map/filter, loads F helpR methods etc) FM WT I've heard, it's supposD to B much more difficult TN this cursory examinaN indicatS; ie loads F memory-management etc.

My suspicion is TT TS memory-management liS in T finR-points F pointers/malloc/free. Is TS T case? WT else am I missG?

A keyboard.

Volguus
Mar 3, 2009

ufarn posted:

I have file.txt:
grep -f whatiwant.txt -o file.txt

Volguus fucked around with this message at 18:55 on Mar 12, 2018

Volguus
Mar 3, 2009

TheCoach posted:

Sadly all we have here are PHP and javascript folks so this might prove problematic.

Whenever I hear an X language developer saying that "I can't program in Y, I am an X developer" I feel like punching them in the face. In reality, I just fire their rear end. It is perfectly acceptable to say: "Y language sucks donkey balls, I don't like it", but to refuse to work in it for 5 minutes, that's not acceptable.

And C# is not set in stone, was just suggested because it is easy. VB would work too (and just as easy). Or, go with plain old win32 apis.

Volguus
Mar 3, 2009

nielsm posted:

When you're targeting a receipt printer you don't want to make PDF files anyway, they usually take some text-based format with escape codes for formatting, barcodes, and graphics.

If you'd had a network-enabled version of the printer, I'd have suggested you used the built-in webserver (on the printer) that takes some XML format and prints it.

You mean postscript? Not all printers know PS, but there's a fair amount of them that do.

Volguus
Mar 3, 2009

Bob Morales posted:

ZPL is a common one

Are there printers other than the Zebra ones that know ZPL?

Volguus
Mar 3, 2009
Here is a SOCKS proxy that i wrote back in 1999 or 2000 or so that i found on my harddrive (yea, my /home folder is that old). As you can see, nothing much to it, just passing bytes around and interpreting them according to the spec.

Volguus
Mar 3, 2009

KernelSlanders posted:

Is there a coherent definition of "real time" systems or programming? Back when I did robotics, we thought about dedicated OS feature and guaranteed task execution times, but now I hear the term thrown around to describe REST services. Should I just stop thinking of "real time" as meaning real time?

That is the definition that I was familiar with as well: guaranteed task execution time. Lately people just mean: display the data as soon as is available (different values of "soon" are acceptable).

Volguus
Mar 3, 2009

JawKnee posted:

The code is at my work and I'm at home, so I don't have anything I can copy-paste for you, my apologies. It's a new job and I'm not terribly familiar with most of the technologies being used - C#, SQL, LINQ, typescript, JQuery, and others that I'm forgetting.

I'm familiar with verbatim strings though, and this isn't it. I've mainly seen it being used in front of using directives, if-blocks, for-loops, and other statements that are otherwise C# code - but not used as a prefix for html or javascript.

e: I think I've found it - it's part of the Razor syntax for ASP.NET

That looks like old asp and jsp pages.

Volguus
Mar 3, 2009

Munkeymon posted:

ASP only uses @s in the directives you'd see at the top of the file, so I understand why you'd get that impression: you open the file, recognize it's ASP and close it immediately without looking at the rest because that's the rational thing to do. It uses <% and %> for open/close tags (and I think maybe optionally <? and ?> because they were competing mainly with PHP when they made the spec). Source: I maintain ASP at current job :smith:

Right, but there doesn't seem to be a difference between this @{} and <% %> (in either asp or jsp). Is the same hat just a different color.

Volguus
Mar 3, 2009

AFashionableHat posted:

I'm almost inclined to point out that you are talking out your rear end. Preact is under 5KB gzipped. Even React and Redux, together, are under 35KB gzipped--so, yanno, you're only four orders of magnitude off. The entire JS bundle for my current project, talking to two external services and pulling in about a dozen dependencies of various types, is 105KB gzipped--which, given HSPA speeds, is a reasonable first-visit download for our target clients on HSPA or better.

Having seen the unreliable state-bashing options that average developers reach for when they don't have a reactive programming framework, it certainly seems like "your view should also update" is a difficult problem for most developers to do correctly, reliably, and in a high-performance way. These tools exist to solve real problems. They may not be problems you experience and I certainly understand the appeal of thoughtless Ludditism over learning how something actually works. But they are nevertheless real problems and there are good reasons that very smart people build those tools and why wise people use them where appropriate..

I'm also inclined to point out that you are talking out of your rear end too. React - our god and savior - rear end.

Volguus
Mar 3, 2009

baby puzzle posted:

Hi I'm stupid and I want to create a build process that does things. I had implemented this with gnu make a while ago, but the makefile is now impenetrable to me, and it also just randomly doesn't work. It is not something I can maintain.

I need to:
- copy specified files to certain locations
- convert wav files to ogg files
- run an encryption thing on files
- rename files based on mystical rules that I need to define myself

etc... Just basic build poo poo, and since the whole process can take a very long time, I need an incremental solution.

So, what I want is a build system that an actual human can understand and use to accomplish these kinds of tasks. Is there such a thing? I'm using Windows 10 and I will not install lovely pretend unix tools. Is it a mistake to even think about using any existing build system for this? I have approx. 0 hours available to sit down and learn something new.

CMD bat files can do all of that just fine. I can guarantee that they will not be more reliable or more "penetrable after 6 months" to you either. But, at least is not "unix tools".

Volguus
Mar 3, 2009

tricksnake posted:

Best/popular coding practice websites/games/apps? OK I have learned C++. Next I get bombarded with "just go code stuff" from every person I ask.

Open up an IDE and write code. Why do you need a website for that?

Volguus
Mar 3, 2009

Munkeymon posted:

Yes but have you considered that it's the cheapest RDBMS option on AWS?!

Not only that, but MySQL is easy to get started with. At the end of the day 99.999% of the applications out there that use MySQL never hit those problems. Because they will never have that much amount of data. For them, LAMP was the best thing since slice bread. Sure, it is an awful stack, awful language, awful database, but hey, they did their thing, it worked (at least in demo), got their paycheck and went happily on their way.
10 years later they call you, the expert, to come and unfuck their poo poo since now they got a ton of records and the DB keeps missing data and the reports take 1 day to generate. But that's fine, since the peanuts they paid for that simple CRUD app was more than worth it and it probably save/made their company millions of $.

Volguus
Mar 3, 2009

Thermopyle posted:

Is MySQL easier to get started with than Postgres?

Yes when the only tutorial you've read only mentions MySQL. Odds are you don't even know PostgreSQL even exists. Maybe heard of Oracle, but that's it.

Volguus
Mar 3, 2009

The Fool posted:

You need better tutorials

e: or newer ones

We're talking here about the new graduate or that accountant that happens to know a bit of programming and that whipped together that little app for their company. We're talking about done on the cheap. Hell, you're lucky that they actually read a tutorial and didn't just dive in applying hearsay knowledge they had.

"Better tutorials" only applies to someone given the time and who has the interest to learn more. Usually is a miracle that whatever they make actually works.

Volguus
Mar 3, 2009

rt4 posted:

What strategies are people using for high availability Postgres? I haven't seen anything as convenient as MySQL with Galera.

I just tell AWS to do it for me.

Volguus
Mar 3, 2009

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.
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.

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.

Volguus
Mar 3, 2009

Thermopyle posted:

Are any of the books in this machine learning humble bundle good enough to justify buying the bundle?

While I do not know the books themselves how good or bad they are, the subjects though are definitely worth $15. For this money I wouldn't even blink given what information is offered.

Volguus
Mar 3, 2009

Magnetic North posted:

Hungarian notation

NO

Volguus
Mar 3, 2009

huhu posted:

If I were you, I'd stop watching a course recommending outdated tools.

I doubt that the recommended tools have anything to do with anything here. He's trying to learn about ML and a big part of it is understanding the math behind it. Octave works perfectly fine. Yes, python comes nowadays with very powerful ML and math libraries, and he will need to work with them in the future, but the math is still the same. Whether you're doing it on paper, in Octave, Mathematica or python is irrelevant.
Now, if the math presented in the course is bad/wrong/irrelevant that's a different issue.
If I were you, I'd stop giving lovely advice.

Volguus
Mar 3, 2009

Helicity posted:

git is a DAG. directed acyclic graph. The whole point is to always move forward.

edit: is this a common thing for others? I've been at 5 companies ranging from struggling startup to massive enterprise and I've had to do this 2-3 times in total. I guess I'm trying to say that fighting against the way git works probably shouldn't be a decision in how you structure your code base and architecture, and hopefully not a routine occurrence.

No, rewriting git history is not a common thing, normally. There was (still is?), however, a fad going on that advocates doing exactly that on a daily basis. That is, the workflow comes and says: instead of using git properly (you know, create branches for the poo poo you're working on, make sure you're alone in said branch), how about you do your work-in-progress commits (the little ones, that we do all the time) in a "main enough" branch that everyone is working on, and when you're done, just rewrite history (push --force) to make the git history look nicer.
And oh, here's how you deal with the inevitable shitstorm that will happen once you obliterate your coworker's work.

It's hosed up, but it exists. On this very forum i saw people advocating that.

Volguus
Mar 3, 2009

Plorkyeran posted:

I've literally never seen anyone advocate this, so I'm pretty sure you're just misunderstanding people talking about doing WIP commits on a personal branch that you then rewrite into something sensible before mixing it with other peoples' code.

It may be the case, if everyone is saying this then that must be it. Still, in a world that has merge --squash rewriting history is never needed. While is true that on a private, only you work on it, branch anything goes, why would you have one workflow in one instance and another workflow when working with other people when is trivially easy to just merge -squash and not carry the WIP baggage with you?

Volguus
Mar 3, 2009

Plorkyeran posted:

A PR may have multiple things that should remain distinct commits when merged, but there really isn't any value to preserving "oops fixed a typo" commit.

Perfect, then you merge --squash from multiple branches. you can go as deep as you want in this rabbit hole. The only time I had to use push --force was when

Helicity posted:

The downside to that approach is getting in the habit of force pushing on your feature branches all the time - the last two times I've had to rewrite git history is from people accidentally force pushing on master when trying to do the above workflow and just whipping through commands too quickly.

Life is complicated enough, without additional help. Why make it hard when it can be easy? Why have a headache when I can sleep soundly? Why give myself work to do when I could be playing a game? Or work on poo poo that actually is important?

Volguus
Mar 3, 2009

Plorkyeran posted:

Why would I assemble several different branches when I can just have several commits on one branch?

Because branches are cheap in git and because you can't use --force because the powers that be (who know their poo poo) disabled such heresies.

Volguus
Mar 3, 2009

Plorkyeran posted:

Nah, I think I'll continue to use git features rather than jumping through dumb hoops to achieve the same thing.

push --force is the nuclear option. Sure, it's nice to have it when poo poo hits the fan, required even, but just like the nuclear red button that US presidents have, exercise caution when using it. Preferably, never touch it. Use the better suited features for your goal.

Adbot
ADBOT LOVES YOU

Volguus
Mar 3, 2009

pokeyman posted:

git is hard to use and even more confusing to talk about.

Exactly. And what's even more baffling, is that there are few simple rules that one should follow to not shoot oneself in the foot and make life simple and easy for everyone (including himself). And then there are still those that come and say: naah, i'll keep shooting, since not once in the last X years i blew my foot off. Which is technically correct i guess.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply