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
ryanrs
Jul 12, 2011

I've had close brushes with fortran in DSP code, like audio and image processing. A lot of black magic signal processing code started as fortran. For example, I am sure there's plenty of fortran in 5G tech, at least in the design tools if not the actual shipping silicon.

Adbot
ADBOT LOVES YOU

AgentCow007
May 20, 2004
TITLE TEXT

Bruegels Fuckbooks posted:

If you'd told me five years ago that people were using a framework like this for embedded, I would've said something uncharitable like "are you smoking crack?" Maybe I'm just getting too old.

I feel the same way... until someone makes me MicroJS :getin:

Spatial
Nov 15, 2007

There is Espruino. Now you can experience the computing power of 1945's ENIAC on a much smaller hardware platform!

ryanrs
Jul 12, 2011

Tiny architectures are cool, but I don't think I'll ever go back to 8-bit micros. Having a clean 32-bit architecture is so nice. It would take a lot for me to look at a not-ARM micro.

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?

Devian666 posted:

Mathematics intensive hobby projects. I don't really like C++ so I avoid it at all costs.

Ah, have fun then

In answer to your original question: I've gotten distracted by Haskell for hobby projects. It's worth checking out if you've only every used procedural languages

Devian666
Aug 20, 2008

Take some advice Chris.

Fun Shoe

HappyHippo posted:

Ah, have fun then

In answer to your original question: I've gotten distracted by Haskell for hobby projects. It's worth checking out if you've only every used procedural languages

I used Haskell in computer science functional programming course. It is on my list to try again. It will no doubt still be as mind bending as when I used it in the 90s.

Spikes32
Jul 25, 2013

Happy trees
I dunno if anyone here can help, but I've got a crystal reports question. Side bar, I dislike crystal reports and know enough to mess stuff up.

I have a report which reports out several pieces of data related to sample_id from a view in the database. I'm trying to add in a data column date_created from a separate table in the same database with sample_id as the primary key.

The issue is that date_created reports out 4 rows for each sample_id. I know what parameters I can use to filter for the particular row I want, but I only want to filter the data for this particular formula not the report as a whole so I can't use selection expert. When I try and use an if then else statement, it won't let me return a string as the else return it demands another date option.

My question boils down to how do I filter data for one specific formula without creating a sub report?

LongSack
Jan 17, 2003

Quick (I hope) CSS question.

I am working on a demo app representing a fictional online retailer, and I'm working on the retail web site now. I'm using a bootstrap 4 card to display individual products. The header contains the manufacturer, product name, and a price widget. The body contains the description. That's all working well.

The problem is the footer. What I want to be there is:
  • An optional left-justified indicator showing the minimum age for purchase, if there is one. I have several pre-made images for 13+, 16+, 18+ and 21+. If the minimum age is some other number, I just show the text "Age xx+"
  • An optional centered text if the in-stock quantity is running low, something like "Only 5 left!"
  • A right-justified button "Add to cart"

The problem is that the centered text is centered between the age badge and the button. This means that if there is an age badge on some items and not on others, the centered text blocks do not line up. What I really want is that the text in the center is absolutely centered in the DIV, not between the two other elements.

Here's the code (razor syntax):
code:
<div class="card-footer product-footer">
    <span class="alignleft"><AgeBadge Product="@Model" /></span>
    @if (Model.Quantity < 10)
    {
        <span class="lowstock">Only @Model.Quantity left!</span>
    }
    else
    {
        <span>&nbsp;</span>
    }
    <button @onclick="() => AddToCart(Model.Id)" class="alignright btn btn-outline-primary btn-sm">Add to Cart</button>
</div>
And here's the relevant CSS:
code:
.product-footer {
    display: flex;
    flex-direction: row;
    justify-content: space-around;
}

.alignleft {
    float: left;
}

.alignright {
    float: right;
}

.lowstock {
    font-style: italic;
    font-weight: 700;
    color: red;
    text-align: center;
    margin: auto;
}
Ideas? TIA

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



If I understand what you're asking correctly, the way to do this is to do
CSS code:
.product-footer {
    position: relative;
}

.lowstock {
    position: absolute;
    right: 50%;
    transform: translate(-50%, 0px);
}

LongSack
Jan 17, 2003

Munkeymon posted:

If I understand what you're asking correctly, the way to do this is to do

I made one change to the age-badge, so that it always puts something out, so if the item isn't age-restricted it puts "All Ages!". Then changing the CSS to this seems to do the trick:
code:
.product-footer {
    display: inline-block;
}

