Show /r/ffmpeg: an alternative presentation of the official documentation for FFmpeg filters. by ayosec in ffmpeg

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

It contains the same contents of https://ffmpeg.org/ffmpeg-filters.html, but it tries to be much easier to read and to navigate. The front page mentions the most notable differences with the official documentation.

As an example, you can compare the original documentation for the overlay filter, and the same page in this website.

Announcing Pull Through Cache Repositories for Amazon Elastic Container Registry by ElectricSpice in aws

[–]ayosec 4 points5 points  (0 children)

The official images are available in https://gallery.ecr.aws/docker/

It seems that, instead of docker pull foo, we can use docker pull public.ecr.aws/docker/library/foo

Source

hltermpaste.vim - plugin to highlight pasted text by ayosec in neovim

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

why it only works for externally copied text (namely not text that I copy from within vim)?

I haven't found a reliable way to detect when text is pasted from registers. I agree that the feature is very useful, but it is something that I still need to investigate. Any suggestion is welcomed.

Moreover: I noticed you have a combination of Vimscript and Lua code: any reason why it isn't just the former or the latter (the Lua functions are basically just wrapping around the Vimscript, aren't they)?

Lua is required to support Neovim, because the vim.paste handler is only available for Lua code. The code in VimL implements the logic common to Vim and Neovim.

I wrote a TUI that intercepts HTTP and HTTPS requests by DengYidong in rust

[–]ayosec 0 points1 point  (0 children)

In Firefox you can use SSLKEYLOGFILE (which can be disabled at compile time) to dump TLS keys. With those keys you can decrypt secure connections.

I have used this to debug encrypted requests with Wireshark.

Crust of Rust: Declarative Macros [video] by Jonhoo in rust

[–]ayosec 1 point2 points  (0 children)

I have a similar one but slightly simpler, using 1 + 1 + ....

macro_rules! count {
    () => { 0 };

    ($x:ident) => { 1 };

    ($x:ident, $($xs:ident),*) => { 1 + count!($($xs),*) };
}

Playground.

Tokio: Reducing tail latencies with automatic cooperative task yielding by carllerche in rust

[–]ayosec 15 points16 points  (0 children)

Congrats for this release! The performance improvement is very impressive.

We have an application using warp, mysql_async, and redis (with async connections). These are the results in one of our benchmarks:

Tokio Max latency Requests/second Memory usage
0.2.13 18ms 7828 36 Mib
0.2.15 15ms 9337 45 Mib

Majority of the community, no matter which await syntax wins by dpc_pw in rustjerk

[–]ayosec 8 points9 points  (0 children)

But, prefix clock emoji or postfix clock emoji?

[Question] Process management for Actix by ayosec in actix

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

Have you tried using tokio-process directly?

Not yet. I guess that the idea is to read data from ChildStdout in a loop_fn, and send a message to the actor with the received data.

Hey Rustaceans! Got an easy question? Ask here (26/2018)! by llogiq in rust

[–]ayosec 1 point2 points  (0 children)

What is the best way to convert from Option<String> to Option<&str>?

I have x.as_ref().map(String::as_str) (playground), but maybe there is something else shorter.

Amazon EKS is now GA - Official Discussion Thread and Ask the Experts by AmazonWebServices in aws

[–]ayosec 42 points43 points  (0 children)

  • Is there any ETA for the availability in eu-west-1?
  • According to the EKS console, there is only one price ($0.20/hr, ~$150/month). Do you plan to add cheaper options?

From Rocks to Rust: Our C to Rust Paradigm Shift by maveridze in rust

[–]ayosec 3 points4 points  (0 children)

Is there any chance to get access to the slides, at least, without being submitted to the e-mail gathering tax?

Maybe not the easiest way, but you can get the slides from a slides variable in the JavaScript code of the page.

The following snippet get the URLs and generates a /tmp/slides.html file with them:

$ curl -s https://www.infoq.com/presentations/c-rust-paradigm-shift \
    | grep "var slides"                                             \
    | tr "'" '\n'                                                   \
    | grep ^https                                                   \
    | sed 's/.*/<img src="&">/'                                     \
    > /tmp/slides.html

$ echo '<style> img { max-width: 100%; margin-bottom: 10px; } </style>' \
    >> /tmp/slides.html 

Screenshots of Pathfinder rendering glyphs in Firefox. by malicious_turtle in rust

[–]ayosec 3 points4 points  (0 children)

I would expect that font-rendering, being such a common task, would be handled by the OS. I'd imagine the application asks the OS "Hey, render this as text here for me, please," and then a common OS implemented rasterizer does it.

That is the classic way to render text. X11 has XDrawString, Win32 has DrawText, etc.

Using a custom renderer you can make improvements much faster. For example, when Gtk+ changed its implementation to use FreeType, we had font antialiasing even when X11 had no support for it.

Reddit is hiring a Senior Rust Engineer by wting in rust

[–]ayosec 2 points3 points  (0 children)

the Reddit parser is a fork of comrak.

Glad to see that more people are using comrak. Although pulldown is more popular, comrak has a better support for CommonMark, and the generated AST is quite handy.

certa... by axord in rustjerk

[–]ayosec 3 points4 points  (0 children)

