/wdg/ - Web Development General

>258 days till Christmas

Previous thread: >Beginner Roadmap and Overview
github.com/kamranahmedse/developer-roadmap
youtube.com/watch?v=UnTQVlqmDQ0

>Free beginner resources to get started
Get a good understanding of HTML, CSS and JavaScript.
developer.mozilla.org/en-US/docs/Learn - a good introduction to HTML/CSS/JS and Node.js or Django
freecodecamp.org - curriculum including HTML/CSS/JS, React, Node.js, Express, and MongoDB
javascript.info - curriculum providing a strong basis in JavaScript

>Further learning resources and documentation
developer.mozilla.org/en-US/docs/Web - excellent documentation for HTML, CSS & JS
hackr.io - crowdsourced collection of tutorials from across the web for learning languages and libraries (ignore sponsored stuff, look at upvotes)
learnxinyminutes.com - quick reference sheets for the syntax of many different languages (generally not sufficient on their own for learning something, but very helpful)
pastebin.com/gfBPg24A - Everything PHP

>Asking questions
jsfiddle.net - Use this and post a link, if you need help with your HTML/CSS/JS
3v4l.org/ - Use this and post a link, if you need help with PHP/HackLang

Attached: wdg_seasons_greetings_2.jpg (1280x720, 176K)

Other urls found in this thread:

vim.rtorr.com/
github.com/symfony/demo
pastebin.com/crm4jyzz
dev.to/mattsparks/building-a-php-framework-part-1---why-seriously-why-3f7g
site.com/me/threads
site.com/api/threads?username={session.username},
styled-components.com/
emotion.sh/docs/introduction
openclassrooms.com/en/courses/3619856-developpez-votre-site-web-avec-le-framework-symfony
twitter.com/NSFWRedditVideo

where is thephpguy i miss him.

Any advice on using a vuex store in a js file within a methods folder?

vim.rtorr.com/
I was thinking the same the other day, kinda shameful to miss a namefag though, but other than being a namefag he was pretty cool

Attached: vim_cheatsheet[2].png (1913x1353, 1.77M)

what's a methods folder?
namefagging is bad form though

yah he was a pretty cool guy.

so the methods folder for a vue file contains javascript functions to be used by that .vue file. I am trying to make a function that is triggered when the state of an object changes in the store

how many large methods does your component have, that you have to extract it into its own file, instead of keeping it in the .vue sfc?

Though you should be able to just import the store in any JS file and directly access state, getters, etc. without issues I think.

I don't know if you are talking about me, but PHP pro here.
What do you guys want to know ?

Attached: 51bae2045c8e2b5d51665686b3e2fc6e.jpg (720x624, 34K)

Someone told me storing my 3rd party api credentials in a config file ignored by git is a bad idea. What should I be doing? Docker secrets? Environment variables? I don't even totally understand how environment variables are any better, and Docker is a choice I'm not ready to make unless I have to. Is there anything else I should know about this stuff before making a decision that I haven't touched on yet?

thoughts on laravel.
organizing vanilla php code? (view and logic)

Just stumbled upon Blackbox, git-secret, and git-crypt. Are any of these commonly used solutions? What's most popular in 2019?

Laravel is just a bloated and watered down version of Symfony.

