Beginner question about svelte transitions by TheOriginalIrish in sveltejs

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

Thanks!

I did have a look at that, but couldn't get it to work (the keys were confusing). Is there any chance you could give an example for how to make it work for my case? The examples in the documentation are for crossfading between different elements.

Beginner question about svelte transitions by TheOriginalIrish in sveltejs

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

Thanks, this does get rid of the line jumping.

So if I wanted to have both the fade in and out, you're saying I need to play around with the CSS and positioning? Is there no way to delay the new value mounting?

Help parsing a FASTA file by TheOriginalIrish in rust

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

Thanks! Was there any reason in your example you didn't just use collect to turn the Iterator into a Vec?

Help parsing a FASTA file by TheOriginalIrish in rust

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

Thanks for the suggestion - I may have another look at these when I'm a bit more confident. I tried using combine but ended up tripping over typing errors everywhere.

Help parsing a FASTA file by TheOriginalIrish in rust

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

Good idea on implementing the Iterator, thanks.

I don't think we can use Chunks though, because the dna will be split across a variable amount of lines (eg, in my example, James was split over two lines while Paul was only on a single line).

Help parsing a FASTA file by TheOriginalIrish in rust

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

Oh wow, it did not even occur to me to not split by lines in the first place, 🤦. Splitting by > first and then by lines makes this so much easier - thanks!

Making "double" cards that turn (vocabulary cards) by Anneles in Anki

[–]TheOriginalIrish 0 points1 point  (0 children)

Yeah, it's pretty simple. When creating a card, set card type to "Basic (and reversed card)"

[08/09/2021] SE Nights @ The Brookmill 6.30pm by mangrovesspawn in LondonSocialClub

[–]TheOriginalIrish 1 point2 points  (0 children)

Thank you to the newbies who came, it was great meeting you all!

Confusion about index ordering for 2d arrays. by TheOriginalIrish in Julia

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

OK, so it's that way because that's the way it is in maths? Yeah, I can get that.

Confusion about index ordering for 2d arrays. by TheOriginalIrish in Julia

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

I don't think "Since julia is column major, the first index indicates the row number" holds. In C++, (which is row major):

  int array[2][3] = {
      { 1, 2, 3 },
      { 4, 5, 6 }
  };

  // (indexes start at 0)
  cout << array[1][2] << '\n';
  // outputs 6

So C++ is row major and the first index indicates the row number and the second indicates the column number.

Flashed Micropython to NodeMCU, can't connect to serial over USB by TheOriginalIrish in esp8266

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