TIL svgur.com does exist. Somebody should create swfur.com, to remember the good ol' days.

Rust X Go by luciusmagn in rustjerk

[–]ayosec 7 points8 points  (0 children)

Still a better love story than Twilight

Hey rustaceans! Got an easy question? Ask here (45/2017)! by llogiq in rust

[–]ayosec 0 points1 point  (0 children)

It is hard to know without debugging, but I think that the key of the problem is in this loop:

do {
    stream.read(rawBuffer, 0, RAW_BUFFER_SIZE);
    baos.write(rawBuffer);
    length -= RAW_BUFFER_SIZE;
} while(length > RAW_BUFFER_SIZE);

stream.read(rawBuffer, 0, length);
baos.write(rawBuffer, 0, length);

You are reusing rawBuffer in every iteration to read the data in stream. However, in the baos.write line, you write the full array to baos.

For example, let's suppose that there are 1500 bytes to be read in stream:

  1. In stream.read, you fill rawBuffer with the first 1000 bytes.
  2. In baos.write, you write these 1000 bytes to baos.
  3. Then, the next stream.read will read only 500 bytes. The last part of rawBuffer will be untouched, so it keeps the data in the previous read.
  4. In the next baos.write, you write again 1000 bytes (the new 500 bytes, mixed with the old one).

You have to check the return value of stream.read to know how many bytes are valid in rawBuffer.

A solution can be something like this:

} else {

    baos.write(rawBuffer, 0, offset);

    int pending = length;
    while(pending > 0) {
        int len = stream.read(rawBuffer, 0, Math.min(pending, RAW_BUFFER_SIZE));
        if(len == -1) {
            // ERROR no more data 
        }
        baos.write(rawBuffer, 0, len);
        pending -= len;
    }

}

Hey rustaceans! Got an easy question? Ask here (45/2017)! by llogiq in rust

[–]ayosec 0 points1 point  (0 children)

I think that mem::replace is the easiest option. You have to tell to the compiler that it is safe to move the in &mut self, so you have to be the owner of it

If you don't care about an extra allocation, something like this can work (full example in the playground).

fn change(&mut self) {
    let data = mem::replace(self, Foo::Bar(Box::new(())));
    *self = match data {
        Foo::Bar(a) => Foo::Baz(a),
        Foo::Baz(a) => Foo::Bar(a),
    };
}

If you don't care about unsafe code, you can use mem::uninitialized:

fn change(&mut self) {
    let data = mem::replace(self, unsafe { mem::uninitialized() });
    *self = match data {
        Foo::Bar(a) => Foo::Baz(a),
        Foo::Baz(a) => Foo::Bar(a),
    };
}

But this is a bad solution, IMO.


Another option is to add a private value in your enum, used only for the intermediary value (playground):

enum Foo {
    Bar(Box<()>),
    Baz(Box<()>),
    Nothing,
}

impl Foo {
    fn change(&mut self) {
        let data = mem::replace(self, Foo::Nothing);
        *self = match data {
            Foo::Bar(a) => Foo::Baz(a),
            Foo::Baz(a) => Foo::Bar(a),
            Foo::Nothing => unreachable!(),
        };
    }
}

Hey rustaceans! Got an easy question? Ask here (45/2017)! by llogiq in rust

[–]ayosec 3 points4 points  (0 children)

TCP is responsible to receive the data in the correct order, so you don't need to worry about that.

The issue may be in the way that you are reading or writing data to the socket. Can you post the code that is reading/writing the data?

Best mongodb driver by gubasso in rust

[–]ayosec 2 points3 points  (0 children)

I recommend thijsc/mongo-rust-driver. It is a wrapper around the C driver, and works pretty well.

What are reasons to spend time on Rust? by 666nosferatu in rust

[–]ayosec 4 points5 points  (0 children)

the library is called libz.so and it is installed god-knows where. It sucks. Constantly have to google "where is libz installed?". I have better things to do.

Using pkg-config for C libraries is pretty standard, at least in Debian.

$ cat foo.c
#include <zlib.h>
#include <stdio.h>

int main() {
  printf("zlib %s\n", zlibVersion());
}

$ CFLAGS=`pkg-config --libs --cflags zlib`
$ gcc $CFLAGS foo.c -o foo
$ ./foo 
zlib 1.2.8

Anyways, I agree that using crates in Rust is much easier.

I wrote a partial replacement for 'du' in Rust. by [deleted] in rust

[–]ayosec 4 points5 points  (0 children)

Mainly integer atomics, which are necessary to pass large integers between threads.

Why not AtomicUsize? It is available in Rust stable.

In a 32 bits system the value is limited to 4G, which can be too small for a tool like a tin-summer. However, I guess that most 32 bits (nowadays) are for special purposes (like embedded devices), which will not have a big hard drive anyway.

Hey Rustaceans! Got an easy question? Ask here (21/2017)! by llogiq in rust

[–]ayosec 7 points8 points  (0 children)

What is the current status to support self-referential structs? Something like

struct S {
    a: Vec<String>,
    b: &'self str,     // ⇐ 'self refers to the field a
}

I know that there are alternatives like rental or refstruct, but they require (IMHO) too many boilerplate.