Almost all of the PHP frameworks stole the RoR file's organization. It has been like that for more than a decade now, and it's not going to change, even front-end frameworks (React, Angular and other zoomer's shit) use this file structure now.
Namely : a folder for your controllers, a folder for your services, and a folder for your models, and a folder for your static assets, and also a model for your views.
The golden rule is: 'Thin controllers, fat models'.
Pust most of your logic in your models and services.
Just use your controllers to declare your routes.

Attached: a0d5c09918d8e99fb5f0fd8d7c054d99.jpg (671x720, 92K)

why is it a bad idea? can you explain. is that what everyone do.

Can anyone explain me how cron works?
More specifically:
>which language does it run on?
>can it run scripts on languages such as python, C or javascript?
>is it possilble (and not a bad practice) to constantly (15min frequency) query a database and write some of it's data on files?
pls no bully I never messed with cron before

any example project i can look at?

This is just a 'bad practice' from a purist basedboy POV.
If you are developing alone or in a small firm (and if you don't host your git repos in the cloud), just put everything in the git folder.
It's much more convenient for your and your CI pipeline.

Attached: b859c91609d0bef4f7b9fc8c9c679aa6.jpg (480x960, 51K)

Yes, the Symfony Demo App, which is the reference and is almost updated daily :
github.com/symfony/demo

Attached: 27e10c87b1e02740c5a7da163deb81ac.jpg (1080x1331, 264K)

not talking about you bro, we're talking about a namefag, but non namefagging PHP pros are better imo

need help

I'm trying to understand dynamic content update through Ajax, trying to integrate it to one of the forms I'm building on my site

I've made a bit of progress so far but I can't get it to work yet, there's many examples out there but none explain how each piece of the code works or where it should point to, so I kind of worked it all up through context

here's the code

pastebin.com/crm4jyzz

what am I missing?

thank you.
though i was asking about a vanilla php project without any framework.

>pic
>that is what we call a boomer today
>I'm one then

Oh, my bad.
I don't know about the best vanilla PHP projects out there.

I remember building a micro-framework from scratch during my master degree, and it taught me all I needed to known.
Try this : dev.to/mattsparks/building-a-php-framework-part-1---why-seriously-why-3f7g

Once you've been down the rabit hole and you roughly know how framework are built, and you have a good PHP level, you can start learning a framework if your aim is to be employed.

Note that I'm telling you to learn/use frameworks, cause once you've organized your files, you'll be reinventing the wheel, and you'll be, consciously or not, building your own framework :)

Attached: b915e6fbd549daa92bb98a5f71569832.jpg (480x640, 47K)

There is no need for jQuery in the current year.
What's not working?

thanks user
i will look into that.
what framework do you prefer?

first dropdown works

second dropdown doesn't update based on the first's choice, which is most likely an issue on the script

that's pretty much it, I searched up a bit and Ajax seemed like the most common solution for this but still, can't get it to work and don't know much about this type of function

You are saying it's not working but aren't giving any helpful info.
any errors in the console, does the success function get called, returned value of the ajax get, etc.

I'm not big on the front end part of it, I know for a fact that the HTML and PHP pages work correctly (aside from the "productorInfo($_GET['mainid']);" on the second one, which may be a clue), the issue has to be related to the script or the second tag, but I've no idea how to find it

that's why I'm here, I don't understand much of this and I can't find many useful breakdowns of this stuff that apply to my use case

So, I'm about to graduate and have been looking for a job so I don't go out unemployed, I have about a year's worth of experience with various web technologies but looking for a dev job has been hard, and I'm supposedly in one of the best cities in this third world country to get a dev job, my problem is they either pay very little (below national median) or pay well but require more experience/ an internship period, which I swore on my life to never again take, being an unpaid intern is the worst possible thing, and the thing is I recently got an offer for a tech support position, which pays better than some of the dev jobs I've applied for but it's tech support, and I'm wondering whether it would be a good idea to take the job, at least temporarily or keep going for a dev job and building up more experience, would having tech support in my CV further my career or would it just be a detriment in the long run? I need some advice from the oldfags and sages itt.
/blog

Any examples for well written APIs in Go/Rust?

In addition to the success callback I would also add an error callback and simply do a console.log inside both to figure out what's going on.

>JAM Stack

Attached: 1478078694836.jpg (486x341, 42K)

What's the best way to make simple UI flow in React? For something like an audio player widget which has several flows between states like playing, paused, connecting etc..
currently I have a simple state machine with a switch statement in the render function that displays the correct buttons depending on the current state (STATE_INITIAL, STATE_PLAYING, STATE PAUSED..)
and then in my react state I have {screenState : STATE_INITIAL} etc
is this reasonable or is there some hip and new way of doing things like this?

Does anyone know if i can create a command in Heroku that will reset the database every 2 or 3 days? I want to post there a portfolio full-stack site but i don't want for people too add random shit to it when i give away the link in my CV, so basically a full restart every 2-3 days, doable?

Attached: 131342535.jpg (1106x1012, 70K)

Why not make it directly in the database?

i am using the postgres heroku gives you for free, can you even configure it?

Can someone give me a quick rundown on Angular and React? I tried both and I find React more intuitive. Do they have different use cases or can you use both of them? What are the different uses for them and is one better than the other? And how easy is it to use React with a backend framework like Django?

No idea, sorry, I thought you were using an actual database, where you can basically do backups and then set a job to restore that backup.

not an expert but: yes it can run any script in any language, yes that sounds about what cron is for, any repetitive task

>in this third world country
can't you work online for richer countries
otherwise suck it up and take the low paying dev job, and then progress from there? if you really wanna be a dev
tech support isn't going to increase your skills

So I've got a form I'm sending via ajax, I want to add a password to it, I'll be hashing and salting the password on the back-end. Do I need to do anything special on the front end to send it securely?

use TLS.

I do that, other than that is it safe to just do document.getElementById.value() and send that?

Well, not literally like your example.
But yes, you just send it.

I've explored that possibility a little bit but haven't had much luck finding remote positions for junior devs, or at least not web related, will search a bit more in that front.

set a cron job to run the seed command every day or something, would be pretty simple to just run "heroku run db:seed" or whatever the command is depending on your stack.

IDK if you can run that from inside the app itself, but you could also just write a function to delete everything and re-seed it, little bit more effort though

page 9 bump

Attached: 1547650544923.jpg (605x454, 102K)

>notepad++
>php
>jquery
name a comfier stack

>notepad++
vscode + prettier for auto code formatting and actual ricing
>php
this is alright
>jquery
vanilla js or use an actual view framework (react, vue, angular)

is this 2008?

One of his last posts was that he's moving jobs

>Write PHP
>Go homeless

Is Ruby the Mac of programming?

No, python is more the ruby of programming, you have to do everything the python way, it's slow as shit, but people use it for the ecosystem (literally just a shit load of c++ bindings) and not even because of the language.

Ruby is all about choice, it's not the fastest but you can have whatever you want, and you can do the same thing in 20 different ways if you like. It's more like the linux of programming ironically

Yup, one more shitty zoomer's meme

Attached: f2c8dbe5cc65231d7b9a2bf3db43d6ba.jpg (960x960, 89K)

Use a cron job which will run a script doing that

Attached: 83745acbf8aba0c019e42b1ff96640d4.png (654x655, 182K)

I have a web app. I need to handle a password sent via a form properly and securely. Should I send the password in plaintext over https and then hash it or use javascript to hash it in browser and then send it to my server?

Attached: 1549203223641.jpg (460x659, 50K)

>plaintext over https
>https is encypted.. full tcp/ip inlcuding form data
its n ot really plain text

See
If you're sending it over HTTPS, it's fine.

Make your server be responsible for the hashing. Make sure you use an algorithm that applies a salt, like bcrypt.

You should send it over HTTPS. It's not technically in plaintext, since it's encrypted by the TLS. In any case, yeah, the server must receive the plaintext version of the password in order to verify/store it, and HTTPS is perfectly secure (as long as the user's device is secure).

Hashing on the client side in place of the server side is actually insecure, because suppose your password table leaked: an attacker would be able to simply send a hash out of the table to your server to log in as any user. That would defeat the whole point of storing hashed passwords in the first place.

pls respond

I didn't think it was a problem either, especially if I had a signed certificate, just want some input from others.

your web apps going to get hacked if your this noob

Attached: 1540108874458.png (658x662, 59K)

>an attacker would be able to simply send a hash out of the table to your server to log in as any user.
That makes a lot of sense actually.

no u

Never hash client side, thats ridiculous because now your password is the hash, not the password itself. HTTPS is designed for this,.

^Those anons are right, user.
Let HTTPS do it's job.

Attached: 5c893a1babe9e7bf477420cabdcef012.jpg (360x363, 34K)

What's the less taxing way of looking things up with a one to one relationship in django?
MyObject.objects.filter(user=request.user)
or should I make a custom user and go
MyUser.MyObject

Is Mac the Ruby of operating systems?

If I am a meme UIX designer, where could I find available full-stack developers to look at their portfolios and partner with them afterward? Is there such a place?

how can I include actual CSS within the React file. Like, not in another file that's imported, but in the same file I write the component in (and using regular CSS not javascript objects)

who here switched from web dev to mobile dev?

I feel like this is where the real magic is happening.

also, what language should I start learning to enter mobile dev?

Attached: 11-drake-hotline-bling.w710.h473.2x.jpg (1420x946, 70K)

In my meme full-stack sites i have some routes that don't have their counterpart on the client side, what i mean

>users clicks load mythreads
>It sends a request to the backend on a route called /getmythreads or some shit
>but there is no such url on the front-end

So if someone had the token and wrote on the browser /getmythreads he would get the json with the threads he created, is this okay or should i fix this?

Attached: 1541816120850.jpg (780x846, 53K)

Why arent your API and frontend logic on separate domains

Its a heroku website

I dont know what that is or why it prevents you from doing subdomains, but alternatively just do

>User navigates to site.com/me/threads or whatever you want
>Make api call to site.com/api/threads?username={session.username}, fetch and display data

I just added more routes on the front end (so pages) instead of only queries to page, it werks

I'm assuming this is with some kind of SPA client side routing, if you do client side requests to some API all the payloads and paths are readable to anyone who can open the browser's dev tools. What secrets you can put in the payloads is a question of your authentication scheme.

I think almost no one itt uses Angular. For those who can freely choose their frontend library React (and Vue) are way more popular.
Their use case is pretty much the same and you can create the exact same application in each of them.

Regarding using React with Django.
If you keep your frontend decoupled as static files, so it only interacts with the backend via API calls, then it makes no difference for the frontend which backend you use.

If you mean component scoped css, then google 'React component css' or something like that and you will certainly find something.
I think for React styled components is the most popular choice.
styled-components.com/
But I also read Emotion being mentioned a few times now
emotion.sh/docs/introduction
>routes that don't have their counterpart on the client side
and what stack is that? If it's an SPA like the other user assumed, then the backend API url should have nothing to do with the client route. You should be able to set them arbitrarily to anything you want.
I can't even think of a scenario, where you fetch something from a backend URL and then also for some reason require the frontend to navigate to the same URL separately.

>I can't even think of a scenario, where you fetch something from a backend URL and then also for some reason require the frontend to navigate to the same URL separately.
What? Isn't this how it works
>React has page /todos
>when you enter it React automatically asks the backend for the /todos route to retrieve todos

Attached: 1540029884672.jpg (399x400, 13K)

how do i make the page view counter? literally something what youtube has?

>What? Isn't this how it works
This is how it works with usual SPA client side routing:
> you request /todos
>server is instead configured to serve index.html (or whatever your React root is) from every route within a certain path/paths, usually / or /app or something
>your browser location now has /todos which is readable from JavaScript, and the React or other client side router gives you the view/component you have routed as /todos
>completely unrelated to this there's some other todos API route, perhaps /api/todos or /todos with some special header (sounds insane but I'm sure someone is doing this) a React component might use

Client side routing and serving a single point from all routes is pretty much a hack. It can be hard to understand if you've never done it the traditional way. I recommend completely separating frontend and API/backend domains/paths to not be confused into thinking that they somehow need to match.

>store each IP address/device UID that connects to the website
>increment counter

you mean to tell me that youtube doesnt increment the views counter when i view the same video tomorrow or after re-oppening the browser? i get only 1 view contribution?

off course youtube have some other shit algo for counting view.

what would you use as a local server on win10?
currently runing homestead (vagrant virtualbox thing)
>inb4 dualboot

Attached: 1475966214702.jpg (1017x579, 330K)

Anything in Docker

but basically only 1 view per user forever?

my dream stack tbqh

>React automatically asks
React doesn't really automatically do anything. You still manually specified that action I guess?
If you have an SPA and the user navigates to /todos, then in the Todo Component you probably have some API call, that will fetch the data you want to render. What your client route is called isn't relevant at all. You could just as well call it /myAwesomeTaskList and then have the component send a GET request to /todos?date=today&done=false (just an example)

It's not like every client route has a corresponding backend API route.

>What? Isn't this how it works
I was more confused by you saying that you click a button to send a request to a URL on the backend and then separately try to navigate to a client route, which doesn't exist?

I'm more of a Symfony guy,
but honestly, don 't be opinionated.
Just pick the one you feel more comfortable with

Attached: 1505987672189694.jpg (740x555, 119K)

i don't know it uses ip for that. there much more to it as dynamic ip is much popular

i was trying laravel felt like brainlet as everything files were generated via artisan.
trying symfony right now will report back.

Symfony is more complicated than Laravel (because Laravel is built from symfony) but you will learn a lot more.
Just follow a good tutorial.

Attached: grasshopper.jpg (499x442, 31K)

right now reading the official doc. any other resource you recommend?

I used this course : openclassrooms.com/en/courses/3619856-developpez-votre-site-web-avec-le-framework-symfony

... which is excellent ... Only if you are/speak French :/.

Otherwise, I don't know about the good resources in English, sorry.
But I guess you could find some good ones by Googling

Attached: 45e06b112a6cf9.08312954frogview-gallery.jpg (336x585, 26K)

> French
:(
thanks user for replying. offical doc. seems nice

It's pretty nice most of the time yes, but sometimes it can be cryptic.
Don't hesistate to ask me questions here if you need.
I'm lurking at /wdg/ threads for most of the day.

Attached: pepsiads2.jpg (450x216, 36K)

once again thanks user.

Attached: happy.jpg (1435x992, 225K)

morning all
this escape func is secure right

str.replace(/([*.`~\\|:&#-])/g, "\\$1")

pray for no xss today

use a templating engine.