/wdg/ - Web Development General

Previous thread
>Discord
discord.gg/wdg

>IRC Channel
#Sup Forumswdg @ irc.rizon.net
Web client: rizon.net/chat

>Learning material
codecademy.com/
bento.io/
programming-motherfucker.com/
github.com/vhf/free-programming-books/blob/master/free-programming-books.md
theodinproject.com/
freecodecamp.com/
w3schools.com/
developer.mozilla.org/
codewars.com/

>Useful Youtube channels
derekbanas
thenewboston
learncodeacademy
funfunfunction
computerphile
codingrainbow

>Frontend development
github.com/dypsilon/frontend-dev-bookmarks

>Backend development
en.wikipedia.org/wiki/Comparison_of_web_application_frameworks
[Gist] backendDevelopmentBookmarks.md

>Useful tools
pastebin.com/q5nB1Npt/ (embed)
libraries.io/ - Discover new open source libraries, modules and frameworks and keep track of ones you depend upon.
developer.mozilla.org/en-US/docs/Web - Guides for HTML, CSS, JS, Web APIs & more.
programmableweb.com/ - List of public APIs

>NEET guide to web dev employment
pastebin.com/4YeJAUbT/ (embed)

>How to get started
pastebin.com/pDT82mQS (embed)
pastebin.com/AL6j7GEE (embed)

>cheap vps hosting in most western locations
lowendbox.com
digitalocean.com/
linode.com/
heroku.com/
leaseweb.com

Other urls found in this thread:

giveawayhopper.com/
marvelousga.com/
simplo.gg
stackoverflow.com/questions/418503/common-header-footer-with-static-html
codepen.io/user/pen/evLPJM
virtualpostmail.com/
angularjs.blogspot.com/2017/03/angular-400-now-available.html
youtube.com/watch?v=b2F-DItXtZs
secure.php.net/manual/en/class.pdo.php
shapeshed.com/creating-a-basic-site-with-node-and-express/
facebook.github.io/react/blog/2013/06/05/why-react.html
phpdelusions.net/pdo/mysqli_comparison
twitter.com/NSFWRedditVideo

First for PHP

What's the best memorystore to use for session management with node.js? Redis? I've previously just used noSQL databases as my "store" before and have yet to have any performance problems with them. Is redis just a meme?

trips for truth

How well did I implement prepared statements? Am I protected from SQL injections now?

Redis is fast as fuck and very useful for caching.

$result should be $r

at what point do you see a performance gain? I've got two sites that average 10k+ users a day and all they are is dedicated boxes, never have any performance problems. I was just looking at redis in case they get any larger.

>be me
>looking to hire web dev
>contact web dev
>tell him i want to buy the script which hes already sold to 3 other people
>giveawayhopper.com/
>marvelousga.com/
>simplo.gg
>tells me no he cant because it's unethical

seriously, what the fuck is up with web devs who actually give a shit about ethics, so what if a potential client wants you to clone a website, why do they give a shit so much? this fucking bothers me man...just take my fucking money and do what i want you to do

now have to go search for a poo in the loo web dev to do it

ps. how difficult is it to build a site similar to those i posted?

if any devs here can clone that script i'll gladly pay $100-$150 (that's how much the original creator vasco charged, hes not selling it any more)

Use prepared statements and parameterized queries. These are SQL statements that are sent to and parsed by the database server separately from any parameters. This way it is impossible for an attacker to inject malicious SQL.

You basically have two options to achieve this:

Using PDO (for any supported database driver):
$stmt = $pdo->prepare('SELECT * FROM employees WHERE name = :name');

$stmt->execute(array('name' => $name));

foreach ($stmt as $row) {
// do something with $row
}

Using MySQLi (for MySQL):
$stmt = $dbConnection->prepare('SELECT * FROM employees WHERE name = ?');
$stmt->bind_param('s', $name);

$stmt->execute();

$result = $stmt->get_result();
while ($row = $result->fetch_assoc()) {
// do something with $row
}


If you're connecting to a database other than MySQL, there is a driver-specific second option that you can refer to (e.g. pg_prepare() and pg_execute() for PostgreSQL). PDO is the universal option.

trivial

the only part that will take any time is making it look visually distinct.

>trivial

some people on reddit are quoting me $1000~ for something like this, fuck sakes

no wonder why people hire poo in the loo freelancers for this type of shit

the poo in loo will probably take your money and not deliver a working product,

you aren't paying for the difficulty for the engineer, you're paying for their hourly rate.

