/wdg/ - Web Delevopment General

nvm fixed it edition

Previous:

>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 (independent of your browser choice)
freecodecamp.com
codecademy.com
hackr.io

>Further resources
developer.mozilla.org/en-US/docs/Web - excellent documentation for HTML, CSS & JS
github.com/kamranahmedse/developer-roadmap - Frontend+Backend learner-path suggestions
[YouTube] Web Development in 2018 - A Practical Guide (embed) {embed} - Web Development in 2018 - A Practical Guide [YouTube]

jsfiddle.net - Use this and post a link, if you need help with your HTML/CSS/JS

>PHP resources
pastebin.com/gfBPg24A

Attached: 1535573754221.png (822x552, 868K)

Other urls found in this thread:

w3schools.com/howto/howto_css_parallax.asp
vidya.link/
twitter.com/SFWRedditVideos

Is this right?

function findMaxProfit(prices) {
let buy = prices[0];
let sell = prices[1];

for (let i = 2; i < prices.length; i += 1) {
const currentProfit = sell - buy;
const currentPrice = prices[i];
const prevPrice = prices[i - 1];

if (currentProfit < currentPrice - buy || currentProfit < currentPrice - prevPrice) {
sell = currentPrice;
if (prevPrice < buy) {
buy = prevPrice;
}
}
}

return { buy, sell };
}

const stockPrices = [50, 40, 60, 85, 24, 30, 50];

const stockPricesTwo = [100, 90, 80, 71, 65, 40];

console.log(findMaxProfit(stockPrices));
// { buy: 40, sell: 85 }

console.log(findMaxProfit(stockPricesTwo));
// { buy: 71, sell: 65 }

Beggar Tier (Oh shit nigger, what are you doing)
>Coldfusion
>Perl
>Haxe
>Dart

Peasant Tier (Child slaves in an Indian IT sweatshop)
>Wordpress
>Any CMS aside from Wordpress (Magenta, PrestaShop, Squarespace, etc)
>Any PHP framework that isn't Laravel (Symfony, Zend, LAMP, CakePHP, etc)

Yeomen Tier (Code Monkeys)
>Ruby (Rails, Sinatra, etc)
>Python (Django, Flask, etc)
>MEAN
>MERN
>Laravel + Vue
>Java frameworks that aren't Spring (Grails, Struts 2, Vaadin, GWT, etc )
>JAMstack

Gentry Tier (Advanced codemonkeys)
>VENoM (Vue, Express, NodeJS, MongoDB )

Merchant Tier (Well-paid boomers)
>Spring + Hibernate
>Elixir + Phoenix
>ASP.NET Core

