Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
I am pretty sure someone will tell me I'm doing it wrong.

On the client side I'm using markedjs to render markdown. The server sends raw markdown to the client and the client renders it on the page. However it isn't really a single page application or anything like that so in order to just avoid an additional request I'm including the raw markdown on the page.

When `DOMContentLoaded` I grab the `innerHTML` of my content, run it through markedjs, and re-insert it into the same place I got it from.

This works.

But I'm getting weirdness in my code blocks like I'm seeing quite a few `>` `<` in there, and if I have an HTML code block it just seems to eliminate most of it. I suspect that's because when I insert raw markdown onto the page the page thinks that HTML code block is actually HTML.

So I'm left to ask should I absolutely definitely not be putting raw markdown into my page, and if I did what's a more smarter way of doing it.

Adbot
ADBOT LOVES YOU

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
After typing out my question I knew the answer.

Now I'm passing the markdown inside of a data attribute, then it's just a string and I'm able to convert it to HTML and insert it without any problems. I'm choosing not to render markdown on the server because markedjs has a pretty great code block implementation that allows me to do syntax highlighting. If I were to render the markdown and all of the syntax highlighting on the server I feel it would be an unnecessary use of bandwidth and cpu.

Surely it would be convenient to parse markdown on the server. But I also have an editor function, so parsing markdown on the client side was something I had in place either way.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
nearlyfreespeech.net

I wholeheartedly recommend them as a managed host if you're pretty proficient with ssh. They aren't super-duper user friendly on purpose, but do in fact do real easy ssl setup, as easy as 1 command. They are also extremely transparent with pricing.

They primarily support php/cgi but I've been hosting a lot of more complex stuff in the form of node apps using daemons.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense

ufarn posted:

Is exporting a phpMyAdmin fairly straightforward for this? I don't really work with PHP that much beside self-hosted stuff.

It comes with phpmyadmin and as many mariadb instances as you like. I never work with php so I can't be much help to you with your question, try their support system

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
It feels like every web framework I've ever used handles a trailing slash in urls differently, it's odd because there really can only be three different ways of handling it but somehow they are all different. I pretend it isn't an issue.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
Man just use float. Most of the new CSS attributes are developed by people who don't know what they are doing.

code:
#header {
    position: fixed;
    left: 0;
    top: 0;
    right: 0;
    height: 50px;
}
#main {
    position: relative;
    top: 50px;
}
#main #sidebar {
    float: left;
    width: 200px;
}
#main #content {
    // padding?
    padding: 50px;
}

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense

duz posted:

I have our templating engine strip all white space on output because why not? The browser dev tools can still generate the tree view just fine.

The prettify feature is being deprecated in pugjs. Which is ok, white space between elements can have weird effects

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
Man you guys are living in the future with that tech.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
Stop it stop showing off!

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense

Love Stole the Day posted:

Hello, I am trash and please tell me why my portfolio project is also pathetic, worthless, and not good enough to get an interview with tia https://wanderrful.github.io/korean-learning-app/

Known reasons:
  • The spinning check-mark at the end is dumb and should be replaced with something more simple
  • There should be a hint message that pops up after X wrong answer attempts
  • There should be some kind of prompt to specifically tell you to translate the thing to English
  • Redux hasn't been successfully shoehorned in randomly just for the sake of it

I can't get past question one but my instinct tells me it's using some kind of overly elaborate library for something otherwise simple. Oh, yeah it's using bootstrap, and therefore also jquery. Oh holy it's also using react. Well, at least you're demonstrating your ability to use it for the pros.

Good lord, the webpage is approx 600 bytes, but the html/css hauls it up to more than half a meg. For what it's doing I don't like the size of it.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
I thought about making a website builder that is intentionally not meant for professional looking websites. But instead mimics Geocities neighbourhoods of old, and lets you sort of drag and drop elements that look like 90's era stuff. Webrings, animates gifs, stuff like that.

Is there any market? It could advertise 5MB of free space on the top, it could be basically like old times again.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
I am having difficulty believing Wordpress is still king of this castle

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense

Gmaz posted:

How do you write big applications for serverless? Or is essentially each function a microservice?