although people on reddit are probably bottom of the barrel retards

Depends on the site and how cacheable it is. Database is where most of the performance goes so any roundtrip to the DB avoided is a win, and if you can return cached responses without even connecting to the DB you're off to a good start.

10k over the span of a day isn't really in the area of needing a lot of caching although it can help with spikes.

If you have anonymous users it's probably easier to just enable nginx caching and set it to 5s or something.

they are logged in users, not anonymous.

Just cache what you can that's the same for everyone.

I am making a simple 10 or so page website, and for every page I am copy and pasting the header and the footer, and if I need to change either, I obviously need to go through every page and make the same change.

What is the sensible way of fixing this, I know it isn't right.

So xampp has PHP Version 5.6.28. Does that mean I don't have to do download a driver for PDO? Or do I still need to download a database-specific PDO driver?

what framework are you using? If you're doing MVC, there's a very easy way to do that. Just use a shared view or something like that.

What language are you using?

Oh sorry, It is just a HTML, CSS, JS site.

basic concept is like this
[header]
[display]
[footer]


You just swap out what's in display when the page is changed.

The specifics will depend on what language you're using, but what you basically want to do is create a 'header' file for all your common header stuff (logo, nav, shopping cart, whatever) and a 'footer' file if you need one, and simply call those files at the top and bottom of each of your templates.

There are more automated ways to do this if you use a framework, but it sounds like a simple site so start simple and embrace includes.

Oh, that's tricker. Includes are easy with server-side scripting. Have a read of this: stackoverflow.com/questions/418503/common-header-footer-with-static-html

I think what he's asking is for a templating engine for HTML.
Like in PHP where you can create one header file and one footer file, then include it on the pages where needed..


--regular HTML/PHP Code for each page.

A JS templating engine would do the trick for a static site, I think.

Sounds like a JS templating engine is the way to go, no need to add another language that I am not familiar with into the mix.

Cheers for the stack link

OhHereWeGo.jpg

What do you suggest if server side languages aren't an option?

Person asking about including 1 header and footer file in every page here, I saw some mention of Jade, a preprocessor, would that be easier and more "Compatible"?

You can make a simple sh/python/whatever "makefile" yourself to propagate your header and footer to your webpages when deploying. I ended up doing something like that a while ago iirc

tfw prototypes too hard to understand :c

Single page application, loading content using ajax

And where will that content come from?

From .html files
poo.html = contents of poo
loo.html = contents of loo

$('.poo-or-loo).load('poo.html');

My website is less than half the size of Sup Forums's javascript even when you load a 1024x1024 PNG

the fuck is up with that

You forgot to load the botnet in yours, my friend

Newjobfag here

Just finished my first day as a web developer

After orientation they parked me in front of a TV and had me watch six hours of Magento tutorials

Yee haw

I'm still writing my image board and just completed the thread rendering.

What do you think of the desgin? I don't want to totally copy Sup Forums but that simple old-era desgin is just comfy. The color scheme still sucks, I know.

What is it? Fake steam oauth? I'll do it for 5k

Oh fuck, of course. Yeah, do this

My first day they had me build my computer and install their Windows stack with no documentation. I wrote their documentation on my first 3 days.

Magento though. There's a place by me that's been looking for Magento PHP devs for over 2 years. 60k too. I don't know SOAP though so I couldn't pass their test.

Why are you using num_rows? Password verify works perfectly with glorious bcrypt.

do all modern browsers support flexbox?

>caniuse.com
search flexbox

Just use a static site generator like hugo or jekyll

Has anyone here actually done work remotely (not including Freelancer, Upwork, etc)? I'm trying to but I can't find shit. I've been applying for a year now and nothing, luckily I found something (shitty) locally that I can do for now.

>yank out a modal
>snap some excel file on it for import to db
>use some retarded ajax hack to push the file inside a c# ajax form to a jsonresult action so i can display an error because fuck scripts even though im using a script to throw the damn thing in.
>shit works but when iterating i have to make up for every exception or the exception goes along iterating with what im iterating so it gets stuck on the first last good iteration thinking the next iteration is also throwing the first exception until the last iteration.


how do i git gud?

They are using a lot of shit but mostly reCaptcha and prettify and making is heavier.

You know these evil scripts are all cached in your browser, right?

For argument's sake lets say I'm a Pajeet and I want to register with Adsense. Now, Adsense pays out lower cash to people outside the US, how do I register myself on adsense as a US citizen with a US address while overseas? Is there a service that does this?

Marry an american whale.

But honestly, don't even try, it's complicated to do it correctly and you could lose a lot if you get caught.

Here's something useless for you:
codepen.io/user/pen/evLPJM
Hint: hover over the text.

Can you be my white American whale?
Seriously, I'd only need someone to open the letter and send me the code so I can verify that as my address.

I would say befriend an honest USA webdev or wherever pays well, just give them your websites to put ads on and give them a good split. If they jew you then you just take the sites offline or take out their ads.

Check out some type of PO box service. I'd imagine someone has set something like this up in fact I just google it.

virtualpostmail.com/

You can bet google has all of those addresses logged and banned already. Google doesn't fuck around. None of the advertising servers fuck around, but Google's on another level.

Go look at any pajeet forum trying to do the same thing.

I should ad(:^)) that google does this thing where they will let you grind out ad revenue right until a few dollars before cashout then ban you. That way you worked for free and you can't do shit because you broke tos anyways.