.alignleft {
    float: left;
    margin-left: 0;
    text-align: left;
    width: 33.33333%;
}

.alignright {
    float: right;
    margin-right: 0;
    text-align: right;
}

.lowstock {
    font-style: italic;
    font-weight: 700;
    color: red;
    float: left;
    text-align: center;
    width: 33.33333%;
}
I left the "width" off of the alignright class, because if I didn't the "add to cart" button would stretch to fit.

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?
Would probably be easiest to just make the footer a 1x3 grid

LongSack
Jan 17, 2003

HappyHippo posted:

Would probably be easiest to just make the footer a 1x3 grid

Hahaha, you’re absolutely right. I got so tied up in trying to use flex, I missed the obvious solution :doh:

ryanrs
Jul 12, 2011

What sort of language features does my C-like toy language need to have in order to be considered Turing-complete?

Right now it can evaluate algebraic expressions, load/store global variables, if/then/else, for/while/do, and call intrinsic functions in native code.

It CANNOT define functions in its own language or do recursion. No local variables or scopes.

This is just for a blurb in the release notes like "Version 1.4 is when this text editor became Turing-complete."

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

ryanrs posted:

What sort of language features does my C-like toy language need to have in order to be considered Turing-complete?

Right now it can evaluate algebraic expressions, load/store global variables, if/then/else, for/while/do, and call intrinsic functions in native code.

It CANNOT define functions in its own language or do recursion. No local variables or scopes.

This is just for a blurb in the release notes like "Version 1.4 is when this text editor became Turing-complete."

Load/store variables and conditional repetition (e.g. for/while) are the two minimum characteristics for Turing complete, so that seems to qualify.

Ruzihm
Aug 11, 2010

Group up and push mid, proletariat!


including what you've already posted, if you can have an arbitrarily long sequence of values (e.g., stack, queue, linked list, eg) it's probably turing complete.

Ruzihm fucked around with this message at 23:45 on Apr 2, 2021

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


Can you simulate a Turing machine in it?

ryanrs
Jul 12, 2011

The language itself has only ints and floats. It can't express arrays or things like linked lists. But you could write a couple stack operators in native code and make it available in the language, so close enough.

Thanks for the explanation!

xtal
Jan 9, 2011

by Fluffdaddy
Does it let you form an infinite loop? The fact that you have for/while/do normally suggests Turing completeness since the only way to prevent that while having those structures is to have a statically known amount of iterations, maybe the lack of local variables accomplishes that.

ryanrs
Jul 12, 2011

Yes, it can definitely get stuck in an infinite loop.

e: I just realized I can read/write from arbitrarily-sized framebuffers, which can be used as stacks. So it's definitely Turing-complete.

ryanrs fucked around with this message at 02:12 on Apr 4, 2021

ryanrs
Jul 12, 2011

What languages have a cool syntax for multi-dimensional looping? In C you would do something like:

for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { your crap here; }}

But surely someone else has developed something snappier? Bonus points if it'll fit into a C-like language without seeming too alien.

xtal
Jan 9, 2011

by Fluffdaddy

ryanrs posted:

What languages have a cool syntax for multi-dimensional looping? In C you would do something like:

for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { your crap here; }}

But surely someone else has developed something snappier? Bonus points if it'll fit into a C-like language without seeming too alien.

Like these? https://en.m.wikipedia.org/wiki/Array_programming#Languages

My first thought was list comprehensions in Haskell, but that's for permutations of arrays rather than matrices.

ryanrs
Jul 12, 2011

Right now I have:
pre:
for [x=0..w, y=0..h] {
    blah(x, y);
}
also supports Rust's inclusive range operator:
pre:
for [x=0..=10] {
    print(x);
}
In the first example, x varies fastest. Is this wrong? It feels opposite to how C would do it (if C had such a construct), but then C's way feels backwards to me. TBH, I'm not sure if I should have strong feelings on this point.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

ryanrs posted:

Right now I have:
pre:
for [x=0..w, y=0..h] {
    blah(x, y);
}
...

In the first example, x varies fastest. Is this wrong? ...

Yes. The syntax suggests that it's syntactic sugar "for [x=0..w] for [y=0..h]", so the intuitive reading is that y varies fastest.

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?
Two options in python:
code:
import numpy as np
for x, y in np.ndindex((3,2)):
    print(x, y)
code:
import itertools
for x, y in itertools.product(range(3),range(2)):
    print(x,y)
