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

11-24-2018 , 04:02 PM
Rusty,

Props on not installing the big brother spyware.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-24-2018 , 04:44 PM
Maybe too much to go into here, and maybe this will be one I figure out before I hit "post", but:

In a React/Node thing I have:

node app got these parts up top

Code:
const cors = require('cors');
.
.
.
app.use(cors())
and I have (I don't think the logic/work inside the route really matters as far as this prob is concerned, so maybe just skim that first)

Code:
app.post('/api/editCaption', (req, res) => {
	// console.log("what the harpo");
	fs.readFile('../solarreact/src/ImageData.json', 'utf8', (err, data) => {
		imgDataArr = JSON.parse(data);
		console.log(imgDataArr);
		console.log("change caption of " + req.body.imgObj + " to " + req.body.newCaption);
		imgDataArr.forEach(function(element) {
			if (element.family === req.body.imgObj.family && element.childNum === req.body.imgObj.childNum) {
				element.caption = req.body.newCaption;
			}
		});
		writeImageData(imgDataArr);
		console.log(imgDataArr);
	});
});
Which is getting a

Code:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:5000/api/imgupload. (Reason: CORS request did not succeed).[Learn More]
error in Firefox, but not Chrome.

I have another route

Code:
app.post('/api/deletePic', (req, res) => {
	let imgFolder = "../solarreact/public/img/"; 
	let fileName = getFilename(req.body.imgObj);
	writeImageData(req.body.jsondata);
	fs.unlink(imgFolder + fileName, (err) => {  
		if (err) {
			console.log("error deleting ", imgFolder + fileName, " :", err);
		} else {
			console.log(imgFolder + fileName, " was deleted");
		}
	});  
	let thisFamNum;
	let thisChildNum;
	let newChildNum;
	fs.readdir(imgFolder, (err, files) => {  
		if (err) {
			next(err);
		} else {
			files.forEach(file => {
				thisFamNum = getFamNum(file);
				thisChildNum = getChildNum(file);
				newChildNum = thisChildNum - 1;
				if (newChildNum>=req.body.imgObj.childNum && thisFamNum === req.body.imgObj.family) {
					let sel = imgFolder + '/' + file;
					let dis = '';
					dis = imgFolder + '/' + thisFamNum.toString() + '_' + newChildNum.toString() + '.jpg';
					fs.renameSync(sel, dis);
				}
			});
		}
	});
	res.json({ message: "pic deleted" });
});
Which seems pretty damn similar and works in Firefox and Chrome without throwing that error.

I don't see how the React code would matter and can post more details on those, but the calls look like this:

Code:
axios.post('http://localhost:5000/api/deletePic', data)  
	.then((res) => {
		console.log(res);
	});
and

Code:
axios.post('http://localhost:5000/api/editCaption', data) // edit the caption
	.then((res) => {
		console.log(res);
	});
Everything is working in Chrome. My first thought was something to do with headers and Chrome being more forgiving and I've tried all sorts of stuff I've seen on SO or elsewhere like:

Code:
app.use(function(req,res,next) {
	res.setHeader("Access-Control-Allow-Origin","*");
	res.setHeader("Access-Control-Allow-Headers","Origin, X-Requested-With, Content-Type, Accept");
	res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
	res.setHeader('Access-Control-Allow-Credentials', true);
	next();
});
with and without "cors()" or "next" in the app.post in all combos I could guess to no avail.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-24-2018 , 05:54 PM
your error message points to "api/imgupload" which isn't mentioned anywhere else as far as I can tell.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-24-2018 , 06:26 PM
Dunno how that happened. I went to recreate and did get:

Code:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:5000/api/editcaption. (Reason: CORS request did not succeed).[Learn More]
When I do imgupload I do indeed get that error:

Code:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:5000/api/imgupload. (Reason: CORS request did not succeed).[Learn More]
But, it still works in Firefox. The image uploads and the processing inside the route is all completed. I must have just done that before posting. Image uploads fine in Chrome without throwing that error.

The upload goes like this:

Code:
app.post('/api/imgupload', upload.single('image'), function(req, res, next) { // upload pic to image directory
//	res.send('this is post route upload');
});
but has a bunch of stuff happening in loading up storage for:

Code:
var upload = multer({ 
	storage: storage,
	limits: limits,
	fileFilter: fileFilter
});
the deletePic one is more similar to the editCaption which isn't working (Firefox only!)
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-24-2018 , 06:51 PM
Are You handling an option route? I don't recall if it's still true but I think it used to be only chrome did it. That includes a header that approves OPTION as well as returning 200 for OPTION

Last edited by PJo336; 11-24-2018 at 06:55 PM. Reason: Looks like you are, I'm skimming :)
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-24-2018 , 09:03 PM
Quote:
Originally Posted by just_grindin
I have always wanted to switch to Arch but seriously seems like it eats up so much mindspace learning/using it that might be better served doing other things.
I have heard and seen the tutorials and community are great though.


Edit: by learn to use it I just meant compiling all your options etc.
You don't really compile anything in arch, I think that's gentoo. You do however spend a ton of time setting it up and assembling all the pieces needed to run a modern OS, especially for the first time.

I really like the arch KISS mentality and I'm a sucker for setting up as "pure" or lightweight a system as possible, but in the end it is a huge productivity drain for dubious benefits. Most distros run fine out of the box once you have everything updated. Who cares if there's a few GB of unnecessary tools and software. Disk space is super cheap anyways.

It's fine if you want to learn more about how linux works and you like tinkering with your computer. But if you're focused on getting work done then I think it's a waste of time compared to distro's that are simpler to install.

The theory is that you only set it up once and then just upgrade cause it's a rolling release. But that doesn't cover when you get a new computer. I would dread having to go through the process again when i got new work machines.

Last edited by Wolfram; 11-24-2018 at 09:09 PM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-24-2018 , 09:40 PM
I got it so that it throws the error on firefox, but still works. I need to put some work in to understand why and maybe get rid of the error that doesn't stop it from working.

The difference between the two things I thought were identical were one was submitted via form and the other wasn't. And the key to the fix (in addition to playing around with the onSubmit to be like this "onSubmit={(event) => this.captionEditor(event, thisImgObj)}" was to do event.preventDefault.

Whatever this was/is worked in Chrome though. I thought the days of things not working the same across browsers, excepting maybe previous versions of IE, were over.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-24-2018 , 10:39 PM
uh why are you using cors when I dont see https anywhere? Also

axios.post('http://localhost:5000/api/editCaption'

just try

axios.post('/api/editCaption'

etc.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-24-2018 , 11:30 PM
Quote:
Originally Posted by RustyBrooks
One of the companies that I used to work for went this route (many years after I left). They got bought by a company that fired all the employees and specifically used Crossover to find and manage all the remote workers to fill out shell roles.

I had done consulting for them off and on since I left, because they never really replaced me. They tried to get me to install this crossover spyware and I was like "no." I had some other demands they didn't like and they kept me on until they could find someone to replace me who wasn't so picky. Which was fine with me.
I get that it makes financial sense. But I can't imagine how soul sucking it would be to work for one of those companies in vampire mode.

If that's all that's left I'll just move somewhere tropical, but not too hot, and make hats on the beach for tourists.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-24-2018 , 11:32 PM
Quote:
Originally Posted by maxtower
Many companies are very penny-wise and pound-foolish when it comes to software. One thing that sticks out is that many banks and medical companies pay less than pure tech employers. They think they are saving money, but instead they are getting qualitatively worse people and the software quality will suffer as a result.
A buddy of mine got hired at PIMCO (the bond giant) circa 2010 or so. He said they would come around and yell at developers for talking to each other. He also said they had just gotten version control right before he got there. Crazy. He lasted 3 months.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-24-2018 , 11:35 PM
micro, if you're still struggling and want to do a coding session tomorrow lmk.

I was very close to going to Hollywood Park for the Friday night tourney and was going to text you. But then several hours on the couch set in. Hustler has some weird tourney going on right now that I don't fully understand but looks interesting.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-25-2018 , 12:30 AM
Quote:
Originally Posted by Grue
uh why are you using cors when I dont see https anywhere? Also

axios.post('http://localhost:5000/api/editCaption'

just try

axios.post('/api/editCaption'

etc.
The basic answer to the first and second questions are a combination of 'legacy issues' and me not knowing what I'm doing.

The node app is running on a server on port 5000. The react is running on port 3000. I start both servers to work on this. Tested it now and, it does need the localhost:5000 part.

The reason for cors is that I was getting errors and looking up the error led me to cors and using cors made it do what I was trying to do. My probably wrong understanding was that the requests from the same host (and I guess just "localhost" and not the specific port counted as the same) was prohibited unless specifically allowed by some method and cors was one way to do that. I didn't see that https was part of that, though maybe it is, though like I said, cors solved a problem and that's why it's there.

I started these things on different servers/ports (iirc) because they started as separate projects. I wanted to do a website in React and was going to have a slideshow of pictures. I had also done some hello worldish thing in node in a separate directory. When I was about to load up pictures for the slideshow I was like, geez, that should really be done in an admin interface on the website so pics can be changed and moved around etc. I've had in the back of my mind the question of why two servers for a while, but I'm getting the features working first.

It's a learning project so I expect to rewrite a bunch. I've already had pretty much all the functionality working, but decided the way I was saving the data (information about pictures: captions and how they are grouped together) was bad and redid that which made a lot of changes necessary.

Maybe it's time to redo things so they are on the same server and then these cors things won't come up at all - though https may be on the todo list.

Sorry for the tldr;
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-25-2018 , 12:37 AM
Cors and https have like nothing to do with each other. Cors is some stupid browser safety measure. You are on the right course but it's hard to diagnose in text snippets only. If it's free to open source pop it in github
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-25-2018 , 12:41 AM
Quote:
Originally Posted by suzzer99
micro, if you're still struggling and want to do a coding session tomorrow lmk.

I was very close to going to Hollywood Park for the Friday night tourney and was going to text you. But then several hours on the couch set in. Hustler has some weird tourney going on right now that I don't fully understand but looks interesting.
Yeah, that'd be cool. I'm generally free. Manhattan Beach Library and Coffee Connection in Culver City are my two offices, but anywhere is fine.

I expect to be struggling somewhat often for quite a while, but I'm also making lots of progress.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-25-2018 , 12:48 AM
Quote:
Originally Posted by PJo336
Cors and https have like nothing to do with each other. Cors is some stupid browser safety measure. You are on the right course but it's hard to diagnose in text snippets only. If it's free to open source pop it in github
I'll expose myself like that soon. It's on github now, but there's something else up there that has other stuff for someone else that I can't really publish, but that's coming off soon and since I don't pay it's all public.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-25-2018 , 12:51 AM
I also started the html/css stuff with a bootstrap thing, but 5000 lines of css (whether I'm looking at it or not) in there kind of makes me sick. I'm stripping that out too and working on getting it work with just what's necessary.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-25-2018 , 01:00 AM
Bootstrap is a good start imo for small/medium apps - even if it's a bit cumbersome.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-25-2018 , 01:58 AM
Quote:
Originally Posted by PJo336
Cors and https have like nothing to do with each other. Cors is some stupid browser safety measure. You are on the right course but it's hard to diagnose in text snippets only. If it's free to open source pop it in github
This.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-25-2018 , 05:31 PM
I vaguely remember having an issue with this a few years ago where our page was https and api calls were not. Worked fine in firefox but chrome puked. Error message was something to do with cors and took a lot of googling to figure out. Worked fine on older versions of chrome but not on a newer version.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-25-2018 , 08:34 PM
Chrome is more picky about OPTIONS request (or used to be).
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-25-2018 , 10:01 PM
Quote:
Originally Posted by suzzer99
Chrome is more picky about OPTIONS request (or used to be).
The standard is not very clear on some aspects, and/or the implementation is not very consistent.

The basic idea of CORS is that the server should "agree" that a client is allowed to access it' APIs, *unless* the request is deemed to be "simple"

simple means
* GET/HEAD/POST
* no extra headers except some basics the browser always adds
* POSTed data can be form data, or text/plain but not JSON, etc
uh, there may be others. I think that if client/server use the same server/port then this is all moot.

My supposition is that for whatever reason, you don't actually have CORS working on your node server, or not working reliably/consistently. I don't know anything about node. I would guess that some of your requests qualify differently to chrome and firefox regarding whether they are "simple."
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-26-2018 , 09:08 PM
Senior dev and junior dev pair progamming:

Senior: Oh no, what have you done?

Junior: What? I just minimized the window to see what's behind...

Senior: Never minimize a window on a Mac. Now it's gone forever.

Junior: What? I can just select it from the Window menu like this-- wait, why did nothing happen?

Senior: uh huh

Junior: Well I can pick Select All Windows from the taskbar icon-- wait, I can see a thumbnail of my window now, but I can't actually click it. It's like my Mac is teasing me. What is Show All Windows actually supposed to do?

Senior: No one knows.

Junior: So reboot?

Senior: It's the only way to be sure.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-26-2018 , 10:07 PM
Had my last interview today, at a large fairly well-known tech co. I had the joy of bombing the **** out of a question harder than I ever have before - it was a system design question, about designing a system that would serve as a document repository and allow you to query for certain words and get results of which documents have those words in them, on the scale of having petabytes of data.

Discussing more to get a sense of the details she was interested in, we're talking about like, how do you partition the database? Do you use a cache? So basically, an entire hour of going into the details of a type of problem I have never, ever worked on before.

I was up front about, uh, hey, so building up distributed systems isn't a class of problems I've actually worked on before, but maybe I can kinda talk about approaching this problem at a smaller scale? And kinda worked my way through that, but still, it was bad. It felt like doing an hour-long interview in Lisp or something.

(and I should add, this wasn't interviewing for a role that requires this sort of thing, this is a place where you interview for the company, and then get matched with a team)


Anyway, hopefully that isn't disqualifying. I mean, there's lots of work you can do in software that involves actually writing code that does stuff as opposed to designing petabyte-scale systems, and I'd hope this company has a few spots available for the former kind of role. If not, oh well.



After getting home, had a call w/ a recruiter from the other (not Desirable Bay Area Megaco, but the other place I interviewed) company whose interview I passed with offer details. This offer came from them unprompted, in the sense that I never told them current or desired salary info, so I still have room to negotiate from here. Pretty happy with the details for an opening round:

Base: same as I currently make (which, again, I did not disclose to them)
Bonus: 50k/yr if performance review is satisfactory (current employer: does not give bonuses)
RSU: 200k, typical 4 year vest

The one downside: company is private. I think they are more viable and more likely to have some sort of liquidity event compared to my current employer, so the RSU doesn't feel as much like paper money as my current stock options do. And it's 50k more than I currently make in cash alone, so that's sweet. And once I have an offer from DBAM (still going through team matching) I'll have even more leverage to negotiate.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-26-2018 , 10:13 PM
What happened to Desirable Bay Area Megaco?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
11-26-2018 , 10:23 PM
Still going through team matching, I think I have another team call tomorrow. Their process is quite slow.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote

      
m