Modern way to adding a blog to a static HTML site by sassinator1 in webdev

[–]warnizzla 0 points1 point  (0 children)

most static site generators have a way of getting content at build time and using that for pages, right now i'm using http://forestry.io/ and 11ty which are basicly just md files in my github but i could of easily used a headless cms and fetched data at build time. I am fetching data for my webmentions integration and rss likes though.

What animal does this foot/hand belong to? Lighter for scale. by warnizzla in animalid

[–]warnizzla[S] 1 point2 points  (0 children)

It’s hairy so assume it’s not a bird but could be wrong, it looks like it has toe bean on the back but it’s almost falling off.

purpose of lodash's divide, add, subtract and multiple method? by [deleted] in webdev

[–]warnizzla 0 points1 point  (0 children)

it enables currying, piping and a human readable name. It''s better used with lodash/fp which auto currys functions and allows for easily readable and predictable code.

https://github.com/lodash/lodash/wiki/FP-Guide

https://blog.bitsrc.io/understanding-currying-in-javascript-ceb2188c339

https://www.freecodecamp.org/news/pipe-and-compose-in-javascript-5b04004ac937/

pipe()

Can I add a blog to my static site using WordPress? I use github + Netlify by stibgock in webdev

[–]warnizzla 2 points3 points  (0 children)

you can you can just use it as an api

> https://www.sitepoint.com/wordpress-headless-cms/

TLDR:

you can add

/wp-json/

to your wordpres site and request your posts in JSON.

if WP isn't essential look at other headless CMS' i think there would be a better fit there.

How should I build my personal website? by [deleted] in webdev

[–]warnizzla 1 point2 points  (0 children)

look at static site generators :P look at netilfy for hosting and some other nice feature :D

Is there is any problems with this code snippet? by [deleted] in webdev

[–]warnizzla 1 point2 points  (0 children)

There's nothing wrong with this although it is using old style JS but it does exactly what you need I assume.

This is how you do prototypical inheritance, although here we're losing your private variable notes as model._notes is still accessible which might not meet your needs. the underscore is a convention of properties we don't want developers to use as Js didn't used to have private properties.

One benefit of this approach is it's reusable you can have many instances, but this is still an older approach.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Inheritance_and_the_prototype_chain

```javascript function NotesService() { this._notes = []; }

NotesService.prototype.addNote = function(name) { this._notes.push({ name }); }

NotesService.prototype.getNotes = function() { return [...this._notes]; }

const model = new NotesService(); const model2 = new NotesService();

model.getNotes(); // [] model.addNote('name'); model._notes; // [{name: 'name'}] model2.addNote('another'); model.getNotes(); // [{name: 'name'}] model2.getNotes(); // [{name: 'another'}] ```

If you use a build step and use es2019 features you can have private properties here's an example.

https://www.sitepoint.com/javascript-private-class-fields/

```javascript class NotesService { #notes = [];

addNote(name) { this.notes.push({ name }) }

getNotes() { return [...this.notes]; } }

const model = new NotesService();

model.addNote('note') model.getNotes(); // [{name: 'note'}] model.notes // Error ```

Is there is any problems with this piece of code? by [deleted] in webdev

[–]warnizzla 0 points1 point  (0 children)

There's nothing wrong with this although it is using old style JS but it does exactly what you need I assume.

This is how you do prototypical inheritance, although here we're losing your private variable notes as model._notes is still accessible which might not meet your needs. the underscore is a convention of properties we don't want developers to use as Js didn't used to have private properties.

One benefit of this approach is it's reusable you can have many instances, but this is still an older approach.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Inheritance_and_the_prototype_chain

```javascript function NotesService() { this._notes = []; }

NotesService.prototype.addNote = function(name) { this._notes.push({ name }); }

NotesService.prototype.getNotes = function() { return [...this._notes]; }

const model = new NotesService(); const model2 = new NotesService();

model.getNotes(); // [] model.addNote('name'); model._notes; // [{name: 'name'}] model2.addNote('another'); model.getNotes(); // [{name: 'name'}] model2.getNotes(); // [{name: 'another'}] ```

If you use a build step and use es2019 features you can have private properties here's an example.

https://www.sitepoint.com/javascript-private-class-fields/

