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

10-15-2018 , 08:46 PM
I've helped out on a few installation scripts, and install locations differ slightly between Mac and centOS, but not by that much.

windows - **** windows
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-15-2018 , 08:56 PM
Quote:
Originally Posted by RustyBrooks
Yes, I feel like you should have solved this problem by now

There are a few places that are default binary locations, install stuff there and then you don't have to mess with your path. /usr/bin is where package managers usually put stuff, /usr/local/bin is where stuff you "manage yourself" usually gets put. You're probably installing the aws stuff with pip though, right? That should be in your path by default unless you installed python somewhere non-standard.

If there are 10 places you need to keep track of paths you're doing something wrong. I can think of... 2 or maybe 3. If you really have a lot then make a little bash script, like ~/.setpaths, set your paths in there, and source that anywhere that needs to have paths set.

bash is a programming language, not a config system, treat it like one - make programs/scripts/functions/libraries/etc
I just ran install AWS client like it told me to from here: https://docs.aws.amazon.com/cli/late...nstalling.html

Code:
pip install awscli --upgrade --user
But then I realized I guess I was on the linux instructions not MacOS. https://docs.aws.amazon.com/cli/late...all-macos.html

Code:
sudo /usr/local/bin/python2.7 awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
And that one worked except my python was in a different place so I just replaced '/usr/local/bin/python2.7' with python.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-15-2018 , 09:03 PM
Question for all the react people. I'm using BrowserRouter like this:

Code:
  <BrowserRouter>
    <div className="sans-serif">
      <Switch>
        <Route path="/login" component={Login} />
        <Route path="/" component={Main} />
       </Switch>
     </div>
  </BrowserRouter>
http://localhost:3000/login works fine when navigating through the app on local and on s3. But if I hit refresh it only works on local where I am running the local webpack dev server. If I do a static build and upload to S3 it static webserver - it returns a 404 when I try to hit /login through deep link or refresh.

Also there is no 302 browser redirect in my network history.



So what's going on here - is the webpack dev server serving routes behind the scenes? Is a production webserver expected to do the same? If so that kinda breaks the idea of a fully static site.

The s3 and cloudfront fixes for this seem to be to redirect all 404 and 403 errors to index.html. This works I guess but it's terrible for SEO.

Edit: ok I guess what's happening is the webpack dev server is just sending anything it can't find to index.html. Unfortunately S3 or Cloudfront doesn't seem to want to do that w/o first showing a 404.

Edit edit: Ok I take that back. If I set the error page on S3 to it's showing the right content but with a status of 404. Because it thinks it's showing the error page. That is just weird and bound to cause problems.

Last edited by suzzer99; 10-15-2018 at 09:14 PM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-15-2018 , 09:08 PM
Quote:
Originally Posted by suzzer99
Code:
pip install awscli --upgrade --user
This installs it for a single user - so it has to put it someplace in the user's home dir, which is a non-standard path. This is what you might do if you were on a multi-user system and didn't have root or didn't want it available for everyone, but it's absolutely not a normal case, and I don't really know why they lead with that.

Actually the weirdest part is that if you were going to install it for a single user, I'd put it in a virtualenv and have the virtualenv sourced in the bashrc.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-15-2018 , 09:30 PM
I posted a while back about how atrocious the whole snapchat redesign was, and I just read this (2 months old but probably still relevant):

https://www.recode.net/2018/8/7/1766...am-user-growth

User base shrinking. Pretty lolsy, epic-level fail. Snapchat had a stranglehold on its market even though every competitor was trying to do what it was doing. I hope whoever was in charge of that redesign never works anywhere again, that was easily a multi-billion dollar mistake.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-15-2018 , 09:32 PM
Snapchat was the easiest short ever - except you still had to time it right like all shorts.

There is nothing harder than saying cool with teenagers. By definition you're not gonna be cool anymore when the younger generation comes up.

I'd bet that the numbers weren't working even with their stranglehold (although Instagram stories were eating in pretty well right?) - so they had to do a redesign to implement ways to make more $$ down the line.

Snapchat is interesting in that literally everyone came out with a snapchat like feature and completely polluted the experience. So annoying - oops I clicked or swiped something wrong - now I'm in the Facebook/IG/iMessage/Whatsapp/Twitter/Slack/iOS Photos App/etc. Snapchat knockoff experience - no idea how to get back to reality.

It's looking pretty grim for another social media giant to come along in the current climate. All the existing sites will just clone them to death and ruin it for everyone - which they're fine with obviously.

Last edited by suzzer99; 10-15-2018 at 09:39 PM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-15-2018 , 09:36 PM
It's hard to put into one post how bad the major redesign was, and how much it misunderstood its own success and its userbase.