How do I fix this bug:

I'm doing a bunch of async JS requests. When they are finished they concatenate their result to a HTML div. The problem is the requests take unpredictable amounts of time and the order gets fucked up often.

You using promises or what? Just check if something has a value before posting, if not then loop again.

>just give them your websites to put ads on and give them a good split
This wouldn't be necessary though. Last time I checked Google doesn't check if you're an American citizen or not, the only thing they confirm is your address by mailing you a unique code to be used for verification. Once you verify you've gotten the letter that address goes on file, then you can cashout through Western if you have the MTCN #.

As user said it's probably banned. I thought of this though.

Callbacks, or promises.

I need to interview web developers most of this month - i'm looking for people with Angular2 experience, which is a rare find in my city.

AngularJS seems to be a runner up, with general javascript/jquery coming up after that.

What is the best way to test these candidates ? I much prefer having them write a bit of code during the interview just to get a handle on how they work (its not so much of a test as a conversation, working together, 'open book' type thing).

Any ideas on something bite sized that can be worked on for people with experience in any of the above areas? (NG2, NG1, JS+JQ)

Just trying to cull the list.

It does use callbacks

but they all add the string they get to the same string in the callback

I think it would just be easier to give them IDs and sort it. I never got javascript async and this doesn't need to be that fast

literally just use promises, dude. Chain each promise using .then()

Hire me senpai. You get the added bonus of having me work remotely so you won't see my ugly mug every day.

Make them invert a binary tree on a blackboard.
Nah I don't know, I'm in no position to give advice to an interviewer but the only thing I care about js devs is that their code isn't tighty coupled to itself (like functions doing 10 different things and stuff like that).

Have them create a simple RESTful web service with HTTP. You can even start them out with a simple HTML form with a route already assigned.

If they can't do this or at least conceptually draw it out for you, then you don't want them. They won't be fit for web dev, even if they are just going to be doing fronted Angular stuff.

Btw Angular is already on version 4:

>angularjs.blogspot.com/2017/03/angular-400-now-available.html

Google just wants you to call it AngularJS from now on.

So are you HR scum or what?

But how should you protect a site from dumb spam bots?

I can't ban every IP that spams cause that would fuck up VPN people. Recaptcha is the only effective captcha all others get bypassed by neuronal networks.

question
how would you traverse through an array with a recursive function without mutation
in js

Never really worked with Node.js before but how does one do worker threads in this language?

I have an async function that scrapes a website but it takes too long for an AJAX reply so I'm having to let it get executed in the background with a job object reference.

This is so that the client can poll the server for the job status.

Redis is perfect for any short-lived data, and it has a reputation for having a very nice codebase

Finally got my first real project!! Very excited!

I'm making a webpage for a small business.

Please share any suggestions or inspiration here.


Share your wisdom web dev masters...

Make a header.vue file. Then make a footer.vue file.
Then use webpack+vue+vue-loader to inject those into the page. plus you also get a bonus of a full-spa app + routing and MVVM goodies

Don't use Nosql

Isn't this the exact use case for promises?

The function I'm calling is a promise (async function).

The thing is that I don't care about waiting until it's done. That job.id will be sent back to the client through a HTTP response and the client should poll the server every x seconds for the job status.

Your idea sounds fine, what exactly is the issue?

You could use websockets if you're doing lots of requests I guess.

The issue is that I'm just calling the promise (the scrape function) with no await/.then() call. I'm doing this because I just want the scraping to run in the background.