That would finally force everyone to error check every single function call.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
Reminds me how I was trained by Ruby to make everything a class or a class instance. Then I tried to translate that to JavaScript and made my life a nightmare for a little while. Then I discovered how great it is not to use classes without there being a good reason.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
I'm running the job application gauntlet and I've been noticing a significant number of companies are hiring for Python backends, and JS frontends. Very few seem to be looking for Node backends. Which is too bad because that's where I focused.

I have a lot of Ruby experience, I think it's clear Ruby lost to Python.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense

melon cat posted:

On the SEO talk- I'm going to vent a bit, here. Despite what anyone claims nobody has 100% "figured out" SEO (Google doesn't make this easy). It's constantly changing. But there are all of these "marketing and communications" companies out there that make dubious claims about "SEO optimization" and make bullshit claims about being able to make you #1 on Google Pagerank for the low, low cost of $800 a month or something. So people are just throwing money at these companies, many of which are run by complete hacks, with really mixed results.

It's modern snake oil. Google just does whatever it wants if you need a guaranteed page rank you have to pay Google money, that's on purpose.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
http://www.youmightnotneedredux.info/

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense

huhu posted:

Do you guys use PUT and DELETE for http request methods? Am I bad because I only use GET and POST? Also, why do I only get asked the difference between GET/POST in interviews?

Well I mean. Those are the only real ones, plus OPTIONS and HEAD the others are artificial and are only possible by adding a hidden field or a query parameter, or request header. Unless you're using fetch I suppose. The whole thing is more ideological than practical but there are die hards out there.

Supposed to do:

code:
GET /products
POST /products
GET /products/id
PUT /products/id
DELETE /products/id
But then you also usually need:

code:
GET /products/new
GET /products/id/edit
Which is messy no matter what you do. And the "new" route is especially bad because "new" could as easily be an id so it's a special case. Therefore the PUT and DELETE routes aren't really the biggest problem. You may as well have:

code:
GET /products
GET /products/new
POST /products
GET /products/id
GET /products/id/edit
POST /products/id
GET /products/id/delete
Or, switch to any other system aside from REST. Like RPC for example, beautiful, sane, RPC.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
What? No. I mean you need a page that displays a way to "Create product" and you need a page to "Edit product", those are routes that generally have to exist.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
k.

Gmaz posted:

Why would you not use e.g. a delete request to delete a resource, why make an additional get route for it?

what's the difference.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense

Edgar Allan Pwned posted:

Here is the codepen for what I'm working on.

https://codepen.io/june-y/pen/XoMrVP

I guess the main question is, why doesnt hover work with the current HTML/CSS setup. I can find examples of hover working for nth-child, like

https://stackoverflow.com/questions/14203823/hover-with-a-nth-child

or

https://stackoverflow.com/questions/14203823/hover-with-a-nth-child

Ive looked at a few jsfiddles and the only difference I have really noticed is how people divide classes.

You haven't set any `:hover` attribute.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
I was a big fan of skeleton for a while, but it has been ages since I've used any kind of css framework so I dunno if it has kept up

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
Blog about tips and tricks you've learned along the way, without divulging any of the code as you're likely held under NDA.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
I've been working on a service that generates email addresses (incoming only) and another thing that lets you generate free forums and I'm 80% certain the first thing I'm going to do is block Europe.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
Do you really want to use html? If you want to just use javascript it's no problem with FormData and XMLHttpRequest...

https://developer.mozilla.org/en-US/docs/Web/API/FormData/Using_FormData_Objects

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
You really just want to set window.location.href to the file location and let their browser do what it does with the filetype. In most cases it'll download. I did something really hacky for a tampermonkey script I use to download images sometimes, it involves creating a link element setting the href to a data url, setting a "download" attribute to the filename I want and triggering a click event on it.

But it's so incredibly hacky I'm ashamed of it so I won't post the code. I have no idea if it works anywhere other than firefox.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense

my bony fealty posted:

I am looking for a way to persist data between two separate front-end sites. Like a user completes one and clicks a button that directs them to the other, which is aware of what they entered in the first.

Currently using localStorage but it seems...unreliable. some of the testers say it doesnt work and I dunno why.

Whats a good option here - a cookie? Session storage? window.name like mentioned earlier? Whatever it is will be in addition to local storage since that works sometimes and multiple layers of redundancy seems good.

Might resort to just using MongoDB or somesuch as I do not really trust the browser for reliable persistent storage right now :shrug:

Do different domains have access to the same local storage? I don't believe so.

The way to do this is to maintain session, and, session information, server side. And have the server willing to communicate with both websites. The problem you will face server side is the same reason why clients don't support this by default, which is security. How do you ensure the person visiting the other domain is the same person?

I think you need a server for each domain, and you need those servers to communicate with each other. Where you can make a request to the domain you are on, which handles the redirection, generating a session identifier for the other domain, so that you know it's the same user.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
GET /redirect-me-please

Server takes a look at your existing session, stores it somewhere or sends it to the other server. Redirects you to /redirect-callback?sid=80801010101010.

GET /redirect-callback?sid=80801010101010

Other server looks up your sid in storage, compares the storage date against a 6 second expiry, gathers your data together on its domain and generates your new session containing data from the other domain and redirects you to whatever you wanted them to land on. You can have as many query parameters defining this behaviour as you want but I don't think it can be any simpler than that.

Even better would be using JWT, and signing it with asymmetric keys. So that you don't need a "magic key" that'll subvert your application, but instead a key from each server, which would be twice as hard to get.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
If you go the JWT route you won't need server side storage of the session which is even better really, because it's simpler as long as you understand how JWT works. You can just include all that data in the token itself and pass it to the other server as a query parameter. As long as the signature is valid you can trust the contents of the token and you're golden.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
HTTP is susceptible to man in the middle attacks at any step. ISP's even started injecting ads on websites they served, which pissed Google off as you can imagine. Entering anything on any form is completely exposed, as is what you view on the page and there's no way to know what you're seeing on the page is what you actually requested.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
I really never got around to making letsencrypt work either. As the certs expire seemingly daily and therefore you have to automate the certification process so that it can run all the drat time. Luckily my current webhost was nice enough to just have a script I could run that does it for me.

Haven't had to think about it since.

It was so nice to run that thing and it "just worked" you have no idea.

Nolgthorn fucked around with this message at 00:11 on Jan 18, 2019

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense

Cugel the Clever posted:

Like was said up-thread, you may not trust Google, but surely the EFF isn't out to destroy the internet?

It depends whose financing it, who's in charge. What one person's opinion is regarding what destroys the internet is different from another. More important than that I think bad actors are drawn to whatever is the most powerful influencer at any given time, many of them have lots of money and can likely weasel their way in there.

Maintaining a lot of competition is key. Currently if I decide I want to stop using one single thing, there's like 5 years of downtime while an alternative gets developed.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
This is the newest book on Amazon

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
I use app because I copied and pasted it from a tutorial the first time I built one and suspect other people did too it's going to become the gold standard.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
Maybe I'm not understanding the issue.

Being "logged in" isn't a concept generally on the server... your session might be getting stored in CouchDB but to retrieve that session you need to set a cookie in the user's browser that identifies it, and you need to get it again from CouchDB on every request.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
I like to set one or two things in a JWT including their user id, stick it in their cookies. Verify the signature when they make a request, look up the user by id, and bingo bango that's my user right there. I understand there's some insane people out there who think JWT isn't a good idea for session management but they are incorrect.

Headless JWT is my personal favourite.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
I've found edge in a lot of cases works better than chrome or other competitors, it's got features and speed. I'm sure there are reasons for switching to webpack but it sure seems like it's going to delay their minimal 64-bit-only Windows Lite project. As webpack is still 32-bit.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
My understanding was edge was a rewrite from scratch, they ditched all backwards compatibility for ie stuffs

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
Webpack, Webkit what's the difference, nobody knows that stuff mang. Practically identical things

Adbot
ADBOT LOVES YOU

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
Something like this will give you an email link and confuse bots.

JavaScript code:
function initEmailLink () {
    var elements = document.querySelectorAll('.email-link');

    for (var i = 0; i < elements.length; i += 1) {
        var element = elements[i];

        element.addEventListener('click', function (ev) {
            ev.preventDefault();
            var href = "mailto:" + (element.dataset['e0']) + "@" + (element.dataset['e1']);
            window.location.href = href + '?subject=Hello from your website';
        });
    }
}

document.addEventListener('DOMContentLoaded', function () {
    initEmailLink();
});
code:
<a class="email-link" data-e0="myemail" data-e1="gmail.com">Email me</a>

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply