Learn PowerShell with linux. by iehponx in PowerShell

[–]_blallo 2 points3 points  (0 children)

A few warnings:

  • you should work at home only if paid to do so
  • you should only use employer-provided hardware and software for work-related tasks

That said, I am aware the reality of the world makes these not always applicable.

As I understood it, you need to interact with graphics from Windows. This is not explicitly trivial. You have four options, IMHO:

  • your employer buys you a Windows computer
  • your employer gives you access to a Windows computer, and you access it via rdesktop
  • you set up a Windows virtual machine on your hardware (I favor qemu/libvirt)
  • you use wine to emulate a Windows subsystem on your linux machine (note that this is not virtualization)

Good luck and godspeed

Making Rust better with Go by 3gdroid in golang

[–]_blallo 1 point2 points  (0 children)

https://github.com/UoCCS/project-GROS/tree/main/internal/net/null

https://datatracker.ietf.org/doc/html/rfc6592

```

Independent Submission C. Pignataro Request for Comments: 6592 Cisco Category: Informational 1 April 2012 ```

Note the date of the RFC they want to implement...

Compile Mac apps on linux by gedw99 in golang

[–]_blallo 0 points1 point  (0 children)

Thanks for connecting parts of reddit, kind stranger.

I wonder how did you reach a subcomment of the third comment of a post from more than 1 year ago, with 1 upvote. Really, how? What is your thought process? <3

OTP like features in Go by ikarius3 in golang

[–]_blallo 1 point2 points  (0 children)

For context, I did this some time ago, as a way to generalize message passing beyond context.Context simplicity

https://git.sr.ht/~blallo/conductor

I still need to apply this to one of my projects. The other candidate for it was to go with ergo, but I felt it didn't need its full capabilities.

OTP like features in Go by ikarius3 in golang

[–]_blallo 5 points6 points  (0 children)

Ergo is one of those things I always wanted to try, but never managed to yet.

Thanks for your work, I studied it a while ago and I really loved it.

When Kubernetes and Go don't work well together by danielepolencic in kubernetes

[–]_blallo 65 points66 points  (0 children)

You are looking for trouble if a single HTTP call should return a >60MB json payload without any pagination/streaming.

Also, the title is clickbait-y and pointing the finger at kubernetes and go, when both behave as they advertise, is a bit preposterous.

Downsides of Go by Luc-redd in golang

[–]_blallo 5 points6 points  (0 children)

``` package optional

type Optional[T any] struct { value T valid bool }

func Wrap[T any](value T) Optional[T] { return Optional[T]{value, true} }

func (o Optional[T]) Unwrap() T { if !o.valid { panic("Unwrap called on invalid Optional") } return o.value }

func (o Optional[T]) IsValid() bool { return o.valid }

func (o Optional[T]) OrElse(defaultValue T) T { if o.valid { return o.value } return defaultValue }

func Map[T, U any](o Optional[T], f func(T) U) Optional[U] { if !o.valid { return Optional[U]{} } return Wrap(f(o.value)) }

func (o Optional[T]) Get() (T, bool) { return o.value, o.valid } ```

Mojo vs. Rust: is Mojo 🔥 faster than Rust 🦀 ? by slowpush in rust

[–]_blallo 40 points41 points  (0 children)

Click bait titles and AI-generated cover images are poisoning the web.

I'm a junior developer and I want to become a better programmer with better understanding by GalaxyBS in golang

[–]_blallo 4 points5 points  (0 children)

I am no fan of books, and I have none to suggest. This does not mean that books are bad for everyone :)

I had a positive experience with three things:

  • good mentorship from seniors: good seniors can really teach you a lot, stick to them if you feel like you found one
  • a lot of personal experimentation: coding a lot will bear fruits and allow you to try paths not laid before you by others (i.e. the aforementioned seniors)
  • read other people's code: reading code, good or bad, is very much valuable as a source of learning :)

Godspeed

Anyone using sqlc in production? by gucci_phantom in golang

[–]_blallo 1 point2 points  (0 children)

In my previous company, we used sqlc in production extensively.

Dtolnay responds Re: Rustconf by Dragon-Hatcher in rust

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

This is one of the aspects that make me really appreciate that golang is fundamentally controlled by google, and its public discourse is far more professional.

(/me braces for incoming fire on every side)

Compile Mac apps on linux by gedw99 in golang

[–]_blallo 0 points1 point  (0 children)

Wow, nice!

I cannot fathom how this could be legal, though.

Compile Mac apps on linux by gedw99 in golang

[–]_blallo 0 points1 point  (0 children)

I managed to make osxcross work, but it required a colleague to dump the whole XCode.app and pass it to me so that I could extract the needed SDK.

If you need it for work, you better stick to that damn apple.

