/wdg/ - Web Development General

Previous Thread: NPM is shit edition

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

> Discord
discord.gg/0qLTzz5potDFXfdT

>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/
youtu.be/JxAXlJEmNMg?list=PL7664379246A246CB - "Crockford on JavaScript" lecture series.

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

>Backend development
en.m.wikipedia.org/wiki/Comparison_of_web_application_frameworks
gist.github.com/dypsilon/5819528/

>Useful tools
pastebin.com/q5nB1Npt/
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/

>How to get started
youtu.be/pB0WvcxTbCA - "WATCH THIS IF YOU WANT TO BECOME A WEB DEVELOPER! - Web Development Career advice"
youtu.be/zf_cb_Nw5zY - "JavaScript is Easy" - If you can't into programming, you probably won't find a simpler introduction to JavaScript than this.

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

Other urls found in this thread:

pastebin.com/y6QPcnpt
pastebin.com/VyprcHCE
pastebin.com/gtBb0cbW
pastebin.com/LDUF5rnM
youtube.com/watch?v=v__8ihsdsm8&list=PL7XjSnbRqMYXAb0zF66uhiEdX0tsSwGge
gist.github.com/anonymous/86430500cc07f76508a828a757be4cb6
twitter.com/AnonBabble

First for Go is fast.

Hi i am experience php coder. Anyone want to hire?

can you speak english good? and will you work for $2.35 per hour?

This is why you can get a job in development.

Of course. I live in new jarsy, my name is Tom like American name. Your office in designated poo street?

A moment of silence for that poor chair.

Imagine the smell of that chair after the hamplanet sat on it

hmm.... anal juice.

I've been stuck on a problem with node.js for fucking hours now and I need help. I have an array set up in express and I want to pass it along to jade, but I can't figure out how routing works. I have tried passing along basic strings and shit but it just doesn't work. Can someone give me some sample code for how to get this shit set up? I just can't figure it out.

Pieces of relevant code are:

app.get('/', function(req, res, next) {
res.render('index', {"books": ["A", "B", "C"]});
});

in express and
body
ul
each val in {books}
li= val

in jade.

Anyone got any idea what I'm doing wrong?

I don't know what Jade is, but if you want to pass an array of data via express then you can try:

app.all('/send_data', function(req, res){
res.send([data1, data2, data3, (data4[0] + data4[1] + data5 + 500 + 200)]);
});


I noticed you are using
app.get

...to try and send data.

From my understanding, .get is used when a get request is made. I've only really had stack overflow answers, their documentation and example code to go off though, so could be wrong.
Anyway, switching it out to
app.all('/send_data', function(req, res) {
res.send({"books": ["A", "B", "C"]});
});

Didn't work either, and not sure how else I would adapt it

did it work for passing a basic string?

app.all('/send_data', function(req, res) {
res.send('/index', {foo: 'bar'});
});

and
head
title= foo

doesn't work at all. I'm pretty certain I've got to do something with routing, but the documentation on routing is so confusing that I haven't got a clue how to do it.

the code you used in your first post worked for me, have you set your view engine to jade?
app.set('view engine', 'jade');

res.render('index.jade')


use the full file name

Yeah that's set, but I'm working in another file than the default app.js, and now I have a feeling it has something to do with that. Is there something I have to do to get that to work?
Didn't work.