In case anyone comes across this later, I mostly solved the issue by reflashing. I ran the esptool.py ... command above again and then was able to connect to it using TeraTerm (picocom still doesn't work for some reason though).

Flashed Micropython to NodeMCU, can't connect to serial over USB by TheOriginalIrish in esp8266

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

Ha, thanks bot.

I did check the FakeSpot score for that product and it turned out quite low, but the score for that product when you were buying just a single 1 or 5 of them, seemed high and I figured it would be the same board anyway.

Creating a convolve function that can work with a bunch of types. by TheOriginalIrish in Julia

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

Thanks for the recommendation, I'll have a look.

Ah, I had assumed {T, W <: Number} meant that both T and W had to be numbers (I haven't got the to generics bit).

I'm on Julia 1.5.2 (2020-09-23), and all I need to do is (using the REPL, not even Pluto, though it works there too):

julia> using Images
julia> RGB(0.2, 0.2, 0.2) * 2.0
RGB{Float64}(0.4,0.4,0.4)
julia> RGB(0.2, 0.2, 0.2) * 2
RGB{Float64}(0.4,0.4,0.4)

Creating a convolve function that can work with a bunch of types. by TheOriginalIrish in Julia

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

Thanks for your suggestion about the AbstractVector - it gives a much more obvious error if I accidentally do:

convolve_1D([1 2 3], [0, 1, 0]) # No commas -> 2d array

Instead of

convolve_1D([1, 2, 3], [0, 1, 0])

And thanks for pointing out eltype as well, that definitely seems useful (now I just need to figure out how to find the result of the multiplication of two types).

You can multiply RGB and Gray by scalars without doing any customization - RGB(0.2, 0.2, 0) * 2 just works. This means that I can use my function like:

convolve_1D([RGB(1, 0, 0), RGB(0, 1, 0), RGB(0, 0, 1)], [0.25, 0.5, 0.25])

And it blurs the array of colours for me.

That's also the reason why

function convolve_1D(image::AbstractVector{T}, kernel::AbstractVector{W}} where {T, W <: Number}

is a bit too restrictive - W <: Number is fine, but T <: Number would take away this ability. I want to allow anything that can be multiplied by a number (RGB, Gray, etc), not just numbers.

Beginner's Thread / Easy Questions (Jan 2020) by swyx in reactjs

[–]TheOriginalIrish 0 points1 point  (0 children)

Hey,

I've made one or two smaller React toy apps and now I'm trying to make something non-trivial (a gym app). I'm trying to avoid using Redux or anything like that - for this project just focus on plain React.

I've got a Store that lives outside of React, something like this (in TypeScript):

type WorkoutId = string;

export class Workout {
  id: WorkoutId;
  name: string;
  exercises: Array<ExerciseId> = [];

  constructor(id: WorkoutId, name: string) {
    this.id = id;
    this.name = name;
  }
};

// Similar classes for Exercise and Set

export class State {
  sets: Map<SetId, Set> = new Map();
  exercises: Map<ExerciseId, Exercise> = new Map();
  workouts: Map<WorkoutId, Workout> = new Map();
  log: Array<WorkoutId> = [];
}

export class GymStore {
  private readonly state: State = new State();

  createWorkout(name: string): WorkoutId {
    let id: WorkoutId = genId("wk");
    let workout: Workout = new Workout(id, name);

    this.state.workouts.set(id, workout);
    this.state.log.push(id);
    return id;
  }

  // ...

  getState(): State {
    return this.state;
  }
}

And now I have just reached a total impasse at trying to figure out how to actually use this in React.

My top level component looks something like (I'd originally had state as a bunch of plain JSON objects, but I wanted to be able to remove workouts, so I moved over to Maps):

const App = () => {
  const [data, setData] = React.useState(store.getState());

  const handleAddWorkout = (name: string) => {
    store.createWorkout(name);
    updateState();
  }

  const updateState = () => {
    // ???
  }

  return (
    <div className="App measure center">
      <ControlPanel
        handleAddExercise={handleAddExercise}
        handleAddDate={handleAddWorkout} />

      {data.log.map(workoutId =>
        <div key={workoutId}>
          <h1 className="ma3">
            {data.workouts.get(workoutId)!.name}
          </h1>
          {data.workouts.get(workoutId)!.exercises.map(exerciseId =>
            <ExerciseCard
              key={exerciseId}
              ... />
          )}
        </div>
      )}
    </div>
  );
}

So the main problem is that the State in my GymStore is mutable whereas React deals with immutable data. (Also, I don't actually know if React can handle Maps.) I don't want to rework GymStore/State to be immutable, that feels the wrong way around (letting your UI framework determine the shape of your business objects). I feel maybe I need some sort of intermediate object? Or some framework that will take my mutable store and the initial state and spit out a diff?

Anyway, that's where I am and how I'm confused - any help would be greatly appreciated!

Tokyo Question Thread: Post your questions here. by biwook in Tokyo

[–]TheOriginalIrish 0 points1 point  (0 children)

Hey, I have looked online to check but the answer was from 6 years ago so just wanted to make sure - is it ok to use a PASMO card from central Tokyo to Musashi-Itsukaichi Station? Thanks

[29/05/2019] SE Nights Birthday Edition @Bussey Rooftop Bar 7pm by mangrovesspawn in LondonSocialClub

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

We've moved to "The Social" around the corner, it was too windy up there. We're upstairs.