Open Side Menu Go to the Top
Register
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

11-15-2018 , 04:56 PM
Ok maybe i am just being nitpicky. I always tend to call with (n,1).
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-15-2018 , 05:03 PM
Quote:
Originally Posted by microbet
I don't fget any of that, so feel free to explain which way is better and why.


fread will read from a file into a buffer like this:

fread(buffer, n, nmemb, file pointer)

n is the number of bytes you are requesting nmemb times, so if you do fread(buffer, 1, 8192, fp) you are requesting 1 byte read 8192 times, vs 8192 bytes 1 time. Then it will return whatever the successful number of nmemb reads was.

but fread will (presumably) read byte by byte anyway into its own internal buffer using getc, so the assumption can be made it doesn’t matter which one you use. But implementations of fread can vary because the standard doesn’t really necessitate n * nmemb calls to getc. It may implement it completely differently if it wishes, as long as it follows the standard.

The number of getc calls is important because it makes a system call which is very expensive.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-15-2018 , 05:43 PM
I get a lot of the recent complaints about SO, but this is like a perfect example of where it’s good. The weird super edge case debate gets moved to the side / hidden and what you need to know is obvious.

It’s far from perfect (especially culturally), but damn am I glad it exists.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-15-2018 , 05:51 PM
Thanks jmakin
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-15-2018 , 09:11 PM
I wrote a decently sized application in C today and my brain is absolutely fried, i came across that comment and i guess it triggered me more than it should have
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-15-2018 , 11:47 PM
Quote:
Originally Posted by jmakin
Ok maybe i am just being nitpicky. I always tend to call with (n,1).
When you do it this way you can't tell how many bytes were read when it fails, which is sometimes useful to know
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-15-2018 , 11:54 PM
Also, this is going out on a limb a bit, but I think POSIX specifies that fread should be an equivalent set of fgetcs. If you have a POSIX compiler, then it should always do that.

Not all compilers are POSIX compliant, and I wouldn't be surprised to find that some supposedly POSIX compliant compilers could have bugs or deviations from spec.

A few days ago I realized that stdc++ and libc++ have different behavior for a function, streambuff::in_avail, that tells you whether or not a stream has bytes that can be read. I can't remember which is which now, but in one of them, the function always says "no" even if the answer is "yes"

A program that we download/compile started breaking for us because they switched from one to the other.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-15-2018 , 11:56 PM
Quote:
Originally Posted by RustyBrooks
When you do it this way you can't tell how many bytes were read when it fails, which is sometimes useful to know


Yea i know, but the reads i’m doing i want all or nothing
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-16-2018 , 02:37 AM
You can do this

Code:
function getValues(param) {
  let x = param + 2;
  let y = param + 3;
  let z = param + 4;
  return [x, y, z];
}

a = getValues(2);
alert(a[0]);  //4
alert(a[1]);  //5
alert(a[2]);  //6
Is there a way to do like this and just assign the return to variables in javascript? Seems like there might be some way to fat arrow something.

Code:
function getValues(param) {
  let x = param + 2;
  let y = param + 3;
  let z = param + 4;
  return x, y, z;
}

(a, b, c) = getValues(2);
(that doesn't work)

you can do this in python

Code:
def getValues(param):
   x = param + 2
   y = param + 3
   z = param + 4

(a, b, c) = getValues(2)
print(a)  #4
print(b)  #5
print(c)  #6
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-16-2018 , 03:50 AM
What you're looking for there is destructuring which is something that got added fairly recently in JS.

If we return that array of values, then we can destructure that into another array with those variables. Like this:
Code:
function getValues(param) {
    let x = param + 2;
    let y = param + 3;
    let z = param + 4;
    return [x, y, z];
}

let [ a, b, c ] = getValues(2);
console.log(a) 
console.log(b) 
console.log(c)

If you return an object like this, you can destructure it with this syntax. Note that your variable names on the left must match the variable names in the return value, since the return object actually looks like this: { x: 6, y: 7, z: 8 }
Code:
function retValues(param) {
    let x = param + 2;
    let y = param + 3;
    let z = param + 4;
    return { x, y, z };
}


let { x, y, z } = retValues(4) 
console.log(x)
console.log(y)
console.log(z)
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-16-2018 , 04:10 AM
You could just return them as properties on an object also. That way they have names.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-16-2018 , 11:03 AM
Thanks both.

I had heard someone talk about destructuring as a new feature in a JS podcast, but it was just talk, they don't really spell out code in podcasts. Now I know what they were talking about.

Chris, yeah. Either an object or array works, I was mostly curious, but the result goes in a very small function never to be used again and it seems more elegant to me to skip having to name the array or object.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-18-2018 , 01:49 PM
Quote:
Originally Posted by fredd-bird
Skip Notepad++ and go straight to VS Code or get good at Vim.
I'm still splitting time on Notepad++ and Vim, but getting my .vimrc file set up better is making Vim nicer. I still need to get auto-completion.

(tabstop and shiftwidth=3, colorscheme evening, Lucinda_console font at 12 for my old eyes.)
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-18-2018 , 02:40 PM
Pretty sure you can use the array reduce function
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-20-2018 , 11:29 AM
I have an interview for a job.

I have two years experience in .Net and the job is .Net, MVC, Web, Javascript, Scrum etc... standard stuff that I do regurlary.

They told me there is a 75 minutes test. What would be the best way to prepare for that kind of test? What are the generally asked question in those type of test?

Thanks
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-20-2018 , 11:31 AM
Check Glassdoor.com and see if they have anything on the tests during interviews.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-20-2018 , 01:29 PM
Quote:
Originally Posted by microbet
I'm still splitting time on Notepad++ and Vim, but getting my .vimrc file set up better is making Vim nicer. I still need to get auto-completion.

(tabstop and shiftwidth=3, colorscheme evening, Lucinda_console font at 12 for my old eyes.)
omni-completion is pretty cool. I can see being able to really fly when you are good at it.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-20-2018 , 04:18 PM
Spent last 2 days trying to fix memory leak in express with no luck
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-20-2018 , 04:18 PM
Quote:
Originally Posted by microbet
omni-completion is pretty cool. I can see being able to really fly when you are good at it.
I really liked whatever completion plug in I used but getting language based auto complete was tough. Like showing functions on an object. Seemed silly to not just use vs code at that point, but then I'm not as leet
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-20-2018 , 04:19 PM
Quote:
Originally Posted by Grue
Spent last 2 days trying to fix memory leak in express with no luck
Haha I think the common node solution is just restart the process once a day.

How'd you go about debugging this? I write so much node but do so little debugging
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-20-2018 , 04:21 PM
Do set noexpandtab on vim too, unless you’re into that sort of thing
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-20-2018 , 04:22 PM
Suzzer, you still working in serverless land? How's that going?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-20-2018 , 05:02 PM
Quote:
Originally Posted by Grue
Spent last 2 days trying to fix memory leak in express with no luck
I would love love love a writeup of this. You should do a medium post or something. Or at least just give us a synopsis of the problem and what you've tried so far here.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-20-2018 , 05:07 PM
Quote:
Originally Posted by PJo336
Suzzer, you still working in serverless land? How's that going?
Great. Tomorrow I'm giving my first real presentation to our group of what I've been working on so far.

Here's the "What have I been doing for the last 3 months?" slide:

Quote:
  • Various code pipelines driven by commit to source control
  • Git branching strategy and workflow
  • C# lamdbas/testing/Visual studio solution workflow
  • Node lambdas with testing
  • API Gateway generated from swagger
  • CI/CD flow and testing platform for front end
  • Workflow for react site with cognito
  • POC cognito login and registration flows back-end with lambdas
  • Internal only access for dev/test sites, living documentation, future monitoring dashboards, etc.
  • Draft architecture for donor portal and other cognito-based internal apps
Here's the donor portal architecture (not including some ETL side flows):



So far we're still in POC-land for the most part. But I'm getting paid well to watch Udemy videos so that's cool.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-20-2018 , 06:32 PM
I watch hella udemy. Any good ones you recommend?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote

      
m