I'm going to be working on my startup all summer, coding the rest of a website we're (or, well, I'm) building.

I'm planning on streaming the process, starting tomorrow, and continuing every weekday. Each streaming session should last about 7-9 hours, hopefully, and I'm pretty excited for it.

The thing I'm worried about is that programming isn't always interesting. Can you guys think of anything that might make the stream more entertaining or useful? I was thinking of letting people come to me with programming-related problems to let me try and help them, but I don't know how well that will work. Plus, while I love helping people, I do need to spend most of my time working on my own shit, not tutoring people.

Any ideas?

I should mention that just running nodemon at root runs the file as a console.log prints out.

let me work on your dank startup with you

Unless you are doing something very esoteric, why would anyone want to watch you program?

anyone got any experience with typescript?

im trying out phaser.js and following a simple tutorial to learn the basics of phaser and i might as well do some typescript with that.

the definitions work fine but when i try to compile i get this error

>tsc Game.ts
Game.ts(12,13): error TS1008: Unexpected token;
'statement' expected.
Game.ts(18,5): error TS1008: Unexpected token;
'statement' expected.


dont quite understand the issue here.

this is the source:
pastebin.com/y6QPcnpt

i dont know what could be worng
ive tried inserting semi colons but the error still persits

post full code, both files

wc3.js: pastebin.com/VyprcHCE
index.jade: pastebin.com/gtBb0cbW
app.js: pastebin.com/LDUF5rnM

you have 2 separate app instances in app.js and wc3.js

wc3 should be something like:

module.exports = function (app) {
// ...
}


and index.js should do this:
var app = express()
var wc3 = require('./wc3')(app)

i believe you can also export the router in wc3.js and app.use(require('./wc3')) in index.js

let and var require an explicit type declaration. let logo: someType = foo. But you should be using const instead here, because you don't change the reference of the variable. Because the reference is constant with const, TS can infer the type of the variable automatically.

Working it around that way still doesn't seem to work, but with ../wc3 instead.

Here's my file structure for reference

note that all your code should be inside that exported function using the passed in app

thanks.

Yeah that's done.

I've gotten viewers before. I keep a commentary of what I'm doing, which helps.

It's not actually very dank.

post channel

here's one way you could have a route in a different file, where your wc3.js would be route.js

in your example, your wc3.js exports a new express instance, where it should be exporting a function that calls the buildSheet() function and renders the result from it

sorry about those colours in the screenshot

is my micro-optimization relevant?

function compare1 (str1, str2) {
return str1 === str2;
}
function compare2 (str1, str2) {
return str1.length === str2.length && str1 === str2;
}

do js engines (mainly v8) optimize string comparison by checking if the strings' lengths match before comparing their contents?

>$2.35
damn, even in eastern europoor countries one cant compete with that

js will be slow regardless.

do shit on your server and use js just to animate dicks on screen.

Fuck the new age js libraries.

This. If you want speed, use C#, Go or C++.

it's for a browser extension

I got that working, and now it only loads everything after I load the web page, but my variables still don't work. Is there any way you can edit my code and see what works for you, as that's straight up not working for me.

For reference, in that image the title should be bar

it does matter a lot.
if you do application size logic optimizing loops and variable declarations can be a difference of a lot of seconds.
if you wanna know more try looking at this: youtube.com/watch?v=v__8ihsdsm8&list=PL7XjSnbRqMYXAb0zF66uhiEdX0tsSwGge
its very quick and you can get through it in an afternoon but it imprints some good practices onto you.

generally you optimize wherever you can. not just the backend.

>is my micro-optimization relevant?
looks like it is. using latest chrome canary for test.

i''ve got this working
gist.github.com/anonymous/86430500cc07f76508a828a757be4cb6

Looks like it doesn't matter at all, once the JIT compiler optimizes it.

are you sure, still seems to matter? also, is the ES-6 syntax relevant???

I know that arrow functions and let/const are more easily inlined and optimized. In fact, after running them a few more times, some returned 0. So I assume it does some preemptive checks and compiles the result as a constant. V8 is amazing.

yoooooooo thanks. I see what I did wrong now, I was treating it too much like base Javascript. Now to work on the rest zzzzzz

hey wdg, Im finally back on track to star some real web dev, and i noticed theres a lot (more) of tools and frameworks, which ones should I stay away from?? and post why.

How can I make some presentable projects in a day per project in JS and Angular? Please please help.

holy fucking shit JSLint is a piece of shit, why wont it stop bullying me!! my productivity has been halved ever since ive started using. CAnt even focus on my project anymore.

If you have to ask, stay away from all of them.

Find or make a good make a template to start from so you don't have to do boilerplate stuff over and over.

Quit writing such shitty code then.

>structuring HTML with JS
stop

Just starting out web development and since im coming from a c background, I love optimizing stuff.

Is there some sort of tool out there which will optimize a JavaScript file before putting it onto the web?

Stuff like:
>Strip unnecessary whitespace
>Remove comments
>Shorten variable names

Would any of these optimizations have any significant impact at all? Im beginning to make games in WebGL and want to squeeze every little bit of performance out of JavaScript that I can. I like to keep code neat for myself but when putting it onto the web I would like as much performance for my clients as possible.

nobody does that, stop projecting.

jslint.

Would any of these optimizations have any significant impact at all?

dont use js for speed.

You can't do much to optimize js for speed (except not do retarded stuff, of course. Keep big O in mind.)

You can get a pretty significant reduction in size with a minifier though, which reduces load time. If you're reasonably familiar with node, take a look at grunt, gulp, or webpack. (I personally prefer gulp.) They're task runners that you can set up to lint, test, minify, compile, and otherwise transform your code.

>jslint
alright thanks, will try it out.

>dont use js for speed.

What should I use then if I plan on working with webgl?

I know JS will never be as fast as C or other compiled languages, but you can still probably squeeze a little bit of performance out of it. Im new to all this so pardon my ignorance.

Usually js is jitted, so it might help with startup, but not on the long run in general.

And if you do this, please know that you should also provide the sources, for freedom reasons.

>minifier
This tool is great! Just reduced my JS file from 3.5KB to 2KB.

I havent tried node yet but will keep those tools in mind for when I learn it.

Thanks for the response

>What should I use then if I plan on working with webgl?

WebAssembly in a few years or so. JS is fine though. Just don't do anything retarded, as said.

Anyone here ever used CherryPy? Thoughts/opinions?

>this is a bullshit free zone
>Wordpress

this chair defies physical laws

>gravity free zone

>finished the US-number challange
>want to see a better solution because mine was too long
>see this:

var re = /^(?:(?:\+?1\s*(?:[.-]\s*)?)?(?:\(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})$/;

wew lad

anyone here use laravel thoughs/opinions?

fukcing disgusting, heres some moe to ease the pain.

I'm using PDO to create a view on an sqlite db, but I keep getting database locked even though the permissions for the file is properly set.

This only happens when I'm trying to create a view on sqlite. I can insert and query other stuff normally to the same sqlite file.

Anybody have any idea what's happening here?

are you already logged in from another connection?

>disgusting
>posts a cartoon with no nose

S Q L I T E user, it's a file DB.

nice quads by the way.

A few months ago I was playing around with it for a project but then turned to Django. It's neat and all but I think it's lacking features.

stop fapping to chinese cartoons user, youre going blind, she obviously has a nose

I just went live with that streaming thing.

I'm SHTheSuper on Twitch. Check it out, I guess? Hopefully everything goes smoothly.

What's the usual approach with regard to connection pools and prepared statements, given that prepared statements only live as long as the connection? Do you only prepare statements when it's going to be used several times in the same connection as opposed to several times across connections?

>inb4 nobody here uses either connection pools or prepared statements, let alone both

Are they in their underwear? Is that it? Being a female techie is about sitting together and "code" in your bloomers?

should i learn go and why

no because it's shit

Yes if you haven't learned any meme language

i know ruby on rails

> i think it's lacking featurres

like what>

Take a shot of whiskey every half hour and I guarantee people will watch

Yes because learning new languages is not difficult and any remotely popular language is worth learning

lads, how can I check if a is clicked with PHP?
normally I would just do
if (isset($_POST['thing_submit'])) {
blablabla
}

but that doesn't work here because it's not an in a form

here's my button:

The guy who runs cock.li did this a few days ago while writing the website for his new VPS service and said he was surprised at how interested people were and how well the stream went.

You'll be fine

You can't

that's not how it works user

if (isset($_POST['delete_pig'])) {
//blablabla
}

Except that still won't do anything because he has no form and is making no post request and has no idea what he's doing

then he needs to use ajax

damn, guess I'll just fuck it inside a form then

use AJAX instead

Just did:

Me and my friend just got our first web-dev contract, this guy wants multiple websites to be made. (mostly info sites, nothing complicated)
We want to use rails as our framework (I already have a little experience in it, he uses asp.net at work).
What do you guys recommend as CMS?

forgot to add that we will be hosting the sites ourselves.

> we will be hosting the sites ourselves
thats stupid.

why? He is paying for it, and we got a 9 euro vps.

>9 euro vps
get scaleway's 3 euro vps if you are just doing wordpress-tier websites

What image slider/carousel do you use?

holy fuck, that IS cheap.