It's not really a syntax thing, except for the destructuring into x,y (which is good)

Hughmoris
Apr 21, 2007
Let's go to the abyss!
Just to get a general feeling: how frequently, and how comfortable, are you in using your debugging tools?

For my small personal/work python scripts, I usually just toss "print" statements everywhere. Now that I'm trying to teach myself a little C, it seems like learning the basics of gdb could be useful.

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?
gdb can be very helpful, and you should know how to use it.
But I don't disparage print statements. Sometimes they get the job done just as well.

12 rats tied together
Sep 7, 2006

The debugger is the one of the first things I learn in any language, right after how to install it and set up a working project structure.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...
Debuggers are extremely important, integrated ones doubly so. Once you feel comfortable enough, find an IDE which should have an integrated debugger of some kind. I believe even VS Code supports gdb and that's very lightweight! Stepping through code blind is possible, but it sucks in comparison to having all information for all parts you'll want to see.

I reserve use of print statements for instances where using a debugger is impractical. For example, gathering data on possible race conditions, firmware that does not nicely support debugging, services that will just decide "lol I'm done" if you block for more than 10s, stuff that can only be found in production, etc. They absolutely have their use, but once you're familiar with using a debugger print statements should usually be reserved for contingency use.

There's also adding print statements of some form for logging, which can be very important (having additional relevant information if an exception occurs, rather than just yeeting the stack trace further along), but those will generally exist in a separate logging framework of some kind and you can worry about that later.

Lastly, print statements are excellent ways to step through trivial programs while tinkering. Seeing all of the results for each step at the end can be a lot better than having to click "next" and "continue" a lot. Don't feel like you're doing it wrong if you're using print statements while you're still getting used to the language, or programming as a whole.

Walh Hara
May 11, 2012

Hughmoris posted:

Just to get a general feeling: how frequently, and how comfortable, are you in using your debugging tools?

For my small personal/work python scripts, I usually just toss "print" statements everywhere. Now that I'm trying to teach myself a little C, it seems like learning the basics of gdb could be useful.

For interpreted languages such as python/R I find using a REPL way superior to debugging. I have a interpreter session open at all times while coding so I'm just executing stuff as I write it. If there's an error I can simply modify the problematic code and run that part again, no need to restart the whole script. It's just very convenient, you just need to bind the "execute the selection in the interpreter" to an easy keyboard shortcut.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Hughmoris posted:

Just to get a general feeling: how frequently, and how comfortable, are you in using your debugging tools?

For my small personal/work python scripts, I usually just toss "print" statements everywhere. Now that I'm trying to teach myself a little C, it seems like learning the basics of gdb could be useful.

I'm constantly in debuggers and get really annoyed when I can't use one. Print statements and logging work great too. Python has pdb if you wanna try a new tool without learning a new language at the same time.

One big benefit of debuggers that I use too infrequently is their ability to modify things. You can try out a fix without having to stop the world, recompile, restart, and get back to the state you were in. If you like having a repl, debuggers let you drop into a repl anywhere you like with all the local state ready for touching.

I don't know if you're counting tools like address sanitizer, thread sanitizer, undefined behavior sanitizer, valgrind, etc. as debugging tools, but they're all very useful and it's nice to have enough familiarity to know when they might help solve your problem.

Also, once it works, turning tossed-around print statements into verbose-level logs can work nicely. Odds are if you found them useful once, you'll find them useful again.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Hughmoris posted:

Just to get a general feeling: how frequently, and how comfortable, are you in using your debugging tools?

For my small personal/work python scripts, I usually just toss "print" statements everywhere. Now that I'm trying to teach myself a little C, it seems like learning the basics of gdb could be useful.

yeah, the tracepoint function of gbd (and a lot of other languages/debuggers, even chrome does it now) is super useful because you can basically just put print statements wherever you want without having to recompile everything. print statements suck if you have long build times.

necrotic
Aug 2, 2005
I owe my brother big time for this!

Walh Hara posted:

For interpreted languages such as python/R I find using a REPL way superior to debugging. I have a interpreter session open at all times while coding so I'm just executing stuff as I write it. If there's an error I can simply modify the problematic code and run that part again, no need to restart the whole script. It's just very convenient, you just need to bind the "execute the selection in the interpreter" to an easy keyboard shortcut.

This helps while writing code but not debugging an entire existing code base.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Bruegels Fuckbooks posted:

yeah, the tracepoint function of gbd (and a lot of other languages/debuggers, even chrome does it now) is super useful because you can basically just put print statements wherever you want without having to recompile everything. print statements suck if you have long build times.

