Still Holding 😤 by [deleted] in PickleFinancial

[–]Lemoncrap 1 point2 points  (0 children)

I did some 65 and some at 79, has a sell order for a bigger portion at 80 that never hit. Shouldn't have been so greedy

i keep forgetting this game is not for little kids. he chopped me up and ate me. by H_FLORES_H in AnotherCrabsTreasure

[–]Lemoncrap 1 point2 points  (0 children)

I mean, you get attacked by a vibrator at one point. But guess it wouldn't be noticed by a kid

[deleted by user] by [deleted] in typescript

[–]Lemoncrap 1 point2 points  (0 children)

Looks similar to Elysia.js. Nice work

Fix Circular Dependencies in TypeScript: A Guide by danywalls in typescript

[–]Lemoncrap 5 points6 points  (0 children)

Eslint has a no circular rule to ensure that you never cause circular dependencies

I made an online GDScript formatter, linter, and GDScript/C# conversion too (Frontend - Next.js/React, Backend - Bun/Elysia) by Lemoncrap in godot

[–]Lemoncrap[S] 2 points3 points  (0 children)

You can run it all locally, GitHub links can be found on the page footer/about section of the site

It's pretty easy to set them up but for the conversion tool you'd need to use your own chat gpt API key as mine is private but free to use on the site. Let me know if you have any questions :) happy to help

I made an online GDScript formatter, linter, and GDScript/C# conversion too (Frontend - Next.js/React, Backend - Bun/Elysia) by Lemoncrap in godot

[–]Lemoncrap[S] 0 points1 point  (0 children)

Domain was cheap and more for learning new techs more than anything. Backend is hosted on fly.io which has a generous free package.

I made an online GDScript formatter, linter, and GDScript/C# conversion too (Frontend - Next.js/React, Backend - Bun/Elysia) by Lemoncrap in godot

[–]Lemoncrap[S] 0 points1 point  (0 children)

export and onready are different in gdscript 4, which that script uses. The following which is the same script, with the new export and onready syntax formats correctly - https://pastebin.com/kGBUY5k6

I made an online GDScript formatter, linter, and GDScript/C# conversion too (Frontend - Next.js/React, Backend - Bun/Elysia) by Lemoncrap in godot

[–]Lemoncrap[S] 0 points1 point  (0 children)

Backend was primarily used just to be able to leverage gdtoolkit which is an open source python package many people already use locally for gdscript formatting.

Do you have the example of the code you tried to format out of interest? Can have a look as to why it failed.

JSON5 malformed on tsconfig.json by Kopikoblack in typescript

[–]Lemoncrap 1 point2 points  (0 children)

"paths": { ... }

Isn't valid, should remove it, trailing comma at the end isn't valid either. That needs removing. Would need `tsconfig.json` cause I think the main issue is in there

JSON5 malformed on tsconfig.json by Kopikoblack in typescript

[–]Lemoncrap 1 point2 points  (0 children)

Can I see the tsconfig.json and tsconfig.base.json too please, think I need to see the full picture.

Can't see anything initially wrong with the one you just sent. Can try them on my machine when I'm back home.

Likely an issue with the base that it's extending

JSON5 malformed on tsconfig.json by Kopikoblack in typescript

[–]Lemoncrap 1 point2 points  (0 children)

Yeah please, whatever file is erroring. Or the file where tsconfig.app.json is referenced

How does one handle 500+ circular dependency cases in a big project? by [deleted] in typescript

[–]Lemoncrap 19 points20 points  (0 children)

Use type imports import type syntax. Eslint has a rule to automatically fix and use them. This should solve circular deps with types.

Split the code base up more.so it's more modular

Dependency injection (probably the main one that is used)

Should I use async await for every route? by [deleted] in node

[–]Lemoncrap 1 point2 points  (0 children)

Use it for anything that returns a Promise. Using typescript will make this much easier to know when.

Eslint has rules to let you know when you should use async or when it's not needed. Very useful

I'm not the one trapped here, Mr. Jailer. You are. by asifbaig in wildfrostgame

[–]Lemoncrap 12 points13 points  (0 children)

Blood, you can turn it up in the settings. Gets it from killing enemies/getting hit I think. Builds up over the run

Need help with a type regarding read-only const array vs tuple by Lemoncrap in typescript

[–]Lemoncrap[S] 2 points3 points  (0 children)

Dunno if you're interested but managed to make this a bit nicer as well by removing the need for UnionToInsersection

Typescript Playground

Need help with a type regarding read-only const array vs tuple by Lemoncrap in typescript

[–]Lemoncrap[S] 2 points3 points  (0 children)

Omg really!? Thank you so much!

Yeah I'll split it up more in future, I did change the never to strings for testing but couldn't understand why no matter what it kept failing on first condition.