My IDE is nagging me that the promise returned is ignored. Apparently it's a code smell.

Maybe just .catch the error and log if there's an error?

Don't use Angular and

Agreed. NoSQL is just a meme. It's used for all the wrong reasons, especially in web dev.

i think i made a big mistake writing a pretty much static website in react for a small business

is there a tried and tested php PDO library for sql queries?
kinda hard to filter shit results on google

it's webscale you nigger

why did you use react?

youtube.com/watch?v=b2F-DItXtZs

:^)

I read that React/Redux were the cool new things that everyone should be using instead of jquery from now on so I tried them full on (React/Redux/Router v3/Saga), but recently I read that SEO is crap with React and only google indexes React sites and I have no idea how to set up SSR and whatever else is necessary to fix it. Everything would've been much easier with just static html and jquery for some dynamic components.

secure.php.net/manual/en/class.pdo.php

React is overkill for projects that don't have a lot of state-based components. I doubt a local company has a lot of that.

BTW, if anyone can provide me with a good example of a business app.


Because right now I got a landing page, and that's pretty much it. I would like to see how these apps are commonly done. How they are using databases, etc.


Any link to a project (github or otherwise) is very highly appreciated.

just use express with jade, and $database_of_choice for the storage if you're wanting to learn javascript.

What are you actually trying to do?

>just use express with jade, and $database_of_choice for the storage if you're wanting to learn javascript.
>What are you actually trying to do?
Getting experience is the goal. I am making an application for a small business that sells machinery to kitchens across the world.

There aren't any firm requisites.
The page for the business has to be good, and it has to attract customers.

What I got is a landing page in static HTML and CSS - that's all.
I'm setting up the server side with express, so far just rendering .html. No need to utilize templates ?

So chiefly I'm looking for inspiration and ideas. I really want to make this webpage good. Any primers greatly appreciated -- first job here!

jade is a templating language, let's say we have a bunch of different machinery objects that each need their own webpage with a description. you can have a jade template that formats the information about objects into a webpage.

this might be helpful. shapeshed.com/creating-a-basic-site-with-node-and-express/

Are you going to be gathering user data (logins, etc.) or will it be a primarily informational site? If the latter, the most important thing will be styling the information in a pleasant way and making everything load quickly and efficiently.

I'm currently using mysqli, should I switch to PDO to support more databases?

mysqli is pretty comfy, prepared statements work well and fetching is fast enough.

This is my first project, so I want it done and done well.
As of now, it's a landing page making a sale.
It's got leads and offers and a contact section that sends an email.

This is all as of now.
Please expand on user login...


So it's primarily informational. Should be simple, but portfolio worthy.
Looking to expand it from here.

React was created to solve some specific problems that probably don't exist in your application

Source: facebook.github.io/react/blog/2013/06/05/why-react.html
>React really shines when your data changes over time.

>In a traditional JavaScript application, you need to look at what data changed and imperatively make changes to the DOM to keep it up-to-date. Even AngularJS, which provides a declarative interface via directives and data binding requires a linking function to manually update DOM nodes.

>React takes a different approach.

>When your component is first initialized, the render method is called, generating a lightweight representation of your view. From that representation, a string of markup is produced, and injected into the document. When your data changes, the render method is called again. In order to perform updates as efficiently as possible, we diff the return value from the previous call to render with the new one, and generate a minimal set of changes to be applied to the DOM.

If your state isn't constantly changing, react might not be the solution for your use case.

That is why I suggested a simple template for now. That way you can render the basic stuff easily and, as you add features, you can easily extend by creating new templates.

By logins I mean--is this an ecommerce site? Will people login and try to purchase things, will they put their data into a form and something will happen?

BTW: A page where the current storage of machinery is displayed would be great.

So I could my client/friend with a provide a monthly update on what he got stored.


So a simple database solution?
Any suggestions welcome.

The reason a templating engine might be a better option for now is that it's simpler and you can add react if you want to introduce some significant complexity later on.

This will reduce your headaches and will allow you to make changes quickly and slowly build up things.

How will you get data to put into this? Will the data be entered manually or do they have some kind of database already?

If manually, you'll have to create an interface for your client to input data into the database. Then you will post that data to the backend and store it. Any database will work (ignore the memes), just learn one.

Will it be client facing, facing to the public, or internal only (requires a login or some kind of authentication?)

MySQLi is good, so if you like it, you can stick with it. But PDO seems better in some cases.

>phpdelusions.net/pdo/mysqli_comparison