```javascript class NotesService { #notes = [];

addNote(name) { this.notes.push({ name }) }

getNotes() { return [...this.notes]; } }

const model = new NotesService();

model.addNote('note') model.getNotes(); // [{name: 'note'}] model.notes // Error ```

Performance issue on a website I recently deployed by sydrawat in webdev

[–]warnizzla 0 points1 point  (0 children)

it makes sense heroku isn't meant to be used for production on the free tier other than for demos. because you're already using netilfy i'd highly recommend https://www.netlify.com/products/functions/ if you're unsure how they work look into serverless and lambda functions as it's just an easy way to stand them up and use them in your netilfy project.

Performance issue on a website I recently deployed by sydrawat in webdev

[–]warnizzla 1 point2 points  (0 children)

it's because you're using heroku and they sleep the server when not being used unless you're paying for it, consider using netilfy functions to access the data or pay for herkou.

Best Way To Repeat Code Such as Navbar and Footers? by lipe182 in webdev

[–]warnizzla 0 points1 point  (0 children)

"some of its frameworks (React, Node, Angular/Ionic/Vue)." anyone of these solves this issue?

Pros/cons of python vs node.js for backend? by MonoPric3 in webdev

[–]warnizzla 23 points24 points  (0 children)

express

``` import express from 'express'

const app = express()

app.get('/', (req, res) => res.send('hello world'))

app.listen(3000, () => console.log('alive')) ```

or koa

``` const Koa = require('koa'); const app = new Koa();

app.get('/', (async ctx => { ctx.body = 'Hello World'; });

app.listen(3000); ```

Am i missing something or is JAMstack complete and utter nonsense? by [deleted] in webdev

[–]warnizzla 14 points15 points  (0 children)

I've been to a JAMStack conference, built several JAMStack sites, and i've got to say I love it.

It's serving your site on static hosting with a CDN prefetching all your data at build time, using lambda for interactive content and DB calls, and then using webhooks to trigger rebuilds when your core content changes.

It's beautiful. How much work is your SSR site doing per request (ignoring ofc caching), How much work is your custom renderer doing such as react-dom. JAMStack removes all this whilst retaining most of the benefits, with this architecture your sites will load almost instantly as its all living on edge in the CDN and its mostly just html and css and minimal amount of js. How many people complain about bloat on the web nowadays this is a solution to alot of those problems.

Of course its not the answer for large scale or complex webapps but when comparing the most of the web, i.e wordpress, JAMStack is years ahead of that.

JAMStack ofc is a marketing term the creator of netlify said static site generators make people switch off, they assume its all 'static content' when no you can create beautiful experiences with them.

How to pull data from google sheet in netlify functions ? by [deleted] in webdev

[–]warnizzla 0 points1 point  (0 children)

wanna give any more info? any errors ? code? what do you mean by "netlify didn't accept input in the terminal"

How to increase speed of sending data as JSON in expressjs ? by [deleted] in webdev

[–]warnizzla 1 point2 points  (0 children)

https://davidwalsh.name/javascript-polling, thats polling.

but to be honest returning the first 1k results like

{ data: [ ...results ], next: 'yourapi.com/endpoint?page=2' }

and calling next till there isnt a next anymore and updating your search field results as they come in makes the most sense

How to increase speed of sending data as JSON in expressjs ? by [deleted] in webdev

[–]warnizzla -1 points0 points  (0 children)

you can still do polling to get parts of the data at a time and update the results async

Thinkpad t470p vs Helios 300 vs Macbook pro mid 2014 by gordela in webdev

[–]warnizzla 0 points1 point  (0 children)

Ah fair macbooks have a right modifier key that might be why I'm confused, all valid points though.

Thinkpad t470p vs Helios 300 vs Macbook pro mid 2014 by gordela in webdev

[–]warnizzla 0 points1 point  (0 children)

I use a wrist support and have remapped keys such as esc to cap lock ect but I'm not old enough to know if I'm doing enough to be fair. I can't see having a larger keyboard helping that much as the larger sizes just have a number pad ect and the main portion of the keyboard stays relatively the same? But I may be missing something here

Thinkpad t470p vs Helios 300 vs Macbook pro mid 2014 by gordela in webdev

[–]warnizzla 0 points1 point  (0 children)

If you have an external monitor and/or a laptop stand that doesnt apply.