Wizard Tier (Unshowered 40+ y.o. virgin in a basement. Would be Noble tier if they weren't so far up their ass over-engineering shit )
>Haskell
>Clojure
>Crystal (Amber, Lucky, etc)

Noble Tier (Experts in the field of web development)
>Kotlin
>Scala + Play

Royalty Tier (The supreme chads of web development)
>Go (Any framework, or none at all, because it doesn't need it.)

Attached: 1523280247401.png (2251x3703, 2.71M)

HAHAHA

Look at this dude. He also has a repo with his own Antifa licence attached to the MIT licence that he's trying to get committed to Yarn and Babel. KEK

Attached: file.png (1034x656, 77K)

AND HE GOT FUCKING DROPPED

SAD!

Attached: file.png (791x936, 122K)

He sure do fucking loves putting his licenses on shit

Attached: file.png (1057x820, 97K)

hmmm

Attached: file.png (492x373, 34K)

Oh, I seemed to have explained myself poorly, my apologizes. Let's say I have a text field in my model called about paragraph, now usually this is only one or two lines however sometimes it becomes a wall of text. Currently this is all one paragraph

"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum \n Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum {{ inebreaksbr }}quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"

Is there anyway to get django to split it into two where the \n is?

>berg
every tiem

>bullshit tier
(you)r post

Dart is actually relevant now with Flutter.

>anti-fascist-mit-license
I swear the internet is ruining us as a species

Attached: my-nigga-you-shitpz.jpg (600x511, 49K)

it's usually a few group of people that causes the most problems

Attached: 1535601769539.png (750x1334, 1.65M)

Help me out lads, I can't figure out how to stop this image from going below the available height
It's supposed to scroll along to the end of the website and it does on other pages, but not this one

Attached: paralax.png (1213x929, 661K)

I don't like how we get more of these people in tech though. Or so it seems anyway. I want politics to leave my web dev biz. Pushing for more women in programming is fine but no bullshit about fascist please

>calling LAMP a framework.

A peasant doesn't know that LAMP is a stack

this is cleaner
const stockPricesA = [50, 40, 60, 85, 24, 30, 50];

let getBuySell = async (stockPrices) => {
const sorted = await stockPrices.sort((a, b) => {return a-b})[0];
const buy = sorted[0];
const sell = sorted[sorted.length-1];
return ({ buy, sell });
};

const maxProfit = getBuySell(stockPricesA);
console.log(maxProfit);

>when newfags can't into programming

t. php creator

const getBuySell = async stockPrices => {
const sorted = await stockPrices.sort((a, b) => {
return a - b;
});
const buy = sorted[0];
const sell = sorted[sorted.length - 1];
return { buy, sell };
};

const stockPricesA = [50, 40, 60, 85, 24, 30, 50];
const stockPricesB = [100, 90, 80, 71, 65, 40];

(async () => {
console.log(await getBuySell(stockPricesA));
console.log(await getBuySell(stockPricesB));
})();


Expected output is wrong. Remember: one of the rules is to buy before selling.

{ buy: 24, sell: 85 }
{ buy: 40, sell: 100 }

you do recognize spamming is against rules right?

wait that doesnt work. nvm
const stockPricesA = [50, 40, 60, 85, 24, 30, 50];

let getBuySell = async (stockPrices) => {
const sorted = await stockPrices.sort((a, b) => {return a-b});
const buy = sorted[0];
const sell = sorted[sorted.length-1];
return new Promise(resolve => {
resolve({buy, sell});
});
};

getBuySell(stockPricesA).then( res => { console.log(res) });

Where does WebAssembly goes?

Attached: 1528158432539.jpg (409x409, 51K)

We're not just selecting the maximum and minimum values from the array.

>those few sweet moments in /wdg/ when the thread hasn't yet been ruined by that one php namefag

Attached: 23464354256354.png (659x609, 66K)

>Any PHP framework that isn't Laravel (Symfony, Zend, LAMP, CakePHP, etc)

Laravel is built on top of Symfony you nigger

Jow Forumsive one real world application to implement stacks or queues

Attached: 1534813502760.png (817x443, 34K)

XML validator for stacks (just try to validate nesting of tag names)

Download manager for queues

If you've ever implemented a chatroom, you've used a queue.

Is there a good alternative to the mern stack, something that has little to no javascript in it but isn't PHP?

Do really consider PHP. PHP 7 is now very solid, and it's much faster since it's core rewrite. Laravel makes it a joy to use and is very much in demand in the job market.

nginx as the web host also makes things very scalable and fast.

I'd also recommend switching from noSQL to PostgreSQL or MariaDB/MySQL unless you really don't care about storing unstructured non-acid compliant data. If you want fast-to-access data, consider using a Redis store.

>sort the array
>buy the low
>sell the highest

is that the solution? what?

The indexes are "tickers" that reflect the time of the day.

You decide to buy on that day, and then you decide to sell later on.

Find the best times that you could have possibly bought and sold on during the day.

>async
>await

for what reason lmao

>We're not just selecting the maximum and minimum values from the array.

To clarify: Find the best times that you could have possibly bought and sold on during the day that make you the most profit (or least loss).

Your example yields:
// [50, 40, 60, 85, 24, 30, 50];
{ buy: 24, sell: 85 }
// [100, 90, 80, 71, 65, 40];
{ buy: 40, sell: 100 }


The correct answer is:

// [50, 40, 60, 85, 24, 30, 50];
{ buy: 40, sell: 85 }
// [100, 90, 80, 71, 65, 40];
{ buy: 71, sell: 65 }

tfw escalated from Yeomen Tier (MERN) to Royalty Tier in a month. feelsgoodman.jpg
The only thing that sucks is the mongodb driver for go is shit

i see. so what's the algorithm for this?
generate every permutation and compute the transaction that has the least loss?

It should be achievable in O(n) time (i.e. one loop).

so where's the solution?

Here's one attempt

is this an interview question?

Yes, for the company I work for.

We recently switched over from 5.6 to 7 on our live and it serves pages faster and uses less resources.

Going to save a loooot of money.

>Going to save a loooot of money.
Yes, on your salary though

is it okay to serve files with nodejs? or is nginx significantly better?

how long is the interviewee typically given to solve it?

node js handles all requests on a single thread

nginx is multithreaded, supports clustering and was built specifically for this purpose

you decide

Wait so you get to see the whole day in advance?

Screw that. Use websocket to pull random numbers every 5 minutes with slight variance and have them generate a bot that consistently makes a profit.

That one is a bit generous at 15-30 minutes. Most do fail though but the real intention for us to know how they approach solving problems, whether they botch it up quickly and then refine it, or plan it out before writing.

I don't care about my salary. It's only half my income anyways.

if they do it in 5, do they get promoted to CEO?

>I don't care about my salary.
So you like to work for free?

Can you say that in German?

No, they don't get the offer because they're going to leave anyways in 6 months.

Salary is mid 50s. Job is beer money. It's easy and I can show up whenever. I should have been at work 30 minutes ago but I'm at home in the bathtub on wdg.

I'm working here while I build my business further.

>they're going to leave anyways in 6 months.
the fuck

Probably a low-paid position.

They would rather go through a lot of low-paid devs than keep a few high-paid ones.

Dev value increases substantially with work experience. 6 months of experience from your first dev job can raise you 20 to 40k more a year if you leave.

>have to solve code challenge to go to a low-paid position.

just give them the job already

A ton of people apply that cant code. You have to filter out the potatoes even at the junior level.

We hired a dev that passed a coding test but sucked really bad and was fired after 3 weeks.

what's the job about anyway?

devops? maintain a SPA?

Im not him. Just stating a likely reason for why he said they leave after 6 months.

>Your whole career was fake it till you make it

Attached: 1532460333599.gif (516x250, 530K)

what's a good way to create the parallax effect (a.k.a. background-position-y: scroll on scroll) bonus points for easing and also bonus points for not scrolling past the img height

Do I need to set up an association if I save my things to the database with an ID on each?

Like User has something_id of 1 and profile has a something_id of 1, I can just do find where something_id is 1, right?

>tfw can't figure it out

Well say you have a users table and a table with money transactions. How are you going to link the money transactions to the correct user? By user id.

SELECT u.*, t.* FROM USERS u LEFT JOIN transactions t ON t.user_id = u.id

Is that what you were asking?

So I did this today :^)

Attached: output.webm (773x532, 2.96M)

w3schools.com/howto/howto_css_parallax.asp

Please use Google before asking here. For your own good.

kek, 10fps@2k frames

Attached: file.png (313x218, 113K)

Scheduled mailer

I already have. That right tgere is nothing but background-position:fixed; aka half of what I'm looking for.
The other half seems to be here: kirupa.com/html5/smooth_parallax_scrolling.htm

What in the world...

Attached: 1534805875886.jpg (680x543, 39K)

Please tell me that you hand-coded 158MB of css.

No, but I got it in a demo now so you can check it out yourself. This one is set to 6MB, 300 frames @ 10fps, 1px color per 10px of source.

vidya.link/

I'm thinking of increasing the frame limit and resolution and calling it a browser benchmark :^)

How is Elixir + Phoenix boomer-tier? Those are both relatively recent things, it's gotta be mostly millennials using them.

>tfw you didn't know how to embed a video on a web page so you ended up manually drawing all the frames on MS Paint

Attached: b.jpg (211x239, 10K)

>How is [insert web stack here] boomer-tier?
All of web development is boomer-tier

Did you write a video to CSS gradient transcoder? I'm not even mad. Did you use ffmpeg to decode the video to pixels, or what?

ffmpeg to decode images to frames

some npm package to go through each image and get every pixel color

...and put all the colors in fucking box shadows lmao

Nice.

I'm playing around with writing babby's first CRUD app with react and I have a question about a bug that I'm having. I'm writing a basic list type app and storing list items in a sqlite database, with the data being accessed by fetching from an express.js server.

React has a philosophy of having a single source of truth and having component re-renders flow from that state changing. I guess I took that idea and ran with it, changing state based on what's in the database, essentially relying on the database to serve as the state.

The problem is that not every time I, for example, click the delete button on a list item, the page will not re-render to remove that item. The flow goes something like this:

1. User clicks the delete button, which sends a DELETE request to the api.
2. If the response is 204, then another function sends a GET request to fetch the list of items from the database, then calls setState on that list of items.

Most of the time, the page re-renders correctly, but most of the time isn't good enough.

At this point I'm thinking that I should just load the list of items in the initial render (In componentDidMount) and then validate requests based on the state prior to sending api requests.

Please, rip me apart, for I am a noob that doesn't know wtf I'm doing. Any design patterns to recommend?

I would have put it as base64 images but that's cheating

This is exactly what I did here

console.log(021); // 17

???

Javascript treats a leading zero as indicating that the value is in base 8 (octal).

Similarly, 0x10 would give you 16, being parsed in hex.

Make sure that your component is actually re-rendering after the setState call.

- Add "componentDidUpdate(prevProps, prevState) {}" to your component that renders the list.

If the list is passed to another component that renders the list, make sure that the component that renders the list implements a "shouldComponentUpdate(nextProps, nextState) {}" method instead of PureComponent or else it'd only shallow compare the props that it's been given.

How are you loading your list right now if it isn't componentDidMount?

Also you probably would rather want to do client side modifications of the state (using immutable update patterns) instead of requesting the list again from the server.

I'm having issues with a WP theme. I'm suppise to ad some JS code. So I do it as I should, through the JS module on the theme. BUT if I do this, the javascript code won't work, I even tried a simple console log and nothing came out.

So I try the next method, through editing functions.php in the WP editor. This way the whole site crashes and not even the WP backoffice will load. So I'm thinking on trying a madeup method, taking the last js loaded in the footer and editing my own js code in tgere, however I haven't even tried this method yet and I'm not sure if it would be the right method for me. Any suggestions? I'm fucking lost here being a WP noob.

This: The solution you're discussing feels like the right one in terms of a reactive pattern, but it's entirely dependent on a real-time connection with the server. What happens on a mobile device when the network connection is lost for some interval of time? What happens when your list is thousands of items instead of dozens and you'd rather not load them all at once?

You're effectively ignoring the network barrier, but the correct pattern is to define an API and a protocol for communication with it. For example, what happens when something changes on the server? Currently, you would fetch the whole list again, right? What you should actually be doing is querying the server for any updates which have occurred after a given time, or possibly sending events on a websocket or something.

update, tried the last method and it won't work either. Wtf man.

>fucking box shadows
Ah, ok, I didn't look close enough. Anyway, very cool. Basically useless, but very cool.

>putting JS in functions.php
What the fuck am I reading

What code are you trying to do? Where is it being called?

that's how you are supposed to do it based on developer.wordpress.org:
developer.wordpress.org/themes/basic/including-css-javascript/

I'm trying to replicate a simpler version of this:
kirupa.com/html5/smooth_parallax_scrolling.htm
but as of now, I'd be happy to get a console.log("hello world"); working, since I've had no success including that in the last .js file included in the footer.

breh

Attached: _85544445.jpg (728x572, 49K)

Okay, so you're bringing in the .js file fine. The 5th argument for wp_enqueue_script is if the script gets placed in the footer or not. Did you try that yet?

I can't since placing functions.php in my child theme to edit it causes the whole thing to crash, I guess I can edit the main functions.php in the original theme, but that would wipe it on a wp update.

Did you just copy the functions.php from the parent theme and place it in the child theme, or is the child functions.php empty/just has your enqueue function?

I spent the last 4 years doing vanilla JS and HTML 4 development for IE7 because the pay was really good.
Now I really want to do something else, by realized I'm basically unemployable.

How quickly can I learn angular/react at an expert level and pretend that's what I'd been doing all along?

Attached: 1523504798757.jpg (340x340, 124K)

I copied it.