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
Munkeymon
Aug 14, 2003

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



You could always load up the page in Phantom or Slimer and dump the body to a file. Might be using a cannon to kill a mosquito, though.

Adbot
ADBOT LOVES YOU

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Server side rendering of a SPA for performance and SEO is pretty legit, not a big deal, and a thing that people should do.

Unfortunately, you've got to use icky tools to do it, but man sometimes people just need to do their job and do the things that need to be done.

tracecomplete
Feb 26, 2017

Bruegels Fuckbooks posted:

i'm almost inclined to say that if you want to render SPA on the server, you could like, consider not making an SPA. SPA is a specific technical term meaning "bloated website that uses a twenty megabyte of js framework to solve the challenging technical problem of making it so if the data in your model changes, your view should also update."
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..

TheFluff
Dec 13, 2006

FRIENDS, LISTEN TO ME
I AM A SEAGULL
OF WEALTH AND TASTE
GUI programming involves managing a lot of state, and managing a lot of state is a loving pain in the rear end - it's hard to test, easy to gently caress up, and easy to make completely unmaintainable, with weird dependencies all over the place. React tries to encourage you to keep state as local as possible and to tell it what you want the end result to look like and not so much about how to get there. It's a step in the right direction, I think, but that poo poo is still really hard to get right.

Munkeymon
Aug 14, 2003

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



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

My last placement as a consultant was at a place that based their not-really-a-SPA on Backbone, which is ~7kb minified. The bundle was still 1.1mb because all the templates were actually compiled from a bespoke internal language to JS and there was data transformation code out the wazoo for every single object because the front-end team just had to eat poo poo and deal with whatever the (mostly remote) back-end team delivered in terms of JSON structures, which had minified property names. To minimize bandwidth used.

I hear they lost their biggest client recently and wish them just the best of luck, but the point is that people find a way.

tracecomplete
Feb 26, 2017

That sounds like less an indictment of SPAs and more of dysfunctional work environments and developers making bad decisions all on their own. I have yet to see a coherently presented argument that React (or even Vue or Angular, neither of which I'm a fan of) creates or even really encourages either of those factors.

Munkeymon
Aug 14, 2003

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



AFashionableHat posted:

That sounds like less an indictment of SPAs and more of dysfunctional work environments and developers making bad decisions all on their own. I have yet to see a coherently presented argument that React (or even Vue or Angular, neither of which I'm a fan of) creates or even really encourages either of those factors.

If they had used React and JSX instead of their homebrew, it wouldn't have been a whole lot better because of all the other poo poo going on, but I suspect/hope that was an outlier and wanted to point out that horror stories aren't all fiction.

mila kunis
Jun 10, 2011

tekz posted:

The functional programming thread seems to be closed, so I thought i'd ask here. Is there a mooc/any kind of resource that's as good at explaining it as Functional programming in Scala but in another language? I don't want to deal with installing Eclipse/the JVM and all that crap, just learn the fundamental principles.

Answering my own question from before, but I found this fantastic resource here (using JS): https://mostly-adequate.gitbooks.io/mostly-adequate-guide/

I now actually understand what monads are, which is cool. Anyone know good js repos out there to go through to see how people apply functional stuff in practice?

mila kunis
Jun 10, 2011

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

100%. ALSO, if you do code splitting right you're going to get only the parts of the bundle you need and reduce initial load considerably. Admittedly, webpack and other tools are a pain to use, but done right I think they remove all the major drawbacks of SPAs.

Like are there any issues other than bundle size/initial load with going that route? If it's a solved problem, why would you go any other way.

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.

spiritual bypass
Feb 19, 2008

Grimey Drawer
Reason+React ends up being like 1mb uncompressed for a simple demo application, which just isn't acceptable to me. The language seems good otherwise. I've been enjoying Elm recently for similar functionality with similar safety benefits. The "maybe" approach to enforce null handling is superb.

LOOK I AM A TURTLE
May 22, 2003

"I'm actually a tortoise."
Grimey Drawer
If you create a new project with Angular CLI 6.0.7 and do a production build without changing anything, the output size is currently a bit over 200 KB of JS, of which roughly 60 KB is polyfills. That seems pretty decent to me, but maybe I've become part of the webdev Borg at this point.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
The minimal hello world sample is reasonable sized with basically all modern SPA frameworks. That doesn't really say anything about the reasonableness of actual applications using them.

baby puzzle
Jun 3, 2011

I'll Sequence your Storm.
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.

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe
Is there any particular reason you'd rather use a build process than just write a shell script or something?

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

baby puzzle
Jun 3, 2011

I'll Sequence your Storm.

TooMuchAbstraction posted:

Is there any particular reason you'd rather use a build process than just write a shell script or something?

Well, I want something to handle dependencies and such, so I can have an incremental build. I can do that with a batch file? I didn't really think of doing it that way.

downout
Jul 6, 2009

I had a complicated build process like that and wrote an application to do it. Really easier to modify and maintain.

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe
You'd have to handle the "does this file already exist? If not, create it" stuff by hand. That's not exactly complicated logic though.

I'm not saying build tools are the wrong tool for this job, it really depends on your scope and the complexity of what you're trying to accomplish, I think. It's just worth thinking about whether a more general-purpose tool could do the job more easily.

nielsm
Jun 1, 2009



You want native Windows things? PowerShell DSC might be usable for this. Or MSBuild!

(DSC is not a build tool, it's a machine configuration management tool. Setting up MSBuild rules that work right requires a lot of patience, reading, and XML.)

Newf
Feb 14, 2006
I appreciate hacky sack on a much deeper level than you.
Any suggestions on a starting point (library, command-line tool) for a program that outputs 12 cropped chessboard images from the following?

nielsm
Jun 1, 2009



How precise do you want it to be? Do you need to correct rotation/perspective from the scan?

If you can assume all input images have almost identical positions some very simple ImageMagick commandlines could probably do it, just extract the same pixel coordinates from every input.

Newf
Feb 14, 2006
I appreciate hacky sack on a much deeper level than you.

nielsm posted:

How precise do you want it to be? Do you need to correct rotation/perspective from the scan?

If you can assume all input images have almost identical positions some very simple ImageMagick commandlines could probably do it, just extract the same pixel coordinates from every input.

I can assume the correct perspective / orientation on each scan, but the scans are all placed 'by hand' and probably can't be made reliable enough for specific pixel ranges to work.

e: I need it to be a pretty precise crop, because step 2 is to chop those images into 64 individual squares, which I intended to do via simple pixel ranges. The individual squares are then destined for a ML classification project (identifying pieces).

Newf fucked around with this message at 19:32 on Jun 2, 2018

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe
If they're all the same scale, then you can use an FFT convolution to get the offset of each image compared to some reference image. There'll be a little noise because of the different piece positions but the checkerboard pattern and the fold in the middle of the book should be the dominant signals.

I wouldn't be surprised if ImageMagick (a commandline image processing tool) has built-in utilities to find the offset for you.

EDIT: oh, just saw your edit. If you need individual squares then you're going to have to also precisely adjust rotation and scale of each image. I hope you like image processing. Once you get each board in its own image, you can find the transformation from that board to a reference board using an iterative method like Simplex, where the fitness function is the difference between the transformed image and the reference image, and the parameters being optimized are X/Y translation, rotation, and scale. Numpy and scipy have all the methods you need for this.

TooMuchAbstraction fucked around with this message at 19:38 on Jun 2, 2018

Newf
Feb 14, 2006
I appreciate hacky sack on a much deeper level than you.
Making some progress with imagemagick and its canny edge detection algo. Basic loop goes like this:

- edge-detect the image, resulting in a 1-bit black and white img
- starting from the top right corner, locate the closest white pixel (reliably the top right corner of the top right board). Note this coordinate c1
- from c1:
- move southwest 730 pixels from c1 (hard coded based on the board diagonals being 670 pixels) then look for the closest white pixel, c3
- using these corners, calculate the coordinates of the other corners of a square, c2 and c4
- use these coordinates to pull a square from the source image
- repeat from coordinates calculated relative to c1 in order to find top-right corners of other squares

ulmont
Sep 15, 2010

IF I EVER MISS VOTING IN AN ELECTION (EVEN AMERICAN IDOL) ,OR HAVE UNPAID PARKING TICKETS, PLEASE TAKE AWAY MY FRANCHISE

Newf posted:

Any suggestions on a starting point (library, command-line tool) for a program that outputs 12 cropped chessboard images from the following?

Google Chess OCR and play with the library results.

Here’s one possible starting point: https://github.com/npcardoso/chessocr

mystes
May 31, 2006

I have a feeling there's probably sort of really simple way to do this using opencv contour hierarchy stuff, but I don't know opencv well enough to actually know how try to implement that.

Sad Panda
Sep 22, 2004

I'm a Sad Panda.
I'm on a Mac and recently moved to VS Code from Sublime Text. It seems pretty but a bit confusing. The option currently confusing me the most is that while for example I have a log file in the folder that my scripts are in /Users/sadpanda/Dropbox/Documents/Personal/Computer/Python/Own/betting/audit/debug.log

It will actually write to

/Users/obow/Dropbox/Documents/Personal/Computer/Python/debug.log

What? Why? And how can I stop this? I assume this is why when I tell it to open a file in a bit of code it tells me it can't find it. Infuriating.

csammis
Aug 26, 2003

Mental Institution
I don’t know all the proper names for settings in VScode but maybe check the working directory setting for your project? It’s probably setting the working directory to the project root when your code is assuming it’s the same as the script that’s executing. iirc Visual Studio has some challenges with that too.

yippee cahier
Mar 28, 2005

Sad Panda posted:

I'm on a Mac and recently moved to VS Code from Sublime Text. It seems pretty but a bit confusing. The option currently confusing me the most is that while for example I have a log file in the folder that my scripts are in /Users/sadpanda/Dropbox/Documents/Personal/Computer/Python/Own/betting/audit/debug.log

It will actually write to

/Users/obow/Dropbox/Documents/Personal/Computer/Python/debug.log

What? Why? And how can I stop this? I assume this is why when I tell it to open a file in a bit of code it tells me it can't find it. Infuriating.

What does os.getcwd() return?

Sad Panda
Sep 22, 2004

I'm a Sad Panda.

csammis posted:

I don’t know all the proper names for settings in VScode but maybe check the working directory setting for your project? It’s probably setting the working directory to the project root when your code is assuming it’s the same as the script that’s executing. iirc Visual Studio has some challenges with that too.

Thanks to both of you. It turns out that using Open Folder to open the root folder where I store my Python projects meant that it was saving things to there. Opening the folder of the project itself sorted that out, but honestly that seems a bit of a crappy solution. I don't see an option of setting the working directory to the same one as the file is in.

Having said that, that's an infinite amount better than my opinion on its source control. I'll completely admit that I've never used Git before, but this thing is loopy. On a fresh install, I opened the folder for my current project. Within 30 seconds the 'Source Control' thing is telling me that I have 5000 pending changes. I look in it and it's just read 5000 files from all over my laptop. I've looked around but can not for the life of me see an option to stop this. There's nothing by the way of intuitiveness about it and looking through the user settings for Git gives me nothing obvious at all.

There seems to be no obvious way to clear the list, and the only option that seemed to make any sense seemed to suggest it would delete all 5000 files from my laptop.

The Fool
Oct 16, 2003


Sad Panda posted:

Thanks to both of you. It turns out that using Open Folder to open the root folder where I store my Python projects meant that it was saving things to there. Opening the folder of the project itself sorted that out, but honestly that seems a bit of a crappy solution. I don't see an option of setting the working directory to the same one as the file is in.

Having said that, that's an infinite amount better than my opinion on its source control. I'll completely admit that I've never used Git before, but this thing is loopy. On a fresh install, I opened the folder for my current project. Within 30 seconds the 'Source Control' thing is telling me that I have 5000 pending changes. I look in it and it's just read 5000 files from all over my laptop. I've looked around but can not for the life of me see an option to stop this. There's nothing by the way of intuitiveness about it and looking through the user settings for Git gives me nothing obvious at all.

There seems to be no obvious way to clear the list, and the only option that seemed to make any sense seemed to suggest it would delete all 5000 files from my laptop.

I've never seen this behavior and I've been using the VSCode git integrations for a year now.

Did you initialize a repository, if so, what folder did you have open when you did that? Where is the .git folder located? You mentioned that you never used Git before, if you aren't worried about losing your history at this point, you can delete the .git folder and start over.

Munkeymon
Aug 14, 2003

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



Sad Panda posted:

Thanks to both of you. It turns out that using Open Folder to open the root folder where I store my Python projects meant that it was saving things to there. Opening the folder of the project itself sorted that out, but honestly that seems a bit of a crappy solution. I don't see an option of setting the working directory to the same one as the file is in.

Unless you're writing a command line tool, don't rely on the current working directory being anything in particular. Make a settings file, even if it's just another .py, and put full paths in there so you're never guessing where it's looking.

baka kaba
Jul 19, 2003

PLEASE ASK ME, THE SELF-PROFESSED NO #1 PAUL CATTERMOLE FAN IN THE SOMETHING AWFUL S-CLUB 7 MEGATHREAD, TO NAME A SINGLE SONG BY HIS EXCELLENT NU-METAL SIDE PROJECT, SKUA, AND IF I CAN'T PLEASE TELL ME TO
EAT SHIT

Sad Panda posted:

There seems to be no obvious way to clear the list, and the only option that seemed to make any sense seemed to suggest it would delete all 5000 files from my laptop.

It will, it's stupid as hell and they refuse to change it (it's not how git itself works)

Git is great but the VS Code stuff integration is not, especially for a beginner

Sad Panda
Sep 22, 2004

I'm a Sad Panda.

The Fool posted:

I've never seen this behavior and I've been using the VSCode git integrations for a year now.

Did you initialize a repository, if so, what folder did you have open when you did that? Where is the .git folder located? You mentioned that you never used Git before, if you aren't worried about losing your history at this point, you can delete the .git folder and start over.

Not knowingly and I can not see a single option to find where the .git folder is. I've searched on my Mac using EasyFind for it and there's nothing. I've not got any history to lose.

If I open one folder in my Dropbox that contains a project, the source control looks normal with 33 files. If I open a different one, it looks like the attached pic. Surprisingly enough my Trash is not part of my Dropbox, let alone the Python project I've got added.

Only registered members can see post attachments!

Sad Panda
Sep 22, 2004

I'm a Sad Panda.

Munkeymon posted:

Unless you're writing a command line tool, don't rely on the current working directory being anything in particular. Make a settings file, even if it's just another .py, and put full paths in there so you're never guessing where it's looking.

Honestly, no idea how to do that either. Is there no way of telling it, the cwd is where you are? When I was running things through Sublime Text it'd work perfectly like that and if I say logging = /logs/audit.log, it'll put it in the logs subdirectory relative to that file.

The Fool
Oct 16, 2003


Sad Panda posted:

Not knowingly and I can not see a single option to find where the .git folder is. I've searched on my Mac using EasyFind for it and there's nothing. I've not got any history to lose.

If I open one folder in my Dropbox that contains a project, the source control looks normal with 33 files. If I open a different one, it looks like the attached pic. Surprisingly enough my Trash is not part of my Dropbox, let alone the Python project I've got added.



If you didn't initialize a repository, it means VSCode saw one that already existed. Are you using "Open Folder" ? It should be looking for a ".git" folder inside the folder you are trying to open. The .git folder is a hidden folder, and while I don't have a mac handy right now, there's probably a checkbox somewhere to add hidden files/folders to your search.

Sad Panda
Sep 22, 2004

I'm a Sad Panda.

The Fool posted:

If you didn't initialize a repository, it means VSCode saw one that already existed. Are you using "Open Folder" ? It should be looking for a ".git" folder inside the folder you are trying to open. The .git folder is a hidden folder, and while I don't have a mac handy right now, there's probably a checkbox somewhere to add hidden files/folders to your search.

Yes, I used Open Folder. I turned on show hidden files/folders. The only hidden folder in that one with all the files listed is .vscode which includes settings.json. It's not the most interesting file.

quote:

{
"git.ignoreLimitWarning": true
}


I copied the .git folder from my project that displays git normally to the project with 5000 and it's fixed it. Outside of that, the only hidden .git folders I can find are just from having Homebrew installed.

Thanks for your help. Hopefully the next time I open a folder it won't give me the 5000 file setting again.

baka kaba
Jul 19, 2003

PLEASE ASK ME, THE SELF-PROFESSED NO #1 PAUL CATTERMOLE FAN IN THE SOMETHING AWFUL S-CLUB 7 MEGATHREAD, TO NAME A SINGLE SONG BY HIS EXCELLENT NU-METAL SIDE PROJECT, SKUA, AND IF I CAN'T PLEASE TELL ME TO
EAT SHIT

On Windows, if I do Open Folder and pick one, and then go to the Git pane, there's nothing there (because I don't have a .git repo folder in there yet). If I click Initialise Repo or whatever, it asks me to pick my base folder - it starts in the currently open one, but I can navigate and select another. When I do that, it creates the repo and lists all that folder's contents as untracked. From your list pic, it looks like the repo is in your home dir? Everything seems to be under /Users/you or ~

Adbot
ADBOT LOVES YOU

Boris Galerkin
Dec 17, 2011

I don't understand why I can't harass people online. Seriously, somebody please explain why I shouldn't be allowed to stalk others on social media!
I have a question about logging practices. Basically what's the "best practice" placement of logging outputs? Here's a silly example

code:
# main is the executable called from the script
def main():
    logger.debug('calling do_something')
    do_something()
    logger.debug('do_something successful')

# random library function
def do_something():
    logger.debug('doing something')
    print('Hello world')
    logger.debug('something has been done')
Silly example aside is it considered better practice to write to a log outside of the function call but inside the main executable, inside the library function, or in both?

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