51
27
52
17
53
13

Maybe this is a cultural thing, but the idea of a solid food hitting the floor and it suddenly being off-limits is alien to me. I was taking a pill for pain this morning. I dropped it on the floor and picked it up and swallowed it with water anyways, and a classmate I was with had this reaction like I had just eaten a worm. Does it supposedly cause illness or bad luck, because I've never gotten any in all my years...

54
-13
submitted 2 weeks ago* (last edited 2 weeks ago) by Allah@lemm.ee to c/casualconversation@lemm.ee

try using this code do you think it will work?

Below is a minimal example of how you can add a real‐time chat box that only your authenticated users can use. It uses:

  • Node.js + Express for the web server
  • express‐session to track logged-in users
  • Socket.io for real-time messaging

You’ll need to adapt the authentication check to however you store your users (database, JWTs, etc.), but this will give you the core of “only logged‐in folks see/use the chat.”


1. Install dependencies

npm init -y
npm install express express-session socket.io

2. server.js

const express = require('express');
const http    = require('http');
const session = require('express-session');
const SocketIO = require('socket.io');

const app = express();
const server = http.createServer(app);
const io = new SocketIO(server);

// 1) Session middleware
const sessionMiddleware = session({
  secret: 'YOUR_SESSION_SECRET',
  resave: false,
  saveUninitialized: false,
  // store: you can add a store like connect-mongo here
});
app.use(sessionMiddleware);

// 2) Make session available in socket.handshake
io.use((socket, next) => {
  sessionMiddleware(socket.request, socket.request.res || {}, next);
});

// Serve static files (our chat page + JS)
app.use(express.static('public'));

// 3) A simple “login” route for demo purposes.
//    In real life you’d check a DB, hash passwords, etc.
app.get('/login', (req, res) => {
  // e.g. ?user=alice
  const username = req.query.user;
  if (!username) return res.sendStatus(400);
  req.session.user = { name: username };
  res.redirect('/chat.html');
});

// 4) Protect chat page
app.get('/chat.html', (req, res, next) => {
  if (!req.session.user) return res.redirect('/login.html');
  next();
});

// 5) Handle socket connections
io.on('connection', socket => {
  const req = socket.request;
  if (!req.session.user) {
    // kick out any un‐authenticated socket
    return socket.disconnect(true);
  }

  const user = req.session.user.name;
  socket.broadcast.emit('message', {
    from: 'SYSTEM',
    text: `${user} has joined the chat`
  });

  socket.on('message', msg => {
    io.emit('message', {
      from: user,
      text: msg
    });
  });

  socket.on('disconnect', () => {
    socket.broadcast.emit('message', {
      from: 'SYSTEM',
      text: `${user} has left the chat`
    });
  });
});

server.listen(3000, () => {
  console.log('Listening on http://localhost:3000/');
});

3. public/chat.html

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Chat Room</title>
  <style>
    #messages { list-style: none; padding: 0; max-height: 300px; overflow-y: scroll; }
    #messages li { margin: 5px 0; }
    #form { display: flex; }
    #input { flex: 1; }
  </style>
</head>
<body>
  <h1>Chat Room</h1>
  <ul id="messages"></ul>
  <form id="form">
    <input id="input" autocomplete="off" placeholder="Type a message…" /><button>Send</button>
  </form>

  <script src="/socket.io/socket.io.js"></script>
  <script>
    const socket = io();

    const form = document.getElementById('form');
    const input = document.getElementById('input');
    const messages = document.getElementById('messages');

    socket.on('message', msg => {
      const li = document.createElement('li');
      li.textContent = `${msg.from}: ${msg.text}`;
      messages.appendChild(li);
      messages.scrollTop = messages.scrollHeight;
    });

    form.addEventListener('submit', e => {
      e.preventDefault();
      if (input.value.trim()) {
        socket.emit('message', input.value);
        input.value = '';
      }
    });
  </script>
</body>
</html>

4. How It Works

  1. Session setup We use express-session so that when a user “logs in” (e.g. via your existing form/database), we store { user: { name: '…' } } in req.session.

  2. Socket authentication By re-using the same session middleware in Socket.io’s io.use(…), every incoming socket has access to socket.request.session. If there’s no session.user, we immediately disconnect() them.

  3. Real-time chat

    • On connect/disconnect we broadcast a system message.
    • On client‐side, every message the user sends is emitted and broadcast to all.
  4. Protecting the page We guard chat.html in Express so that if you go there directly, you’ll get bounced to /login.html (you’d build a real login page).


