|OT| Programming - Print("Hello "+ metacounciluser[yourID] + "!");

Le Pertti

0.01% Game dev
Oct 10, 2018
8,616
22,132
113
45
Paris, France
lepertti.com
So thought we should have a programming thread!

I'm a total noob and pretty much just took a basic C course but I want to learn and I thought a good way would be to do small apps for myself that do simple things:

For example I need to do an app that takes a photo and just adds white border to it and then spits out a new jpeg. I assume something simple like that can be done pretty much with all languages but which one would be the easiest and smoothest one to do simple apps like that?
 
  • Like
Reactions: lashman

lashman

Dead & Forgotten
Sep 5, 2018
32,121
90,471
113
For example I need to do an app that takes a photo and just adds white border to it and then spits out a new jpeg. I assume something simple like that can be done pretty much with all languages but which one would be the easiest and smoothest one to do simple apps like that?
how about C#?
 
OP
Le Pertti

Le Pertti

0.01% Game dev
Oct 10, 2018
8,616
22,132
113
45
Paris, France
lepertti.com
how about C#?
Ah yes it was going to be the next course I would do at pluralsight but the free month ran out! I'm sure there are alot more free ones out there, will check it out!

Its easier than C++? While I understood the basic flow of it, I have no idea how to even begin to make something of my own.
 
  • Like
Reactions: lashman

Copons

MetaMember
Nov 12, 2018
477
1,179
93
Brighton, UK
copons.wordpress.com
Yay programming!

Monooboe I guess to do stuff with images, and without the overhead of having to compile and stuff, PHP is also a good choice.
At least, I know PHP, I use PHP all the time, PHP was the first language that came to mind. šŸ˜„

Anyway, I've been mostly a JS programmer for a long time now, and I utterly love it!
Modern JS + React + Redux is just amazing to use.
I've had a few MINDBLOWN moments in my career (which is starting to be rather long!), but none of them brought me as much joy as learning to use Redux (which has a rather awkward learning curve), and React hooks!
Using React hooks = OMG I CAN DO ANYTHING I WANT AND IT'S SO FUCKING EASY! Love it.
 

QFNS

Plays too many card games
Nov 18, 2018
1,290
3,121
113
In college I used Matlab to process videos and do (really shitty) face detection. So that's even an option.

But yeah the language you choose is almost secondary to what you want to do. You can probably do anything in any language if you are willing to work hard enough.
 

Copons

MetaMember
Nov 12, 2018
477
1,179
93
Brighton, UK
copons.wordpress.com
What editor do you guys use? For webstuff I used to use Brackets but for coding it seems Visual Studio Code is pretty great.
Visual Studio Code.
Most of the time it works as I expect, and doesn't get in the way too much.

Previously, Atom, then Sublime, then who knows, Coda maybe? But we're talking so many years ago!
Started with Dreamweaver when it was still a Macromedia product! šŸ˜…

Most of my colleagues use VS Code as well, to the point that we are starting to write documentation for environment setup specifically for it, which is peculiar since we have absolute freedom of using whatever tools we like.
Some use PhpStorm, and find it excellent. I could even try it on the company's dime, but its UI looks so damn cluttered!

Oh, also Vim, but my experience is always: search for specific command on Google -> use command -> wait 5 minutes -> forget command.
 
  • Like
Reactions: Le Pertti

BlackRainbowFT

Mouse Accelerated Member
Apr 17, 2019
508
1,179
93
38
Switzerland
Its easier than C++? While I understood the basic flow of it, I have no idea how to even begin to make something of my own.
Oh yes. Way easier. The most significant difference is how you handle memory. With C# you have garbage collection, which is a form of automated memory management.

Unless you're specifically interested in the more low-level side of things, I suggest you focus on more high-level languages so that you can quickly start building cool things.
 

Copons

MetaMember
Nov 12, 2018
477
1,179
93
Brighton, UK
copons.wordpress.com
How hard is it to get a job even at the entry level?
Imho it really depends on your local market.
It's generally not super hard, though, considering that "web dev" nowadays means an extremely wide range of stuff.

This said, I think that these days with the virus outbreak less companies are hiring, but it's definitely not limited to the tech industry.

On the other hand, many are now dipping their feet in the remote/distributed work.
With any luck, lots of companies will end up appreciating it, and so when things will go back to normal, there'll be tons of new remote opportunities, which means that even if your local market sucks, you'll still have plenty of chances anywhere else in the world, without the hassle of moving away from friends and family.

---

I want to ask the programmers in this thread if The Odin Project is worth pursuing if I want a career in webdev?
I'm not familiar with that specific course, but the current web dev world has a surprisingly steep learning curve, as opposed to when I started, some 15 years ago.
Whereas back then HTML+CSS+PHP were enough and JS was just some shitty language that made sites incompatible across different browsers, nowadays web devs, even just front end devs, are supposed to know A LOT of very complicated stuff.

You need to know your way around the terminal, Node, build systems, preprocessors, transpilers. Then you'll need to know about JS, some frameworks (React, but not necessarily), some way to handle data (Redux, but not necessarily), how to interact with APIs, etc.

I'm lucky enough to have lived through all these changes, so I had years to figure them all out to a professional level.
New devs aren't as lucky, but at least starting now means that most of the confusion has settled, and so y'all (hopefully!) won't end up changing tools every couple of months because a newer shiny thing appeared out of the blue.

What I'm trying to say is: take advantage of courses! Especially if they are free!
I'm sure you'll realize it quickly enough if it's shit, and worst case scenario you'll have lost a few hours.

Also, if you are a sociable person, check out some local meetups, because usually these communities are excellent, very open and welcoming to new people, full of great advices, etc.
In my case, I know for a fact that the WordPress community is amazeball, and my local meetup makes no exception. I know lots of people that started attending as newbies, and ended up being hired by some of the best local companies.
(In other words: networking is really helpful in this industry!)
I realize that with the covid most meetups are suspended until further notice, but a few of them moved to online-only, and kept going on nonetheless.[/QUOTE]
 
  • Like
Reactions: Rando10123

QFNS

Plays too many card games
Nov 18, 2018
1,290
3,121
113
I work on low level stuff, and my work has relatively limited options in Linux due to contract reasons. So I use Eclipse. It's a memory hog, but it supports basically everything I want from build to version control to execute.
 
  • Like
Reactions: BlackRainbowFT

lashman

Dead & Forgotten
Sep 5, 2018
32,121
90,471
113
Finally started a C# tutorial and I love the feeling in the beginning always when starting learning: "fuck yes this is so easy and makes perfect sense!".
it won't go away :p C# really is that simple
 

EdwardTivrusky

Good Morning, Weather Hackers!
Dec 8, 2018
7,401
12,493
113
Monooboe It sounds like a stupid thing to say but keep on commenting the shit out of your code!
I guarantee that at some point you'll know the project really well and start slacking on your comments and then 6 months or a year later when you're on a new thing and remember something cool you did and want to reuse it you'll look at your lazily documented code and wonder what the hell is going on.

Documentation and comments are your friends.
 

Copons

MetaMember
Nov 12, 2018
477
1,179
93
Brighton, UK
copons.wordpress.com
We are learning javascript right now in the course I'm doing and I always feel so damn lost with programming haha!
Nice!
JS is my (current) tool of the trade, so feel free to ask if you have doubts and whatnot.
I can warmly recommend this book on GitHub, which has helped me a lot in my early years.

I think it's a very cool language, and super fun to use, but it also have a steep learning curve, caused by the absurdly fragmented language ecosystem.

You have several versions of JS (or, rather, ECMAScript) with various degrees of browsers compatibilities, then you have frameworks (React, Angular, etc.), build systems (Webpack, etc.), transpilers (Babel) that let you use cutting edge features and convert them to be compatible with older browsers, etc.

So while the language in itself is relatively easy to learn, using it at a pro level is a massive PITA.
Luckily there are a few no-config bundlers that help (I've used Parcel in the past, but I guess there might be newer and better ones around).


This said, one thing that is very easy to overlook about JS, is that you might not need any of the things I've listed here.
Just open the browser console, type your stuff and hit enter: it will work! šŸ˜„
 
OP
Le Pertti

Le Pertti

0.01% Game dev
Oct 10, 2018
8,616
22,132
113
45
Paris, France
lepertti.com
Nice!
JS is my (current) tool of the trade, so feel free to ask if you have doubts and whatnot.
I can warmly recommend this book on GitHub, which has helped me a lot in my early years.

I think it's a very cool language, and super fun to use, but it also have a steep learning curve, caused by the absurdly fragmented language ecosystem.

You have several versions of JS (or, rather, ECMAScript) with various degrees of browsers compatibilities, then you have frameworks (React, Angular, etc.), build systems (Webpack, etc.), transpilers (Babel) that let you use cutting edge features and convert them to be compatible with older browsers, etc.

So while the language in itself is relatively easy to learn, using it at a pro level is a massive PITA.
Luckily there are a few no-config bundlers that help (I've used Parcel in the past, but I guess there might be newer and better ones around).


This said, one thing that is very easy to overlook about JS, is that you might not need any of the things I've listed here.
Just open the browser console, type your stuff and hit enter: it will work! šŸ˜„
Thanks for the tips! Right now I don't even know what to ask, I'm immensely lost haha.

We have a assignment to do now where we are supped to use everything we have learned up until this point but I seriously can't code without just copy pasting from online.XD It's the same problem I have when I watch tutorials, I understand the code when I see it presented but then to write it I can't at all.
 
  • Hug
Reactions: Copons

Durante

I <3 Pixels
Oct 21, 2018
4,052
19,546
113
Picking this up from the Steam thread.

On a related stupid idea, if I learned a programming language, which one ?
I really don't like Python (for reasons which range from at least semi-objective language-lawyer stuff to mega-nerd nitpicking) but if you wanted to learn a programming language today it's probably a good choice at the intersection of being widespread (which makes googling stuff and finding good material easier), relatively simple to learn, and with a broad ecosystem. Another choice in a very similar vein would be Javascript (with a slightly different set of trade-offs, including dependency and framework hell).

It also depends on what you want to accomplish, e.g. if you want to write desktop applications or games then C# might also be a pretty good first choice as a language.

For starting a more comprehensive CS education I'd make different recommendations (something like C to understand computers and Haskell to understand algorithms), but that's more of a multi-year full-time project.
 
OP
Le Pertti

Le Pertti

0.01% Game dev
Oct 10, 2018
8,616
22,132
113
45
Paris, France
lepertti.com
framework hell
I'm working on a school assignment right now to build a todo list with users that can login and such for our javascript course and I'm so lost trying to figure it all out haha. While much easier than vanilla JS(which I have more trouble with) but now instead I have trouble finding correct way to do things within a framework.
 

Wok

Wok
Oct 30, 2018
4,923
13,188
113
France
I suggested Python because I am used to it, it is nice to work with, and it is really powerful.

However, I have heard a lot of good things about C#, and that should be a great recommendation based on what other people recommended to me back then.
 
OP
Le Pertti

Le Pertti

0.01% Game dev
Oct 10, 2018
8,616
22,132
113
45
Paris, France
lepertti.com
Alright you JS wizards! I feel I keep going round in circles and could love some pointers.

I need to have this flow of events using JS and Axios.
Log in user -> Get Id of that user -> Get todo list for that ID -> Create new entry to the list

Initially I thought I needed to be able to also create a new user but not sure if the API server that we are testing on allows that. I think I can create a new user on the actual site but even there I don't fully get it to work.
 

spiel

Junior Member
Apr 17, 2019
121
379
63
I don't have much to add to the exellent discussion in the other thread, but just wanted to share that in my CS course, this was the typical progression of classes in the first 2 years:
  1. Basic programming with C
  2. Java, OOP, data structures and algorithms
  3. Advanced data structures and algorithms (still Java)
  4. Introduction to software engineering
I appreciate how it builds up our foundational knowledge, but it definitely took a while before I learned how to build a functioning application with a GUI. For a beginner, it seems more motivating to work on something with a tangible end result like excel macros.

Haskell made me cry, the word "monad" still haunts me to this day :cryblob:
 

ganmo

My Neighbour Totoro
Dec 10, 2018
359
414
63
Alright you JS wizards! I feel I keep going round in circles and could love some pointers.

I need to have this flow of events using JS and Axios.
Log in user -> Get Id of that user -> Get todo list for that ID -> Create new entry to the list

Initially I thought I needed to be able to also create a new user but not sure if the API server that we are testing on allows that. I think I can create a new user on the actual site but even there I don't fully get it to work.
I suppose there's no need of security on your assignment? thus your database would be plain text file perhaps, and password would be saved in plain text? If it is important then I would go with some finished libraries for security. Btw do you need to do it in plain javascript? otherwise I suggest using typescript, and as for framework I would suggest using Angular, React or something similar.
 
OP
Le Pertti

Le Pertti

0.01% Game dev
Oct 10, 2018
8,616
22,132
113
45
Paris, France
lepertti.com
I suppose there's no need of security on your assignment? thus your database would be plain text file perhaps, and password would be saved in plain text? If it is important then I would go with some finished libraries for security. Btw do you need to do it in plain javascript? otherwise I suggest using typescript, and as for framework I would suggest using Angular, React or something similar.
Yeah there is no security at all. We are using a API site to handle the data. https://promo1.forticas.fr/api
Right now I can get todos for one specific user but still can't make a user, login a user, create new todo or modify or delete them.XD I'm so far behind haha
Here's my current experimenting, it's pretty much cut and pasting all over the place.

JavaScript:
// CREATE NEW USER
let createUser = e => {
    e.preventDefault();
    axios.post('https://promo1.forticas.fr/api/user', {
            "email": document.querySelector('input[id="newuseremail"]').value,
            "password": document.querySelector('input[id="newuserpassword"]').value
          
            
            
            
        })
        .then(function (response) {
            alert("OK")
        })
        .catch(function (err) {
            console.log(err);
        });
}
document.querySelector('#createuser_submit').addEventListener("submit", createUser)

// LOG IN USER
async function activeUser() {
    await axios.get( 'https://promo1.forticas.fr/api/user/users', {
      auth: {
        user: 'username',
        password: 'password'
      }
    })
  }
document.querySelector('#loginuser_submit').addEventListener("submit", activeUser)



/* async function makeGetRequest() {

  let res = await axios.get('https://promo1.forticas.fr/api/users');

  let data = res.data;
  console.log(data);
}

makeGetRequest(); */


// GET TODO LIST FOR USER
const getTodos = () => {

    let display = ''

    axios.get('https://promo1.forticas.fr/api/todos?owner=42', {
            headers: {
                'accept': 'application/json'
            }
        })
        .then(function (response) {
            response.data.forEach((element, index) => {
                display += `
                <div class="list-group">
                <a href="#" class="list-group-item list-group-item-action">
                <div class="d-flex w-100 justify-content-between">
                <h5 class="mb-1">${element.title}</h5>
                <small class="text-muted">${element.todoAt}</small>
                </div>
                <p class="mb-1">${element.description}</p>
                <small class="text-muted">${element.periority}<small><br>
                <label for="ifdone">Completed</label>
                <input id="ifdone" type="checkbox" ${element.isDone? 'checked' : ''}>
                </a>
                </div>
                `
            })
            document.querySelector('#mainlist').innerHTML = display
        })
        .catch(function (err) {
            console.log(err);
        })

}
document.querySelector('#showlist').addEventListener("click", getTodos)


const nextID = () => Math.max(0, ...todos.map((todo) => todo.id)) + 1;

const addTodo = () => {
    const todo = {
            id: nextID(),
            title: document.querySelector('input[id="todo_title"]').value,
            description: document.querySelector('textarea[id="todo_description"]').value,
            todoAt: Date.now(),
            periority: document.querySelector('select[id="todo_priority"]').value,
            owner: '/api/user/42',
            isDone: false };
    axios.post('https://promo1.forticas.fr/api/todo', todo)
      .then((res) => todos = res.data)
      .then(render)
      .catch((err) => console.log(err));
    
  };


// ADD A NEW TODO
/* const addTodo = e => {
    e.preventDefault();
    axios.post('https://promo1.forticas.fr/api/todo', {
            "title": document.querySelector('input[id="todo_title"]').value,
            "description": document.querySelector('textarea[id="todo_description"]').value,
            "periority": document.querySelector('select[id="todo_priority"]').value,
            
            
        })
        .then(function (response) {
            alert("OK")
        })
        .catch(function (error) {
            console.log(error);
        });
}
 */


document.querySelector('#todo_submit').addEventListener("submit", addTodo)
 
  • Like
Reactions: lashman

ganmo

My Neighbour Totoro
Dec 10, 2018
359
414
63
Yeah there is no security at all. We are using a API site to handle the data. https://promo1.forticas.fr/api
Right now I can get todos for one specific user but still can't make a user, login a user, create new todo or modify or delete them.XD I'm so far behind haha
Here's my current experimenting, it's pretty much cut and pasting all over the place.

JavaScript:
// CREATE NEW USER
let createUser = e => {
    e.preventDefault();
    axios.post('https://promo1.forticas.fr/api/user', {
            "email": document.querySelector('input[id="newuseremail"]').value,
            "password": document.querySelector('input[id="newuserpassword"]').value
         
           
           
           
        })
        .then(function (response) {
            alert("OK")
        })
        .catch(function (err) {
            console.log(err);
        });
}
document.querySelector('#createuser_submit').addEventListener("submit", createUser)

// LOG IN USER
async function activeUser() {
    await axios.get( 'https://promo1.forticas.fr/api/user/users', {
      auth: {
        user: 'username',
        password: 'password'
      }
    })
  }
document.querySelector('#loginuser_submit').addEventListener("submit", activeUser)



/* async function makeGetRequest() {

  let res = await axios.get('https://promo1.forticas.fr/api/users');

  let data = res.data;
  console.log(data);
}

makeGetRequest(); */


// GET TODO LIST FOR USER
const getTodos = () => {

    let display = ''

    axios.get('https://promo1.forticas.fr/api/todos?owner=42', {
            headers: {
                'accept': 'application/json'
            }
        })
        .then(function (response) {
            response.data.forEach((element, index) => {
                display += `
                <div class="list-group">
                <a href="#" class="list-group-item list-group-item-action">
                <div class="d-flex w-100 justify-content-between">
                <h5 class="mb-1">${element.title}</h5>
                <small class="text-muted">${element.todoAt}</small>
                </div>
                <p class="mb-1">${element.description}</p>
                <small class="text-muted">${element.periority}<small><br>
                <label for="ifdone">Completed</label>
                <input id="ifdone" type="checkbox" ${element.isDone? 'checked' : ''}>
                </a>
                </div>
                `
            })
            document.querySelector('#mainlist').innerHTML = display
        })
        .catch(function (err) {
            console.log(err);
        })

}
document.querySelector('#showlist').addEventListener("click", getTodos)


const nextID = () => Math.max(0, ...todos.map((todo) => todo.id)) + 1;

const addTodo = () => {
    const todo = {
            id: nextID(),
            title: document.querySelector('input[id="todo_title"]').value,
            description: document.querySelector('textarea[id="todo_description"]').value,
            todoAt: Date.now(),
            periority: document.querySelector('select[id="todo_priority"]').value,
            owner: '/api/user/42',
            isDone: false };
    axios.post('https://promo1.forticas.fr/api/todo', todo)
      .then((res) => todos = res.data)
      .then(render)
      .catch((err) => console.log(err));
   
  };


// ADD A NEW TODO
/* const addTodo = e => {
    e.preventDefault();
    axios.post('https://promo1.forticas.fr/api/todo', {
            "title": document.querySelector('input[id="todo_title"]').value,
            "description": document.querySelector('textarea[id="todo_description"]').value,
            "periority": document.querySelector('select[id="todo_priority"]').value,
           
           
        })
        .then(function (response) {
            alert("OK")
        })
        .catch(function (error) {
            console.log(error);
        });
}
*/


document.querySelector('#todo_submit').addEventListener("submit", addTodo)
In the part where you get the activeUser, shouldn't you use the actual username/password instead of passing in the string value "username" and "password"?
 
OP
Le Pertti

Le Pertti

0.01% Game dev
Oct 10, 2018
8,616
22,132
113
45
Paris, France
lepertti.com
In the part where you get the activeUser, shouldn't you use the actual username/password instead of passing in the string value "username" and "password"?
Ah yes of course! I need to put in queryselector, been trying to do everything at the same time that I forgot!XD
 

spiel

Junior Member
Apr 17, 2019
121
379
63
Yeah there is no security at all. We are using a API site to handle the data. https://promo1.forticas.fr/api
Right now I can get todos for one specific user but still can't make a user, login a user, create new todo or modify or delete them.XD I'm so far behind haha
Maybe you could elaborate on what you're stuck on. Is it about calling the api, or handling the returned response? Is there an error logged in the console when, say, [UWSL][UWSL]createUser[/UWSL][/UWSL] is executed? It would help with debugging the code.
 
OP
Le Pertti

Le Pertti

0.01% Game dev
Oct 10, 2018
8,616
22,132
113
45
Paris, France
lepertti.com
Maybe you could elaborate on what you're stuck on. Is it about calling the api, or handling the returned response? Is there an error logged in the console when, say, [UWSL][UWSL][UWSL]createUser[/UWSL][/UWSL][/UWSL] is executed? It would help with debugging the code.
Yeah I need to log in the user and return the ID of that user and with that ID get the todo list. Right now I have hardcoded the id in getting the list but want it to be dynamic depending on the ones who logs in.
 

spiel

Junior Member
Apr 17, 2019
121
379
63
Yeah I need to log in the user and return the ID of that user and with that ID get the todo list. Right now I have hardcoded the id in getting the list but want it to be dynamic depending on the ones who logs in.
Okay, so the id of that user has to be saved in a variable somewhere so that the getTodos function can access it.

Now the problem is getting the user id. You want to get the user id associated to that email.

Looking at the api site, it doesn't seem to have a specific endpoint for that. (c[UWSL]orrect me if I missed something[/UWSL][UWSL]). But maybe there are other ways.[/UWSL]

[UWSL]There's [/UWSL]POST /authentication_token to login, bu[UWSL]t it doesn't seem to return anything useful.[/UWSL]
[UWSL]POST /api/user creates a user and returns the user id. But then you'd have to create a new user each time, which doesn't make sense.[/UWSL]
GET /api/users [UWSL]returns a list of all the users, and how convenient, each user object has an id. Perhaps you could find the user with the matching email.[/UWSL]
 
OP
Le Pertti

Le Pertti

0.01% Game dev
Oct 10, 2018
8,616
22,132
113
45
Paris, France
lepertti.com
Okay, so the id of that user has to be saved in a variable somewhere so that the getTodos function can access it.

Now the problem is getting the user id. You want to get the user id associated to that email.

Looking at the api site, it doesn't seem to have a specific endpoint for that. (c[UWSL]orrect me if I missed something[/UWSL][UWSL]). But maybe there are other ways.[/UWSL]

[UWSL]There's [/UWSL]POST /authentication_token to login, bu[UWSL]t it doesn't seem to return anything useful.[/UWSL]
[UWSL]POST /api/user creates a user and returns the user id. But then you'd have to create a new user each time, which doesn't make sense.[/UWSL]
GET /api/users [UWSL]returns a list of all the users, and how convenient, each user object has an id. Perhaps you could find the user with the matching email.[/UWSL]
I can create an user on the site and all, it should be possible to get an users id, that's what I'm trying to do with the login, and in the get for the todos specify the owner. Right now I'm just using the address to the owner, /api/users/42, 42 which is the ID.

Edit, Right now I use the sorting of the list to only show by owner, like this: 'https://promo1.forticas.fr/api/todos?owner=42'
 

spiel

Junior Member
Apr 17, 2019
121
379
63
I can create an user on the site and all, it should be possible to get an users id, that's what I'm trying to do with the login, and in the get for the todos specify the owner.
Yes. My point is, there should be an api that can give you the user id based on the login (i.e. username or email).

Is https://promo1.forticas.fr/api/user/users a valid url? Again, if you run the code, does it show any errors in the console?
 
OP
Le Pertti

Le Pertti

0.01% Game dev
Oct 10, 2018
8,616
22,132
113
45
Paris, France
lepertti.com
Yes. My point is, there should be an api that can give you the user id based on the login (i.e. username or email).

Is https://promo1.forticas.fr/api/user/users a valid url? Again, if you run the code, does it show any errors in the console?


I think you can get a list of all users with the /api/users address and if you one just one user it's with the api/user/{id}

JavaScript:
async function makeGetRequest() {

  let res = await axios.get('https://promo1.forticas.fr/api/users');

  let data = res.data;
  console.log(data);
}

makeGetRequest();
With that I can get a list of all users in the console.

Just need to figure out how to login and get just one user and its ID that then goes to the getting the todo list part.

When I try to log in, I used to have an alert that it was ok but never got it to work.

JavaScript:
async function activeUser() {
    await axios.get('https://promo1.forticas.fr/api/user/users', {
        auth: {
        email: document.querySelector('input[id="newuseremail"]').value,
        password: document.querySelector('input[id="newuserpassword"]').value
        }
    })
    .then(function (response) {
        alert("OK")
    })
    .catch(function (err) {
        console.log(err);
    });
  }
document.querySelector('#loginuser_submit').addEventListener("submit", activeUser)
 
OP
Le Pertti

Le Pertti

0.01% Game dev
Oct 10, 2018
8,616
22,132
113
45
Paris, France
lepertti.com
In our javascript course we have started with VueJS and using local servers to work on sites. Now things are starting to get interesting! I'm still completely lost with vanilla JS but with Vue I kind of don't feel completely useless!
 
  • Like
Reactions: Pommes

Swenhir

Spaceships!
Apr 18, 2019
3,534
7,621
113
In our javascript course we have started with VueJS and using local servers to work on sites. Now things are starting to get interesting! I'm still completely lost with vanilla JS but with Vue I kind of don't feel completely useless!
I have a horrified memory of JS where functions had literally no way to be called by name. You'd reference them from the order in which they were written in the code. I'm pretty sure that something was wrong somewhere but that has given me a rather terrified outlook of web development things.
 
OP
Le Pertti

Le Pertti

0.01% Game dev
Oct 10, 2018
8,616
22,132
113
45
Paris, France
lepertti.com
I have a horrified memory of JS where functions had literally no way to be called by name. You'd reference them from the order in which they were written in the code. I'm pretty sure that something was wrong somewhere but that has given me a rather terrified outlook of web development things.
Yeah sure you have an oder to things, but you can name functions and call them! But yeah vanilla JS is a pain for me too.
 

Swenhir

Spaceships!
Apr 18, 2019
3,534
7,621
113
Yeah sure you have an oder to things, but you can name functions and call them! But yeah vanilla JS is a pain for me too.
I do recall that naming them had no effect on the calling method, but that was way, way back too :). It was indeed vanilla JS, but I think we should call it something else because vanilla implies a level of goodness, and this was an abomination.
 
  • Like
Reactions: Le Pertti

spiel

Junior Member
Apr 17, 2019
121
379
63
Long shot but I'm looking for a cheap way to detect if keys have been left in the lock, and I think something like a RFID sensor on the door + a RFID tag on the keys could work to detect if the two are in close proximity for >10 minutes. I don't have Google Home or Alexa so I don't know if there are third party accessories that can do what I want. Instead, I could rustle up something with a Raspberry Pi (or two)? But I'm new[UWSL] to the hardware side of things so I'm a bit lost.[/UWSL]

[UWSL]My first thought was to install the sensor on a Pi and attach it to the door. A consideration is it has to run off battery power. [/UWSL]This post[UWSL] suggests I'm better off with a low power microcontroller, and that of course is another rabbithole. Then I want to sound an alarm inside the house, so the sensor has to emit info to some server, which means it needs... wifi? Bluetooth?[/UWSL]

[UWSL]If anyone has experience I would love to hear some input, even if it's to tell me it's a bad idea! This sounds horribly complicated for a first project so maybe an electronic door lock is a better investment.[/UWSL]
 

Durante

I <3 Pixels
Oct 21, 2018
4,052
19,546
113
I have very little HW experience, but it does sound like a pi would be overkill for that purpose.

I feel like the easiest way to do it with low battery consumption would be using an Arduino. There is usually lots of documentation on how to use any peripherals with that, and from a quick googling it looks like this holds true for RFID readers as well. You'd also need a wifi peripheral, but again there are lots of those and documentation for them.
 

BlackRainbowFT

Mouse Accelerated Member
Apr 17, 2019
508
1,179
93
38
Switzerland
Long shot but I'm looking for a cheap way to detect if keys have been left in the lock, and I think something like a RFID sensor on the door + a RFID tag on the keys could work to detect if the two are in close proximity for >10 minutes. I don't have Google Home or Alexa so I don't know if there are third party accessories that can do what I want. Instead, I could rustle up something with a Raspberry Pi (or two)? But I'm new[UWSL] to the hardware side of things so I'm a bit lost.[/UWSL]

[UWSL]My first thought was to install the sensor on a Pi and attach it to the door. A consideration is it has to run off battery power. [/UWSL]This post[UWSL] suggests I'm better off with a low power microcontroller, and that of course is another rabbithole. Then I want to sound an alarm inside the house, so the sensor has to emit info to some server, which means it needs... wifi? Bluetooth?[/UWSL]

[UWSL]If anyone has experience I would love to hear some input, even if it's to tell me it's a bad idea! This sounds horribly complicated for a first project so maybe an electronic door lock is a better investment.[/UWSL]
What's the range of an RFID? I'm asking because it might not work depending on which side of the door you left your keys in.

Depending on type of door and the type of key, you might be able to mod the lock itself... If it's a double cylinder you might be able to drill a hole next to the bolt to install a tiny IR sensor?

Or, to avoid having to tamper with the lock itself, you could mount some sort of ring around the keyhole in which you could install an IR sensor.
Just to illustrate it could look something like this:

(I didn't find an exact picture of what I had in mind... Obiously you'd have a keyhole...)
 
  • Like
Reactions: spiel and lashman

spiel

Junior Member
Apr 17, 2019
121
379
63
What's the range of an RFID? I'm asking because it might not work depending on which side of the door you left your keys in.
[UWSL]Good point. I picked passive RFID, thinking to only power the reader and just add the tag to the keyring. Those supposedly go up to a few meters, but of course the cheap readers can only handle a couple inches. Active RFID tags have an extended reach, with the downside of being battery powered. I can't seem to find any for sale though [UWSL][UWSL]:huhblob:[/UWSL][/UWSL][/UWSL]

[UWSL]I'm not familiar with IR so I'll read up on that, thanks![/UWSL]
 
  • Like
Reactions: BlackRainbowFT

Gamall Wednesday Ida

Just a loon, apparently.
Dec 4, 2020
357
1,068
93
France
www.youtube.com
Haskell made me cry, the word "monad" still haunts me to this day :cryblob:
If you enjoyed the typing, pattern-matching, exhaustiveness of compiler warnings and checks, etc,... but did not enjoy monads, you can try OCaml.

It's pretty similar to Haskell (they both belong to the same family of typed functional languages), but OCaml is neither non-strict (~ lazy) nor pure; you can write in imperative style and have side-effects without wearing a Hazmat suit.

It also has OOP capabilities (hence the O in the name). I personally never found a use for them, though, but it's there. The module system was fine for everything I did with it.
 
Last edited:
  • Like
Reactions: spiel

BlackRainbowFT

Mouse Accelerated Member
Apr 17, 2019
508
1,179
93
38
Switzerland
[UWSL]Good point. I picked passive RFID, thinking to only power the reader and just add the tag to the keyring. Those supposedly go up to a few meters, but of course the cheap readers can only handle a couple inches. Active RFID tags have an extended reach, with the downside of being battery powered. I can't seem to find any for sale though [UWSL][UWSL]:huhblob:[/UWSL][/UWSL][/UWSL]

[UWSL]I'm not familiar with IR so I'll read up on that, thanks![/UWSL]
Here's something I cobbled up just to better illustrate a solution using IR (which in the end might be simpler than RFID).

You have a diode emitting infrared light facing an IR sensor... by inserting a key you interrupt the signal and can use that information to play Ride of the Valkyries at full blast.
 
  • Eyes
Reactions: spiel
OP
Le Pertti

Le Pertti

0.01% Game dev
Oct 10, 2018
8,616
22,132
113
45
Paris, France
lepertti.com
Anyone here familier with building websites with java, jsp, database connection and all that nice stuff? I have an assignment but I've constantly been behind that I'm just so lost, the teacher just dumps assignments on us so feel like I'm not learning the important stuff.
 
  • Like
Reactions: BlackRainbowFT