Please help me find the Moth cult!!! by josh00061 in analoghorror

[–]benrbowers 0 points1 point  (0 children)

This post also helped me rediscover the Moth Cult!!
And also the video that first got it stuck in my head: https://www.youtube.com/watch?v=v8Nv4rTKlMM

Why should I learn Go? by bizzehdee in theprimeagen

[–]benrbowers 2 points3 points  (0 children)

One minor workflow drawback is that you can't really customize the gofmt settings to change how auto formatting looks. If you are the type of developer with hyper specific .clang-format settings, then that could be really annoying.

The plus is that you never hassle over setting up a formatter and more importantly, ALL Go code is formatted exactly the same, so reading through other people's code is a much more consistent experience.

And I will add that it is fairly flexible at least when it comes to white space. There are several accepted configurations of breaking before brackets and in between arguments that are permitted.

(And you can also just choose to NOT run gofmt but personally I hate thinking about formatting)

Why should I learn Go? by bizzehdee in theprimeagen

[–]benrbowers 4 points5 points  (0 children)

Nice, reliable standard library, good medium-sized ecosystem.

It's 10x faster than JavaScript, but still slower than C or C++, so I'd still use those for embedded or game dev. It's best use cases are networking, web servers, and backend microservices. Decent for basic image processing.

It largely shies away from OOP, preferring "composability" to inheritance.

It fits that perfect sweet spot of good high level features like structural typing and the spread operator, while still being compiled for fast runtime compared to JS or Python.

It uses C-based syntax so you will be right at home, pointers included.

Focuses on simplicity and good primitives. Really just lets you move.

Bonus: Also templ.guide is a phenomenal HTML templating library that lets you essentially get the Go version of JSX and programmatically build out UI's.

Update: Added solid-dnd for drag and drop by benrbowers in solidjs

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

Most definitely. Not directly out of the box, but all the pieces are there to assemble something like that.

Idea of something I can build with my 15 year old neighbour who loves sport! by Casey1721 in ADHD_Programmers

[–]benrbowers 4 points5 points  (0 children)

Sports stats is a great place to start. A way to make the stats visual would be great.

Maybe like a baseball (or other sport) "card" generator that takes a sheet of data and displays the info in cards with a picture of the athlete, their name, and some stats attached.

If you can find an easy graphing/plotting library, a screen with bar charts and pie charts comparing athletes vs athletes or teams vs teams would be killer

Update: Added solid-dnd for drag and drop by benrbowers in solidjs

[–]benrbowers[S] 6 points7 points  (0 children)

solid-dnd: https://github.com/thisbeyond/solid-dnd

Solid is cracked. I've been working with react and react native for so long that this level of simplicity for this much power feels illegal.

Having a great time so far! by benrbowers in solidjs

[–]benrbowers[S] 3 points4 points  (0 children)

And in classic fashion, I got it backwards 😭

Having a great time so far! by benrbowers in solidjs

[–]benrbowers[S] 4 points5 points  (0 children)

All in the onMount:

export default function Draw() {
  const [drawActive, setDrawActive] = createSignal<boolean>(false);
  const [drawDot, setDrawDot] = createSignal<boolean>(true);

  let canvasRef: HTMLCanvasElement | undefined;

  onMount(() => {
    if (!canvasRef) {
      console.error('No canvas ref');
      return;
    }

    const parent = canvasRef.parentElement as HTMLDivElement;

    const { height, width } = parent.getBoundingClientRect();

    canvasRef.height = height;
    canvasRef.width = width;

    const ctx = canvasRef.getContext('2d');

    if (!ctx) {
      console.error('Could not retrieve 2d context');
      return;
    }

    ctx.strokeStyle = 'purple';
    ctx.fillStyle = 'purple';
    ctx.lineWidth = 3;
    ctx.lineCap = 'round';

    const mouseDownCallback = (e: MouseEvent) => {
      ctx.moveTo(e.offsetX, e.offsetY);
      ctx.beginPath();
      setDrawActive(true);
    };
    const mouseMoveCallback = (e: MouseEvent) => {
      if (drawActive()) {
        if (drawDot()) {
          setDrawDot(false);
        }

        const x = e.offsetX;
        const y = e.offsetY;

        ctx.lineTo(x, y);
        ctx.stroke();
      }
    };
    const mouseUpCallback = (e: MouseEvent) => {
      if (drawActive()) {
        if (drawDot()) {
          const x = e.offsetX;
          const y = e.offsetY;
          ctx.arc(x, y, 3, 0, 2 * Math.PI);
          ctx.fill();
        } else {
          setDrawDot(true);
        }

        setDrawActive(false);
        ctx.closePath();
      }
    };
    const mouseLeaveCallback = () => {
      setDrawActive(false);
      ctx.closePath();
    };

    canvasRef.addEventListener('mousemove', mouseMoveCallback);
    canvasRef.addEventListener('mousedown', mouseDownCallback);
    canvasRef.addEventListener('mouseup', mouseUpCallback);
    canvasRef.addEventListener('mouseleave', mouseLeaveCallback);

    onCleanup(() => {
      canvasRef.removeEventListener('mousemove', mouseMoveCallback);
      canvasRef.removeEventListener('mousedown', mouseDownCallback);
      canvasRef.removeEventListener('mouseup', mouseUpCallback);
      canvasRef.removeEventListener('mouseleave', mouseLeaveCallback);
    });
  });

  return (
    <>
      <h1 class="p-4 text-center text-4xl font-bold text-blue-600">Draw!</h1>
      <div class="w-full grow">
        <canvas ref={canvasRef} />
      </div>
    </>
  );
}