Next Steps

  • Integrate with your real user database. Replace the demo /login route with your own logic.
  • Persist chat history if you want to store messages (e.g. in MongoDB or MySQL).
  • Add rooms or private messaging by namespace or room support in Socket.io.
  • Style it and embed it in your existing layout (lemm.ee) CSS.
55
21
Sauna + swimming (hackertalks.com)

I've started to use my gyms sauna. For two weeks now I get into the sauna until I can't stand it anymore then go dip into the pool.

My heat tolerance has improved rapidly, I can now do 80C for 20m.

Ive noticed my sleep dramatically improving on sauna days.

Do you use a sauna? How do you like it?

56
29

If this has been done before, I'd love to see video of a race.

I imagine miniature hay bales, stacked tires, and tiny traffic cones to mark the route, and POV drivers and real crowds watching the action all over the golf course.

57
76

I just remembered that back when YouTube generally used to show you actually related videos in the sidebar sooned or later you'd reach this so-called weird part which was basically an assortment of increasingly unhinged recommendations. It's funny to me that back then that was basically the only time when the algorithm failed to be invisible. But I was also quite young when the weird part of YouTube was a thing so I'd be interested to know if any of you remember specific clips you've seen there and any other details I might not have mentioned. The only videos that seem to have left a lasting impression on me were a 9/11 conspiracy documentary and a slideshow about a horrific, likely fake skin disease.

58
20
59
13
60
66

To me, money isn’t everything. It’d be nice if I got something that cost a lot, but I’d also be fine with something cheap as long as it’s high-quality and not like a Temu ring or something.

We got each other the same ring off Amazon for $12.😂 😅

61
21
62
25
63
49
64
38
65
14
66
34
submitted 2 weeks ago* (last edited 2 weeks ago) by pebbles@sh.itjust.works to c/casualconversation@lemm.ee

I never really understood, but now that that house bill passed that may end up blocking AI regulation from individual States. I get it. I don't like knowing that even if everyone in my state wanted to stop companies from using AI for hiring decisions, we couldn't.

Texans, I feel you.

Edit: I'm learning a lot about Texas in this thread. Thanks for all the context folks.

67
64

Time to look for a new job ig.

My boss just grinned and laughed awkwardly as I explained why I want a raise and why I deserve it. The company wants me to get certifications on my own time and I want more money to make up sacrificing my free time. If I don't get the raise (pretty sure they aren't going to give it to me) I'm not getting the certs they want and will do the bare fucking minimum.

Then in a meeting with all the bosses and HR, I asked if they could ask the other employees to message me if they're coming in sick so I can mask up. I'm the first person here every day and I have an autoimmune disease and have gotten very sick from my coworkers multiple times this year. My superiors told me that they can ask but told me that I NEED to take precautions outside of work. They told me it's only fair that I take precautions all the time outside of work since apparently people texting me before they come in is too much to ask for. They brought up places outside of work that they know I go to and were so shitty about me not masking up there. I was also asked if I considered a permanent wfh position but was then told that permanent wfh would prevent me from advancing to higher positions. I have already had a promotion dangled in front of my face for a year only to be told that the standards I need to meet before that are higher than the standards people already in that position are already held to.

I was also given shit for calling off for being sick or having migraines. God forbid I take care of myself.

I'm getting surgery in July and their only concern when I told them was how much time I'll need to take off. I was prepared to only take one day off and suffer through working from home. Now they're pushing me to go on short term disability for my recovery. I can't financially afford that.

68
86

I'm nervous as hell.

69
18
70
36
71
23

Do you believe our society is currently programmed to victim blame or we are already doing the best we can to handle malicious people?

72
28
submitted 3 weeks ago* (last edited 3 weeks ago) by Typewar@infosec.pub to c/casualconversation@lemm.ee

I've listened to a lot of different music over the years. I listen to music so much all day mostly as background noise... I recently moved to a new place, and the neighbor sometimes plays Jazz in the weekends. I seriously open the windows and turn off my own music. Something about it is just soo nice and chill. Something with the vibe, I don't know. The closest genre I listen to similar to Jazz, is Downtempo. Here for reference: Youtube Music | Spotify

73
2
submitted 3 weeks ago* (last edited 3 weeks ago) by Grogon@lemmy.world to c/casualconversation@lemm.ee

About a year ago, I got married. I couldn’t invite everyone from my friend group, so I decided to only invite people I actually spend time with one-on-one outside of group stuff over the past year or two.

There are two people in the group—one of them being the one this is really about—who I honestly wouldn’t even know if they stopped hanging out with our shared friends. We’ve never done anything just the two of us. We only ever see each other at parties every few months.

Thing is, those two are also the ones who organize everything. They’ve kind of created their own mini friend group inside the bigger group—like 6 or 7 people out of 15 who get invited to the real stuff: birthdays, city trips, holidays, etc. And five of those people are actually close friends of mine.

When I invited 9 of the 15 to my wedding, I told people I just couldn’t include everyone. Most people were cool with it, even her best friend didn’t mind. But now, she’s throwing a party for her 30th birthday and invited everyone—except me.

She’s never invited me to her birthday before, which is part of why I didn’t invite her to the wedding in the first place. I figured if we’re not close enough for a birthday dinner, a wedding isn’t happening either.

But this time it’s different. She invited literally everyone else in the group. My best friend wasn’t invited either, but that makes sense—he doesn’t really know her. With me, though, I’m pretty sure it’s payback for not inviting her to my wedding.

And yeah... I don’t know. I usually don’t care about her events because I’m not close with her. But this time feels different. Not because I wanted to go to her party—but because everyone else is going. I know I’ll be left out when they’re all talking about it later. I’ll miss out on those shared moments, even if it’s with people I do care about.

I get it. I didn’t invite her, she’s not inviting me. Fair enough. But I can’t help feeling weird about it. Like, yeah, maybe I started this when I didn’t include her—but at the same time, she’s the one who’s always made the group feel split in two. She’s been excluding people for years.

Anyway, here we are. Not invited. And for once, it actually kind of stings. Wish it didn’t. But this one hits different.

I probably won't be able to fix this cause even on group gatherings we rarely have a 1:1 conversation. Like never had... she is the person that is always there and in the middle of all but if we talk it's in a group setting. I can't remember if I ever talked alone with her.

I personally would have invited her to something like a birthday. But I don't celebrate my birthdays. I never did and I don't care about my birthday. Three years ago I planned a trip to a theme park and I invited everyone (and her) to join and organised everything. A few weeks later she organised something else but only with the 5 other friends. So that was the last time I organised something.

It's weird because this person also makes me feel very insecure. It's not that I don't like her but when she is around I am totally different. I am more quiet, scared to say things I would normally say,... it's a very loud person and I just don't like that. But that is all I have to her. Maybe she is different alone but I sometimes do wonder why everyone likes her. She likes to be in the middle of everything, kind of like attention seeker. But not really either... To me she comes off as passive toxic. If I just observe her at parties I am always happy I only see her at these parties and not on vacations, trips etc... but maybe it's also cause I am mad about the splitting of our group and that she didn't invite me 3 years ago after I organised a trip first.

This feeling actually made me more silent, I avoid going to these parties more and more. I go more to the gym, do things with 2 other friends but I feel like I am isolating myself more and more and trying to find new people which is very hard. I go to the gym like 6 times a week and talk with someone there but that is it. This whole thing makes me feel like I am not really wanted anymore in that group and maybe she is saying things to my other friends about me. Or I am just thinking this going full psycho and nothing is going on. In the end maybe she just forgot to invite me and doesn't even care - but that I don't believe. This time she excluded me on purpose and invited the others who she normally never invites intentionally.

74
34
75
16
view more: ‹ prev next ›

[Migrated, see pinned post] Casual Conversation

3391 readers
1 users here now

We moved to !casualconversation@piefed.social please look for https://lemm.ee/post/66060114 in your instance search bar

Share a story, ask a question, or start a conversation about (almost) anything you desire. Maybe you'll make some friends in the process.


RULES

  1. Be respectful: no harassment, hate speech, bigotry, and/or trolling.
  2. Encourage conversation in your OP. This means including heavily implicative subject matter when you can and also engaging in your thread when possible.
  3. Avoid controversial topics (e.g. politics or societal debates).
  4. Stay calm: Don’t post angry or to vent or complain. We are a place where everyone can forget about their everyday or not so everyday worries for a moment. Venting, complaining, or posting from a place of anger or resentment doesn't fit the atmosphere we try to foster at all. Feel free to post those on !goodoffmychest@lemmy.world
  5. Keep it clean and SFW
  6. No solicitation such as ads, promotional content, spam, surveys etc.

Casual conversation communities:

Related discussion-focused communities

founded 2 years ago
MODERATORS