This is actually a hugely awesome and underrated ability for some debuggers. You can modify the breakpoints to not pause, but instead to evaluate and execute some code snippet.

You can also conditionally trigger the breakpoint, so if you end up in a state where dickbutt == null but shouldn't be you can see what everything else looks like and where things just were when they happened.

boofhead
Feb 18, 2021

I never studied maths or computer science but I do have some dev experience, and I'm applying now for a position as a junior backend dev, working in python. I don't want help with my homework, but I want to check my imposter syndrome real quick -- is it normal to get sent what amounts to a multiple choice knapsack problem challenge as a code challenge for a junior backend position? I'm going to do the rest and then try to leave as much time as possible to work on that, but from the few hours I've spent looking into it so far today, it seems a bit.. farfetched. Like, this is NP-complete stuff (e: right?), the dataset they link is only 20k rows so you could probably brute force it (but on a web app environment?), but they're asking how I'd recommend they scale that to add 5-20 million extra rows per month. Uhh... I guess I'd recommend "don't", but then again, I never studied computer science, so I don't know if this is A Normal Thing

boofhead fucked around with this message at 17:53 on Apr 8, 2021

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


Ridiculous interview questions are a completely normal thing. It's also possible that whoever sent you the problem doesn't know that it's NP-complete and wouldn't know what that means.

raminasi
Jan 25, 2005

a last drink with no ice
It is also possible that the answer they're looking for is an acknowledgement that the problem is NP-complete and some strategies for handling it anyway (because in reality sometimes you have to do that). Either way, it sounds a little weird for a junior position, but there's no real way to know which precise flavor of weird without talking to them more.

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?
Do they want an "optimal" answer or a "good enough" answer?

boofhead
Feb 18, 2021

The phrasing is literally:

quote:

Once the budget is defined, the tool must show a list of 11 players that constitute the best team one can have for this specific budget.

In bold, too. I have some ideas for how I could approach a "best guess" kind of solution and then hopefully compare to pre-generated lists at certain budgets to see how far off I am, but let's see how much time I have (or how long it'll take to generate those lists)

Thank you for your feedback, I was going a little crazy. I don't want any help with approaching the problem but it was nice to get confirmation that I'm not the world's dumbest dumb dumb. I'm definitely going to point to the NP-Completeness thing in my response, no way I'm copping a "aw, you didn't manage it? sorry, we're kinda looking for Rainman" for a junior dev role

boofhead fucked around with this message at 18:44 on Apr 8, 2021

Khorne
May 1, 2002

boofhead posted:

I never studied maths or computer science but I do have some dev experience, and I'm applying now for a position as a junior backend dev, working in python. I don't want help with my homework, but I want to check my imposter syndrome real quick -- is it normal to get sent what amounts to a multiple choice knapsack problem challenge as a code challenge for a junior backend position? I'm going to do the rest and then try to leave as much time as possible to work on that, but from the few hours I've spent looking into it so far today, it seems a bit.. farfetched. Like, this is NP-complete stuff (e: right?), the dataset they link is only 20k rows so you could probably brute force it (but on a web app environment?), but they're asking how I'd recommend they scale that to add 5-20 million extra rows per month. Uhh... I guess I'd recommend "don't", but then again, I never studied computer science, so I don't know if this is A Normal Thing
Is there really a maximum weight? If not, the answer is far simpler.

If you're writing backend code it's not necessarily a web app environment.

They've talked about scaling the data but have they talked about who'd be making the requests, how varied the inputs are to the request, and how many users would be making the request? Have they mentioned performance expectations, too? Is the problem space constrained in some way, like does the user only have 20 potential items out of the entire dataset that you need to optimize for?


edit: You replied before I did. From that description, are players "active" for someone to pick from or do they have access to the entire dataset? Can players already be taken by other people or are you allowed to draft from the entire pool? etcetc

Khorne fucked around with this message at 18:49 on Apr 8, 2021

Adbot
ADBOT LOVES YOU

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


raminasi posted:

It is also possible that the answer they're looking for is an acknowledgement that the problem is NP-complete and some strategies for handling it anyway (because in reality sometimes you have to do that). Either way, it sounds a little weird for a junior position, but there's no real way to know which precise flavor of weird without talking to them more.

This is the way I would approach it. If the interviewer is looking for this sort of answer, you've done the right thing, and if they fail you for not finding the optimum solution to an NP-hard problem at arbitrary scale, you've dodged a bullet.

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