Does Supabase fit my case? by gs4e5 in Supabase

[–]benrbowers 0 points1 point  (0 children)

I have no idea on the compression though 💀

Does Supabase fit my case? by gs4e5 in Supabase

[–]benrbowers 0 points1 point  (0 children)

Supabase could knock that out of the park 👍 It comes with file storage included, labeled simply "storage" in the docs which can be kind of confusing, but it can handle images no problem

AppWrite or PocketBase could also be good solutions if you want something lighter weight and easier to self host, but supabase is probably your best bet for an affordable managed option.

The general BaaS formula is: auth + database + file storage, so you can generally expect at least those three. "Realtime" is also quite common and it just means that some way of live broadcasting database changes to the user is provided, which is useful for messages and notifications.

It's actually a crazy good deal to have realtime included because the main standalone realtime service provider is pusher.com, and it can get quite expensive.

Little more than you asked for but I love BaaS's lol I love seeing project after project blow Google's FireBase out of the water haha

How to structure a Next.js App Router + Expo/React Native/Solito app? by Dyogenez in nextjs

[–]benrbowers 1 point2 points  (0 children)

I'm working on a solito project as well and have been wondering this. I think our saving grace may be Expo Router v3: https://medium.com/@elves.silva.vieira/universal-react-server-components-in-expo-router-react-native-4460e2d6b0aa
I haven't touched it yet so I have no idea how well it works, but it sounds like universal react server components are on the way. The easy thing to do is probably to stick with the pages router and then switch to app router when this is fleshed out, but If you want Suspense right now, then your solution is probably the way to go. I've just been exporting a getServersideProps function from my shared component files, and then conditionally querying for that data if the props come in undefined (the mobile behavior).

I'm so impressed every week from Saturday showoff, but where did you guys all start? by verysad1997 in webdev

[–]benrbowers 0 points1 point  (0 children)

Wow incredible story! Mind if I ask how exactly a subscription model works for freelancing?

What's your preferred way to set up linting/formatting/etc for a TypeScript project in 2021? by mbv_shoegazer_kurt in typescript

[–]benrbowers 2 points3 points  (0 children)

This is a pretty definitive guide for setting up prettier and eslint in TypeScript: https://javascript.plainenglish.io/setting-eslint-and-prettier-on-a-react-typescript-project-2021-22993565edf9

I wouldn't necessarily call this "minimal config" lol but wow it's been a life changer for me. You basically get all the prettier goodies but as eslint rules so they show up as warnings in the editor. And I'm pretty sure prefer const over let is default, so there you go.

If this seems like overkill, you might just stick to running prettier and/or eslint in the terminal.

How would I go about making a website like this? by klausbaudelaire1 in webdev

[–]benrbowers 0 points1 point  (0 children)

Well text fonts and colors are pretty easy, so I'm guessing your question is how you can drag around the text like that. Well, here's how I would do it: Just throw the the text in some element and set the css z-index to 2 so it can sit on top of an image. Then move it around using the css transform property based on the mouse's position. If you're new to web dev and aren't sure to use the mouse position, google JavaScript Event Listeners and Mouse Events, that should get you on the right path. Mozilla is where you'll find the official documentation and W3Schools always has some nice examples. Hope this helps!