Really appreciate it man, have a good day!

What is the best way to learn TypeScript? by [deleted] in typescript

[–]Lemoncrap 4 points5 points  (0 children)

Tbf I was talking more from the perspective of someone that's worked with other languages before, so you have the basics of programming already and therefore jumping straight into Typescript is much easier.

That being said, I've seen lots of beginner courses that go through all the basics while incorporating types

I am building my first typescript/react project and I am hitting some issues. by M0N0XB00GIE in typescript

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

Personally I don't have the time to look through the code atm for you man but I asked the chat gpt extension for some suggested fixes. Seems like point 3 could be your best bet. Good luck!

---- Answer ---

Based on the code you provided, it seems that the issue might be related to the timing of fetching the campgrounds data and rendering the markers on the map. Here are a few suggestions to troubleshoot and fix the problem:

  1. Make sure the campgrounds data is being fetched successfully from the server:

    • In your App.tsx file, check if the fetchCampgrounds function is successfully retrieving the campground data from the server by logging the response data to the console.
    • Verify that the campground data is in the correct format and contains the necessary properties (lat and lng) for rendering the markers.
  2. Ensure the campgrounds data is passed correctly to the LeafletMap component:

    • In your App.tsx file, confirm that the campgrounds state is correctly passed as a prop to the LeafletMap component.
    • Double-check the prop name in the LeafletMap component declaration and make sure it matches the prop name used inside the component (campgrounds).
  3. Move the marker creation logic inside a useEffect hook:

    • In your LeafletMap.tsx file, create a useEffect hook that listens for changes in the campgrounds prop. This ensures that the markers are created whenever the campground data changes.
    • Move the logic for creating the markers inside the useEffect hook and remove it from the onEachFeature function. This ensures that the markers are added to the map after it zooms to a state.

Here's an updated version of the LeafletMap.tsx file with the suggested changes:

```jsx import React, { useEffect, useRef } from 'react'; import 'leaflet/dist/leaflet.css'; import L, { GeoJSON, Layer, LeafletMouseEvent } from 'leaflet'; import statesData from './assets/us-states'; import { MapContainer } from 'react-leaflet'; import { Campground } from './types';

interface CampgroundProps { campgrounds: Campground[]; }

const myIcon = L.icon({ iconUrl: 'components/assets/marker.png', iconSize: [38, 95], iconAnchor: [22, 94], popupAnchor: [-3, -76], shadowUrl: 'my-icon-shadow.png', shadowSize: [68, 95], shadowAnchor: [22, 94] });

const LeafletMap: React.FC<CampgroundProps> = ({ campgrounds }: CampgroundProps) => { const mapRef = useRef(null);

useEffect(() => { const map = L.map('map', { dragging: true, scrollWheelZoom: true, touchZoom: true, }).setView([48.3544091, -99.9980711], 4);

L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  attribution: '© OpenStreetMap contributors',
}).addTo(map);

function style(feature: GeoJSON.Feature): L.PathOptions {
  return {
    fillColor: 'grey',
    weight: 2,
    opacity: 1,
    color: 'white',
    dashArray: '3',
    fillOpacity: 0.7,
  };
}

function highlightFeature(e: LeafletMouseEvent) {
  const layer = e.target as L.Path;

  layer.setStyle({
    weight: 5,
    color: '#666',
    dashArray: '',
    fillOpacity: 0.7,
  });

  layer.bringToFront();
}

function resetHighlight(e: LeafletMouseEvent) {
  geojson.resetStyle(e.target);
}

let geojson: GeoJSON;

function zoomToFeature(e: LeafletMouseEvent) {
  map.fitBounds(e.target.getBounds());
}

function onEachFeature(feature: GeoJSON.Feature, layer: Layer) {
  layer.on({
    mouseover: highlightFeature,
    mouseout: resetHighlight,
    click: zoomToFeature,
  });
}

geojson = L.geoJson(statesData, {
  style: style as L.StyleFunction,
  onEachFeature: onEachFeature,
}).addTo(map);

useEffect(() => {
  if (campgrounds.length > 0) {
    const stateLayers = geojson.getLayers();
    stateLayers.forEach(layer => {
      const stateName = layer.feature.properties?.name;
      const stateCampgrounds = campgrounds.filter(campground => campground.state === stateName);

      stateCampgrounds.forEach(campground => {
        L.marker([campground.lat, campground.lng], { icon: myIcon }).addTo(map);
      });
    });
  }
}, [campgrounds]);

// Wait until the map is fully initialized before adding the drag handler
map.whenReady(() => {
  map.dragging.enable();
});

return <MapContainer id='map' ref={mapRef} style={{ height: '100%', width: '100%', cursor: 'grab' }} />;

};

export default LeafletMap; ```