Oddbean new post about | logout

Notes by chuckis | export

 What's your favorite mobile note app?
#askNostr 
 Logseq 
 The day will come when you will laugh at what scares you today. I tell myself this more and more often. 
 is it just me, or has the metal used in chain saw chains gotten alot softer over the last decade? 
 the resistance of nature has increased  
 Here is my [creation](https://chuckis.github.io/flyingpoop/). I dreamed about the game. It was created in a couple of hours using chatgpt. Now I want to make it in more humane-way, with sprites and develop levels etc. If you have any ideas, throw them in the [github] (https://github.com/chuckis/fanex) issue. 
 #til "Mandella effect" from 14 y.o.  
 I know nothing of rust #programming, but devouring my RAM and crashing while compiling isn't impr... 
 picolisp 
 Using an unfamiliar #meme ... it's like trying to import a class from an unknown library. You wanted a banana, but ended up with the jungle and a monkey instead 
 How often do you look at your global feed, on Nostr?

nostr:note107qta3fhn9kf3jxc78y5j0rdj62zvalv... 
 never 
 Прекрасная осень, разыскиваю Михаила Феничева вместо грибов. 
 Programmer's Day, nostr!

#programming 
 i detest 'modern' document formats.
blech.
give me .txt or .html 
 Which client can do this? 
 Citrine turnes off in background. 
 Citrine 
 I'm watching a wonderful film and I recommend it to everyone, even before I've finished watching the first episode.

https://youtu.be/HVobfdjETew
https://image.nostr.build/2df3da9c341304e1fa9d08ee164cdd431263266d667e7dc2e276b1c535e7157d.jpg 
 https://image.nostr.build/e04504c6ed575261d9ab7de15ca7ab3efbb197baaa678ca49c4f2bd8403d02a1.jpg me terrible in graphic design. Just trying to mash up nostr and logseq icons. What do you think, plebs? 
 Can someone remind me how I can block words? 

#asknostr  
 Security filters -> hidden words 
 test 
 #productivity
#devdiary #logseq

**Not Another Nostr Client – Just Pure, Fast Posting.**
Forget the endless tabs and heavy interfaces. This plugin for logseq is here to give you a faster way to get your thoughts out there. 
Whether it's a few quick lines or a deep-dive post, it's all about hitting send to your followers without the extra noise. This is not a client—this is your direct line to the relay, a tool built for efficiency and simplicity.
Think of it as your personal "publish now" button, ready whenever inspiration strikes. Be part of something streamlined and help me shape a tool that puts your voice first.

[Release](https://github.com/chuckis/screenplay/releases/tag/pre-0.0.1)

DM @chuckis 
 I will tell my descendants that I was on Nostr even before ReplyGuy started 
 #asknostr
An attempt to calculate the total number of users would be a move towards centralization, wouldn't it? 
 после непродолжительных исследований, обнаружена жизнь в simplex, hah 
 Early Adopters Wanted! 
 ITS ALREADY BETTER THAN THE CUCKED SOCIAL NETWORKS 
 DEFINITELY YES!
nostr:nevent1qqsveyud7spmd83ratmf62wtm0wxvgqw8lz29sq647cgnp3xa5znpuqdgjdkc 
  ок 
 https://github.com/chuckis/screenplay/releases/tag/pre-0.0.1

#logseqplugin
#devdiary

This is my first release! Sure, it's a bit rough around the edges. Automation, TypeScript, unfamiliar API territories—yeah, all that jazz. It was just an itch I had to scratch! It's raw and green, but hey, I think it's fitting for Nostr. I’m asking for help and inviting collaboration. Alright, I'm off to grab some coffee! 😊
 
 Production-level software projects do not have downtime. They are not the corner store. They're d... 
 I would say, a kind of priests  
 Thinking about all that stuff with sprites, collisions, music, engine. A lot of abstractions. Or may it be a simple such as now...
nostr:nevent1qqsrqjjx3ecgl30343u340kk03ww4drhce5rkx4zmxw3ll4k0pn9trgpp4mhxue69uhkummn9ekx7mqzyzahx52vsznezm0agty6m24gjfuft6y5mnmnf0qgdn9r869xaq4xqqcyqqqqqqgly54s2 
 [repository](https://github.com/chuckis/my-slider-app)

nostr:nevent1qqs0y7lgdgtzyqq7l56v9p85lk0c2mwv2tpxa9tzp5vnh83mklyusuqzyzahx52vsznezm0agty6m24gjfuft6y5mnmnf0qgdn9r869xaq4xqqcyqqq823cfhuq5w 
 It took about 3 hrs to make the app and tutorial. You know what I mean. 
nostr:nevent1qqs2h3657avejqqhrvuelcwdjr9n9qhj7cdmn5r5dlesdcyxr9hnhygpp4mhxue69uhkummn9ekx7mqzyzahx52vsznezm0agty6m24gjfuft6y5mnmnf0qgdn9r869xaq4xqqcyqqqqqqgtm36hd
https://image.nostr.build/ebcf2e8afb35bb7dcbda242b88bc4f878ea137d000daa5209b1455afea2eaa36.jpg 
 In this tutorial, we'll build a React component using TypeScript that includes sliders for adjusting length, width, height, and volume. You will be able to fix the values of the sliders and automatically recalculate other parameters based on the volume.

### Step 1: Create a New Project

First, let's create a new project using `Create React App` with the TypeScript template.

Open your terminal and run the following command:

```bash
npx create-react-app volume-slider-app --template typescript
```

After the installation is complete, navigate to the project directory:

```bash
cd volume-slider-app
```

Start the project with the following command:

```bash
npm start
```

The project will open in your browser at `http://localhost:3000`.

### Step 2: Basic Slider Component

Let's create a basic component that will contain sliders for length, width, and height.

1. Create a new file `src/SliderComponent.tsx`.
2. Add the following code:

```tsx
import React, { useState } from 'react';

const SliderComponent: React.FC = () => {
  const [length, setLength] = useState<number>(10);
  const [width, setWidth] = useState<number>(10);
  const [height, setHeight] = useState<number>(10);

  return (
    <div>
      <div>
        <label>Length: {length}</label>
        <input
          type="range"
          min="1"
          max="100"
          value={length}
          onChange={(e) => setLength(Number(e.target.value))}
        />
      </div>
      <div>
        <label>Width: {width}</label>
        <input
          type="range"
          min="1"
          max="100"
          value={width}
          onChange={(e) => setWidth(Number(e.target.value))}
        />
      </div>
      <div>
        <label>Height: {height}</label>
        <input
          type="range"
          min="1"
          max="100"
          value={height}
          onChange={(e) => setHeight(Number(e.target.value))}
        />
      </div>
    </div>
  );
};

export default SliderComponent;
```

3. Open the `src/App.tsx` file and replace its content with the following:

```tsx
import React from 'react';
import SliderComponent from './SliderComponent';

const App: React.FC = () => {
  return (
    <div className="App">
      <h1>Volume Calculator</h1>
      <SliderComponent />
    </div>
  );
}

export default App;
```

Now, when you refresh your browser, you'll see three sliders that allow you to adjust the length, width, and height.

### Step 3: Adding Volume Calculation

Next, let's add volume calculation based on the length, width, and height values.

1. Update the code in `SliderComponent.tsx`:

```tsx
const calculateVolume = (length: number, width: number, height: number): number => {
  return length * width * height;
};

const SliderComponent: React.FC = () => {
  const [length, setLength] = useState<number>(10);
  const [width, setWidth] = useState<number>(10);
  const [height, setHeight] = useState<number>(10);
  const [volume, setVolume] = useState<number>(calculateVolume(length, width, height));

  // Update volume when parameters change
  const updateVolume = () => {
    setVolume(calculateVolume(length, width, height));
  };

  return (
    <div>
      <div>
        <label>Length: {length}</label>
        <input
          type="range"
          min="1"
          max="100"
          value={length}
          onChange={(e) => {
            setLength(Number(e.target.value));
            updateVolume();
          }}
        />
      </div>
      <div>
        <label>Width: {width}</label>
        <input
          type="range"
          min="1"
          max="100"
          value={width}
          onChange={(e) => {
            setWidth(Number(e.target.value));
            updateVolume();
          }}
        />
      </div>
      <div>
        <label>Height: {height}</label>
        <input
          type="range"
          min="1"
          max="100"
          value={height}
          onChange={(e) => {
            setHeight(Number(e.target.value));
            updateVolume();
          }}
        />
      </div>
      <div>
        <label>Volume: {volume}</label>
      </div>
    </div>
  );
};
```

Now, the volume will be recalculated whenever any of the parameters (length, width, height) change.

### Step 4: Adding Toggle Switches to Fix Values

Next, let's add the ability to fix the values of length, width, height, and volume using toggle switches.

1. Add toggle switches to the sliders in `SliderComponent.tsx`:

```tsx
const SliderComponent: React.FC = () => {
  const [length, setLength] = useState<number>(10);
  const [width, setWidth] = useState<number>(10);
  const [height, setHeight] = useState<number>(10);
  const [volume, setVolume] = useState<number>(calculateVolume(length, width, height));

  const [isLengthFixed, setIsLengthFixed] = useState<boolean>(false);
  const [isWidthFixed, setIsWidthFixed] = useState<boolean>(false);
  const [isHeightFixed, setIsHeightFixed] = useState<boolean>(false);
  const [isVolumeFixed, setIsVolumeFixed] = useState<boolean>(false);

  const updateVolume = () => {
    if (!isVolumeFixed) {
      setVolume(calculateVolume(length, width, height));
    }
  };

  return (
    <div>
      <div>
        <label>Length: {length}</label>
        <input
          type="range"
          min="1"
          max="100"
          value={length}
          onChange={(e) => {
            if (!isLengthFixed) {
              setLength(Number(e.target.value));
              updateVolume();
            }
          }}
          disabled={isLengthFixed}
        />
        <label>
          <input
            type="checkbox"
            checked={isLengthFixed}
            onChange={() => setIsLengthFixed(!isLengthFixed)}
          /> Fix
        </label>
      </div>

      <div>
        <label>Width: {width}</label>
        <input
          type="range"
          min="1"
          max="100"
          value={width}
          onChange={(e) => {
            if (!isWidthFixed) {
              setWidth(Number(e.target.value));
              updateVolume();
            }
          }}
          disabled={isWidthFixed}
        />
        <label>
          <input
            type="checkbox"
            checked={isWidthFixed}
            onChange={() => setIsWidthFixed(!isWidthFixed)}
          /> Fix
        </label>
      </div>

      <div>
        <label>Height: {height}</label>
        <input
          type="range"
          min="1"
          max="100"
          value={height}
          onChange={(e) => {
            if (!isHeightFixed) {
              setHeight(Number(e.target.value));
              updateVolume();
            }
          }}
          disabled={isHeightFixed}
        />
        <label>
          <input
            type="checkbox"
            checked={isHeightFixed}
            onChange={() => setIsHeightFixed(!isHeightFixed)}
          /> Fix
        </label>
      </div>

      <div>
        <label>Volume: {volume}</label>
        <input
          type="range"
          min="1"
          max="100000"
          value={volume}
          onChange={(e) => {
            if (!isVolumeFixed) {
              setVolume(Number(e.target.value));
            }
          }}
          disabled={isVolumeFixed}
        />
        <label>
          <input
            type="checkbox"
            checked={isVolumeFixed}
            onChange={() => setIsVolumeFixed(!isVolumeFixed)}
          /> Fix
        </label>
      </div>
    </div>
  );
};
```

### Step 5: Implementing Dependency Between Values

Now, let's implement the logic where, when the fixed volume changes, the length, width, or height is recalculated.

1. Update `SliderComponent.tsx`, adding the dependency logic between the parameters:

```tsx
const handleVolumeChange = (event: React.ChangeEvent<HTMLInputElement>) => {
  const newVolume = Number(event.target.value);
  if (!isVolumeFixed) {
    setVolume(newVolume);

    if (isLengthFixed) {
      setHeight(newVolume / (length * width));
    } else if (isWidthFixed) {
      setHeight(newVolume / (length * width));
    } else if (isHeightFixed) {
      setWidth(newVolume / (length * height));
    } else {
      setHeight(newVolume / (length * width));
    }
  }
};
```

### Conclusion
![app](https://image.nostr.build/ebcf2e8afb35bb7dcbda242b88bc4f878ea137d000daa5209b1455afea2eaa36.jpg)

You've created a component with sliders and dependent values, where each value can be fixed. The component automatically recalculates parameters based on the fixed values and changes in volume. You can expand this component by adding styling, additional logic, or other features as needed.

[App](https://chuckis.github.io/my-slider-app/) 
 [repository](https://github.com/chuckis/my-slider-app)

nostr:nevent1qqs0y7lgdgtzyqq7l56v9p85lk0c2mwv2tpxa9tzp5vnh83mklyusuqzyzahx52vsznezm0agty6m24gjfuft6y5mnmnf0qgdn9r869xaq4xqqcyqqq823cfhuq5w 
 #til #ui #ux 44px 
 Today simple python scripts, tomorrow the world. 
 The "Hello world" :) 
 GM
nostr:nevent1qqszvsyky9lhaa2khpa70slvv3nlfnt6c08gtzq92n894jfyzzvaxegpzemhxue69uhhyetvv9ujuurjd9kkzmpwdejhgq3qhde4znyq57gkml2zexk642yj0z2739xu7u6tczrvege73fhg9fsqxpqqqqqqzhdnwaa 
 #devdiary omg typescript, especially after python. btw, block send from #logseqplugin 
 #til
ctrl+shift+p restart ts server  
 All of the “city crazy people” suddenly disappeared somewhere. The hysteria around Covid ended, then the war began, and they disappeared. I've seen 4 of them before, all the time. And now, they are gone... 
 Testing chuckis.npub.pro  
 testing comments 
 another comment 
 what about plugins, examples? 
  у оружейных баронов тоже есть свои планы 
 Blur, song2;
Tory Amos, Crucify;
 
 + Нау, Цой and a special Shout out for ALLIANCE "NA ZARE"
https://youtu.be/rkbHnALPiec?si=Gp74VM8-CcSrhcG8

nostr:nevent1qqsd53dqczg5chrndx3lmte2jnufjy9fqzx9l0tlsq49802zp9sv2xqppamhxue69uhhxmmvda3k7tnwdspzpwmn29xgpfu3dh759jdd425fy7y4az2deae5hsyxej3naznws2nqqvzqqqqqqyx3nd4t 
 начали отключать электричество по 10+ часов. 
#darkdiary 
 you can make mistakes, but you can’t lie 
 Sometimes social entrepreneurship looks like a scam.  Often like this 
 C - vertex, CD - altitude 
 oops may be I wrong, and that vertex is D.  
It's better to read about such in native language :D. Sorry.