It left a huge gap in the market for IG to snap up, and now, it's no longer relevant. It'll probably be mostly gone in 2 years, maybe less. My stories get 4x the views in IG than they do in snapchat, with the same number of followers. A year ago it'd be unheard of for someone to primarily post stories in IG.

it still remains a MUCH better photo editing app/primary camera app than IG - it should try to capitalize on that, but I know it won't. It's probably the biggest case of CEO hubris that the world has seen so far. The potential was unreal.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-15-2018 , 09:40 PM
But really my main point back then was usability/UI for an app is EVERYTHING.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-16-2018 , 12:30 AM
Quote:
Originally Posted by Craggoo
I'm starting to wonder if I should just try and spend the time to go through a book like

Quote:
Cracking the Coding Interview
I expect I would need to spend a little time in Java first before anything in the book would make sense. Does this seem like a worthwhile endeavor?
I'm also curious if there's feedback on this book - was talking with a tech company recruiter who recommended it to prepare for interviews.

I'm currently signed up for Interview Cake, which you have to pay for but it feels worth it - it's kind of like the coding challenge sites that are everywhere, but for every problem they have, they talk through solving it (with some hints at the start if you're stuck) in the context of how you should approach it in an interview type setting, and how to apply common strategies to different problems.

Actually, checking again, it must be popular or something because the price went wayy up since I got it ($80 for a year of access back in March, now $250???)
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-16-2018 , 12:51 AM
I bought CCtI - the first version. Seemed useful but at the time my takeaway was Lol Facebook, Google, etc. and their silly interview processes.

Fast forward 8 years and now every startup thinks they're Facebook. I bought the newest version. Didn't read it of course but if I hadn't landed a gig soon I probably would have.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-16-2018 , 12:54 AM
Quote:
Originally Posted by goofyballer
I'm also curious if there's feedback on this book - was talking with a tech company recruiter who recommended it to prepare for interviews.

I'm currently signed up for Interview Cake, which you have to pay for but it feels worth it - it's kind of like the coding challenge sites that are everywhere, but for every problem they have, they talk through solving it (with some hints at the start if you're stuck) in the context of how you should approach it in an interview type setting, and how to apply common strategies to different problems.

Actually, checking again, it must be popular or something because the price went wayy up since I got it ($80 for a year of access back in March, now $250???)
You got a great deal. Interview cake must be doing some pricing tests or something. It has been around $200 since I first looked at it a couple years ago and when I paid for it last year.

Cracking the coding interview is pretty similar to IC except it's not interactive in the same way and looking up hints and solutions is a pain in the ass. It has some good content on how to approach interviews in general and some more general job hunting advice too. It seemed a little more tailored to Google style interviews where things are underspecified than IC where problems are presented more in a more straightforward manner.

You don't need to be fluent in Java to get a lot out of it. The Java language features used are very easy to follow if you know basic for loops, array operations, and hashmaps. Where Java implementations of things are significant it's mostly called out for you.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-16-2018 , 01:10 AM
This may be just because I'm a newbie, but uploading a file and using node/express to get the file, then read a json file to figure out what to name the uploaded file, then putting the file where I want it was hard. Lotta asynchronicity. But, done!
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-16-2018 , 01:15 AM
Look into async/await to avoid callback hell. Feel free to paste your code.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-16-2018 , 01:42 AM
Quote:
Originally Posted by suzzer99
Look into async/await to avoid callback hell. Feel free to paste your code.
I made a couple passes at async, await, but not in earnest. I want to understand it the "old fashioned" way first. I didn't really want to use multer or anything like it, but apparently fileupload was taken out/deprecated from express and you have to use something third party. I don't quite get the role of 'cb' in there. I don't know if that's just because I don't get it or because it's obscured in multer.

Code:
var storage = multer.diskStorage({
	destination: function (req, file, cb) {
		cb(null, '../solarreact/public/img')
	},
	filename: function (req, file, cb) {
		fs.readFile('../solarreact/src/ImageData.json', 'utf8', (err, data) => {
			if (err) throw err;
			imgDataArr = JSON.parse(data);
			const filename = imgDataArr[imgDataArr.length-1][2].toString() + '_' + imgDataArr[imgDataArr.length-1][0].toString() + '.jpg';
			imgDataArr.push([imgDataArr.length+1, "./img/" + filename, imgDataArr[imgDataArr.length-1][2], "this would be the caption here"]);
			console.log(JSON.stringify(imgDataArr));
			writeImageData(imgDataArr);
			cb(null, filename);
		});
	}
});

var upload = multer({ 
	storage: storage
});
app.post('/api/imgupload', upload.single('image'), function(req, res, next) { 
	res.send('this is post route upload');
});
Code:
function writeImageData(jsondata) {
	fs.writeFile('../solarreact/src/ImageData.json', JSON.stringify(jsondata), (err) => {
		if (err) throw err;
		console.log('the file has been written');
	});
}
edit: added the last function there

Last edited by microbet; 10-16-2018 at 01:50 AM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-16-2018 , 01:42 AM
Quote:
Originally Posted by suzzer99
My boss literally told a dev he had to use a gui git client and not the command line. I can't imagine if that had happened to a ton of posters itt.

To be fair this guy is pretty raw - not some command line rock star like everyone here
Quote:
Originally Posted by river_tilt
This happened to me. Apparently, command will scare our clients.

I know what I am doing with command line. What my boss can't see won't hurt him. On a completely unrelated note, he works in a different building to me at the moment.
Wtf, this is such a weird policy. Are they just saying that because they are afraid you guys don't know what you are doing with the command line?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-16-2018 , 03:41 AM
Quote:
Originally Posted by blackize5
You got a great deal. Interview cake must be doing some pricing tests or something. It has been around $200 since I first looked at it a couple years ago and when I paid for it last year.
Interesting - for me it was $100, then after the 7 day email newsletter thing they included a "special, if you act now!" 20% off deal.

Do you feel like it prepared you pretty well for interviews? Like, when companies hit you with their questions, any major curveballs or did you mostly feel like "I got this"?

Random fun story: my manager, when he does interviews, literally asks people "implement the C strstr function" (find a substring from within a larger string and return where it occurs) and he says like 70% of people **** it up, which blows my mind. Like ~every IC question is harder than that.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-16-2018 , 06:13 AM
Quote:
Originally Posted by suzzer99
Question for all the react people. I'm using BrowserRouter like this:

Code:
  <BrowserRouter>
    <div className="sans-serif">
      <Switch>
        <Route path="/login" component={Login} />
        <Route path="/" component={Main} />
       </Switch>
     </div>
  </BrowserRouter>
http://localhost:3000/login works fine when navigating through the app on local and on s3. But if I hit refresh it only works on local where I am running the local webpack dev server. If I do a static build and upload to S3 it static webserver - it returns a 404 when I try to hit /login through deep link or refresh.

Also there is no 302 browser redirect in my network history.



So what's going on here - is the webpack dev server serving routes behind the scenes? Is a production webserver expected to do the same? If so that kinda breaks the idea of a fully static site.

The s3 and cloudfront fixes for this seem to be to redirect all 404 and 403 errors to index.html. This works I guess but it's terrible for SEO.

Edit: ok I guess what's happening is the webpack dev server is just sending anything it can't find to index.html. Unfortunately S3 or Cloudfront doesn't seem to want to do that w/o first showing a 404.

Edit edit: Ok I take that back. If I set the error page on S3 to it's showing the right content but with a status of 404. Because it thinks it's showing the error page. That is just weird and bound to cause problems.
You do this with .htaccess on Apache, basically set it to serve /index.html for all paths. I am not sure if redirects will work to preserve the route, but if they do then good I guess!

Here's some example server configs: https://github.com/ReactTraining/rea...ng-your-server

This article has some changes to webpack to get it working locally, then sets S3 error page as index.html and says it works fine https://medium.com/@ervib/how-to-set...s3-d3dffa6ae43 (he's probably at the same spot as you and not bothered by the 404 response if it looks working, I guess?)

Personally I use the react-router <HashRouter> instead of <BrowserRouter> since that seems to work just as well and supports working out of arbitrary folders / subfolders perfectly with no reconfiguration, it seems to me the only cost being a hash in the middle of the visible url. For this ability to dump a HashRouter page in any folder on any server, add:
Code:
"homepage": ".",
to the top level of package.json in your project.

Last edited by _dave_; 10-16-2018 at 06:21 AM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-16-2018 , 10:15 AM
Yeah thanks that matches what I found - using .htaccess. The takeaway here seems to be that cloudfront + S3 is not really a full-fledged static webserver.

Hash routing has always bugged me for some reason but I have no idea what our requirements are on this so we'll see.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-16-2018 , 10:49 AM
Quote:
Originally Posted by microbet
I made a couple passes at async, await, but not in earnest. I want to understand it the "old fashioned" way first. I didn't really want to use multer or anything like it, but apparently fileupload was taken out/deprecated from express and you have to use something third party. I don't quite get the role of 'cb' in there. I don't know if that's just because I don't get it or because it's obscured in multer.

Code:
var storage = multer.diskStorage({
	destination: function (req, file, cb) {
		cb(null, '../solarreact/public/img')
	},
	filename: function (req, file, cb) {
		fs.readFile('../solarreact/src/ImageData.json', 'utf8', (err, data) => {
			if (err) throw err;
			imgDataArr = JSON.parse(data);
			const filename = imgDataArr[imgDataArr.length-1][2].toString() + '_' + imgDataArr[imgDataArr.length-1][0].toString() + '.jpg';
			imgDataArr.push([imgDataArr.length+1, "./img/" + filename, imgDataArr[imgDataArr.length-1][2], "this would be the caption here"]);
			console.log(JSON.stringify(imgDataArr));
			writeImageData(imgDataArr);
			cb(null, filename);
		});
	}
});

var upload = multer({ 
	storage: storage
});
app.post('/api/imgupload', upload.single('image'), function(req, res, next) { 
	res.send('this is post route upload');
});
Code:
function writeImageData(jsondata) {
	fs.writeFile('../solarreact/src/ImageData.json', JSON.stringify(jsondata), (err) => {
		if (err) throw err;
		console.log('the file has been written');
	});
}
edit: added the last function there
This looks ok except throw err might not going to break the flow the way you expect - since you're in asynchronous land. You probably need to pass err as the first argument to cb(err, data) instead. This will probably call the express next(error) behind the scenes, which is the equivalent of throwing an error in the express asynchronous flow. Does the multer example use throw?

Same goes for writeImageData. You're firing this off as an async process while the primary request/response flow continues on. So any errors won't be handled at all - they just get thrown to the node event loop executor, which has no idea what to do with them. If you want the user to get some input if the file write fails, you'll have to use another callback here and only call cb() inside that. Or use async/await (or straight promises, or the 3rd party async-js lib). You're probably getting an idea what "callback hell" means at this point.

The cb() is basically a nested callback inside filename()/fsReadData(). Whatever function inside multer (obscured but you could look at the code) that executes filename() is feeding a callback (cb()) which it uses to do the actual work. fs.readData takes an anonymous function as a callback ((err, data) => ... ) which gets executed when it's done and that ultimately executes the parent callback (cb) at the end.

Also holy 8-space tabs. Muh horizontal space!

I'll play with this some more when I get into work.

One of the best things about pull requests is multiple users can comment right on the lines of code in question - makes collaboration super easy.

** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-16-2018 , 11:10 AM
Thanks. The error stuff is pretty much all copy-paste and possibly legacy from an earlier effort. I def intend to get into error handling after I get basic functionality working. If that ever happens. I'm a huge feature creeper.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-16-2018 , 11:11 AM
I did feel that interview cake prepared me well. The only question I remember having a hard time with during that round of interviews was unfortunately at Google.

It was essentially how would you guess my number in the fewest steps. Binary search ok. Now what if there is a different cost associated with each number you can guess. And I tanked right there, not really understanding what he was looking for and completely forgetting everything I once knew about probability.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-16-2018 , 11:17 AM
Lol I need to start brushing up on that ****. May start looking for a job very soon, mine is becoming unbearable.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-16-2018 , 12:02 PM
I used interview cake as well. Was 200 for me iirc. Half the qs I went through I ran into some similar variation in real interviews and got a job within a couple weeks of buying so meh, was worth it to me. Think it's a pretty helpful site, combined with like a code wars style site
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-16-2018 , 01:20 PM
Quote:
Originally Posted by microbet
Thanks. The error stuff is pretty much all copy-paste and possibly legacy from an earlier effort. I def intend to get into error handling after I get basic functionality working. If that ever happens. I'm a huge feature creeper.
Also did you look at this: https://www.npmjs.com/package/express-fileupload

Seems like it might be simpler than multer. Seems weird that destination and filename are both asynchronous functions. Is there a different option? Like could destination just be:

Code:
destination: '../solarreact/public/img',
For file you could always use read/writeFileSync instead of read/writeFile (which you should never do in a real multi-user world - synchronous I/O is the biggest no-no in a node app, but it's ok if this app is just you uploading pictures).

Btw async/await would be tough because of the way express middleware and your multer app works. Callbacks are fine - but you could use something like at async.js (https://github.com/caolan/async) to make the code easier to reason with - once you've satisfied yourself that you've experienced callback hell the hard way.

Last edited by suzzer99; 10-16-2018 at 01:28 PM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-16-2018 , 01:26 PM
I have user file upload in my game and easiest way to make it work was to base 64 encode it ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote

      
m