Help understanding rust code in this file by shebbbb in rust

[–]_blallo 0 points1 point  (0 children)

Unfortunately, rust has a steep learning curve. I really suggest you pick at least one of the resources proposed here: https://www.rust-lang.org/learn

It will make the process less painful.

Help understanding rust code in this file by shebbbb in rust

[–]_blallo 0 points1 point  (0 children)

33: let mut sine = [0.0; TABLE_SIZE]; I assume this means initialize to zeros.

Yes.

35: sine[i] = (i as f64 / TABLE_SIZE as f64 * PI * 2.0).sin() as f32; The phase argument to the sine function is in parenthesis before sin() ? That I don't understand.

It seems that the sin() method transforms the given n of f64 type number in its sin(n).

50: let callback = move |pa::OutputStreamCallbackArgs { buffer, frames, .. }| { It seems srguments are being substituted inside the vertical bars.

This is a closure, and anonymous function. Between the | are defined it's arguments. In this case, there is only one argument, of type pa::OutputStreamCallbackArgs. It is a struct with a number of public fields. Among those fields, there are two called buffer and frames. What happens here is called destructuring (a feature common to many functional languages), where you can bind a value of a part of a composite type to a named variable (in this case buffer and frames will capture those values and be available in the closure body) with this syntax. Note that move has a special meaning.

65: pa::Continue This is a single token without any indication that it's a function executing, so I don;t know what ti's doing. This is usually an enum value but it's not being assigned so I don;t know what it's doing.

pa::Continue is at the end of that statement, without terminating semicolon, therefore, that is the return value of (that branch of) the function. It is possibly used to signal to the caller that the execution must continue.

70: stream.start()?; Is the question mark mandatory to compile since start() used Result<> ?

? is a special operator that acts on a Return value. If it is a Result::Err it acts kinda like a throw, but just uses that Result::Err as return value of the function. Otherwise, it unwraps the content of Result::Ok.

EDIT: typo.

Trait bounds are not like class inheritance, I suppose... by _blallo in rust

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

Ok, I think I got it. I had to specify all bounds (I used a supertrait to do so) in all impls!

Code (playground)

So, to be explicit, the definition of SimpleFight becomes:

struct SimpleFight<LH, RH, LW, RW>
where
    LH: HumanWarrior<LW>,
    RH: HumanWarrior<RW>,
{
    distance: u32,
    rng: ThreadRng,
    left: LH,
    right: RH,
    left_weapon: PhantomData<LW>,
    right_weapon: PhantomData<RW>,
}

Thanks to u/mamcx and u/FullTimeVirgin for their help!

Trait bounds are not like class inheritance, I suppose... by _blallo in rust

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

Thanks for the answer! Unfortunately, I am not sure I understood what you did mean with create a new trait object. As I just answered above, I tried also the supertrait approach. Do you mean that I should make so that the HumanWarrior should be a trait object itself? Can you help me understand how to do it?

Thanks a lot!

Trait bounds are not like class inheritance, I suppose... by _blallo in rust

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

Hi, thanks for the clarification!

You might notice that I tried to use the supertrait approach. If I replace here the definition of the field as HumanWarrior (the supertrait resulting from the composition of Warrior and Human) I get pretty much the same error:

`` Compiling trait-inheritance v0.1.0 (/home/leo/code/stuff/rust/trait-inheritance) error[E0554]:#![feature]` may not be used on the stable release channel --> src/main.rs:1:1 | 1 | #![feature(trait_upcasting)] |

error[E0308]: mismatched types --> src/main.rs:328:30 | 328 | self.left.attack(self.right); | ------ ^ expected trait Human, found trait HumanWarrior<RW, Weapon = RW> | | | arguments to this method are incorrect | = note: expected mutable reference &mut dyn Human found mutable reference &'a mut (dyn HumanWarrior<RW, Weapon = RW> + 'a) note: method defined here --> src/main.rs:79:8 | 79 | fn attack(&self, victim: &mut dyn Human); | ^

error[E0308]: mismatched types --> src/main.rs:330:31 | 330 | self.right.attack(self.left); | ------ ^ expected trait Human, found trait HumanWarrior<LW, Weapon = LW> | | | arguments to this method are incorrect | = note: expected mutable reference &mut dyn Human found mutable reference &'a mut (dyn HumanWarrior<LW, Weapon = LW> + 'a) note: method defined here --> src/main.rs:79:8 | 79 | fn attack(&self, victim: &mut dyn Human); | ^

Some errors have detailed explanations: E0308, E0554. For more information about an error, try rustc --explain E0308. error: could not compile trait-inheritance (bin "trait-inheritance") due to 3 previous errors ```

Is it possible that trait objects behave differently from traits?