ur0 / lolcat Goto Github PK
View Code? Open in Web Editor NEWlolcat, now with fearless concurrency.
License: MIT License
lolcat, now with fearless concurrency.
License: MIT License
From clolcat
:
// if a single line is too fat it might break down to multiple visual lines,
// but the color will be as if it was a single visual line. So we get the
// width of the terminal and every time it is reached we act as if a \n
// appeared
Seems like a good feature. I will try to implement after exams.
{ sleep 1 ; echo starwars ; sleep 99999 ;} | nc -c telehack.com 23 | RUST_BACKTRACE=full lolcat
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Kind(InvalidData)', /Users/michael1/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lolcat-1.5.0/src/main.rs:24:60
stack backtrace:
0: 0x109decd73 - std::backtrace_rs::backtrace::libunwind::trace::h211824fb0870b7d7
at /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
1: 0x109decd73 - std::backtrace_rs::backtrace::trace_unsynchronized::h0e69993850353c73
at /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x109decd73 - std::sys_common::backtrace::_print_fmt::hee91bd3b61c5fec7
at /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/library/std/src/sys_common/backtrace.rs:65:5
3: 0x109decd73 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h9b8c7d4986eea143
at /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/library/std/src/sys_common/backtrace.rs:44:22
4: 0x109e06c3b - core::fmt::rt::Argument::fmt::hea92c31b43c9e564
at /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/library/core/src/fmt/rt.rs:138:9
5: 0x109e06c3b - core::fmt::write::h745c6d87d2702197
at /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/library/core/src/fmt/mod.rs:1094:21
6: 0x109dea28e - std::io::Write::write_fmt::h9bc75e1a1578f329
at /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/library/std/src/io/mod.rs:1714:15
7: 0x109decb6a - std::sys_common::backtrace::_print::h98bb00e155d79a89
at /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/library/std/src/sys_common/backtrace.rs:47:5
8: 0x109decb6a - std::sys_common::backtrace::print::hb5816525719dec2d
at /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/library/std/src/sys_common/backtrace.rs:34:9
9: 0x109dedf35 - std::panicking::default_hook::{{closure}}::hfc88b82ae9ab0222
at /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/library/std/src/panicking.rs:269:22
10: 0x109dedcdf - std::panicking::default_hook::h2cb72824a505d11d
at /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/library/std/src/panicking.rs:288:9
11: 0x109dee490 - std::panicking::rust_panic_with_hook::hc7199b95a24a631d
at /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/library/std/src/panicking.rs:705:13
12: 0x109dee3b3 - std::panicking::begin_panic_handler::{{closure}}::h29c0dd87214757f4
at /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/library/std/src/panicking.rs:597:13
13: 0x109ded179 - std::sys_common::backtrace::__rust_end_short_backtrace::hd299ff4177db45a7
at /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/library/std/src/sys_common/backtrace.rs:151:18
14: 0x109dee0ed - rust_begin_unwind
at /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/library/std/src/panicking.rs:593:5
15: 0x109e10433 - core::panicking::panic_fmt::h8b25e6b7bc9d8aa4
at /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/library/core/src/panicking.rs:67:14
16: 0x109e107e5 - core::result::unwrap_failed::h3575be054108b8be
at /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/library/core/src/result.rs:1651:5
17: 0x109d75082 - lolcat::cat::print_chars_lol::h020bb8e4a14de7a5
18: 0x109d776be - lolcat::main::hb84b2e210e3827df
19: 0x109d7b7c6 - std::sys_common::backtrace::__rust_begin_short_backtrace::h89b72f6f6c527f26
20: 0x109d7b7dc - std::rt::lang_start::{{closure}}::h44df6f286e049f18
21: 0x109de677a - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h136184a71f015bca
at /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/library/core/src/ops/function.rs:284:13
22: 0x109de677a - std::panicking::try::do_call::h2e2637ab353d5609
at /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/library/std/src/panicking.rs:500:40
23: 0x109de677a - std::panicking::try::hab157366490bbca8
at /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/library/std/src/panicking.rs:464:19
24: 0x109de677a - std::panic::catch_unwind::h65a1f3af6151de00
at /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/library/std/src/panic.rs:142:14
25: 0x109de677a - std::rt::lang_start_internal::{{closure}}::h34628e201aebaa71
at /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/library/std/src/rt.rs:148:48
26: 0x109de677a - std::panicking::try::do_call::hb94abc6ad51b64cb
at /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/library/std/src/panicking.rs:500:40
27: 0x109de677a - std::panicking::try::h8e012c727c1c58c7
at /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/library/std/src/panicking.rs:464:19
28: 0x109de677a - std::panic::catch_unwind::h4d612bb9078ec854
at /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/library/std/src/panic.rs:142:14
29: 0x109de677a - std::rt::lang_start_internal::h4f6dde0e5153fc54
at /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/library/std/src/rt.rs:148:20
30: 0x109d787dc - _main
31: 0x7ff803800310 - <unknown>
From clolcat
:
// if a single line is too fat it might break down to multiple visual lines,
// but the color will be as if it was a single visual line. So we get the
// width of the terminal and every time it is reached we act as if a \n
// appeared
Seems like a good feature. I will try to implement after exams.
I use lolcat
almost every day. Until I found this repository, I used the Ruby version by installing it through gem install lolcat
. This has always been a hassle because of local Ruby versions.
I'm glad I found the Rust equivalent of lolcat
. I'm curious if this could get published on Homebrew so I can install brew install rust-lolcat
or something similar? I don't mind updating this repository with docs and managing the formula updates. But I didn't want to do anything without checking in first. Thanks!
How do we do that? @ur0
Currently, it installs a previous version if I run cargo install lolcat
. I assumed it tracked this repository directly, but I guess not.
Not sure how much complexity this adds...
I wrote an article about lolcats and how to create snap packages for them,
https://blog.simos.info/how-to-make-a-snap-package-for-lolcat-with-snapcraft-on-ubuntu/
I included this version of lolcat as well!
:D
Confirmed it works on ubuntu 20.x but the colors don't work properly for any lolcat distribution on 21.x. Have tried with many different lolcat versions. Text is gray and occasionally displays a character with a colored background or blinking
So I was quite pleased with myself that this implementation is much faster than other rust lolcat
s. But
hyperfine 'lolcat words' '/tmp/lolcrab/target/release/lolcrab words' /tmp/clolcat/clolcat\ words
Benchmark 1: lolcat words
Time (mean ± σ): 110.0 ms ± 14.8 ms [User: 89.9 ms, System: 18.7 ms]
Range (min … max): 87.6 ms … 135.3 ms 23 runs
Benchmark 2: /tmp/lolcrab/target/release/lolcrab words
Time (mean ± σ): 294.6 ms ± 12.0 ms [User: 258.1 ms, System: 35.5 ms]
Range (min … max): 280.0 ms … 310.7 ms 10 runs
Benchmark 3: /tmp/clolcat/clolcat words
Time (mean ± σ): 1.1 ms ± 0.4 ms [User: 0.4 ms, System: 0.9 ms]
Range (min … max): 0.0 ms … 3.1 ms 1748 runs
Summary
'/tmp/clolcat/clolcat words' ran
103.45 ± 43.90 times faster than 'lolcat words'
277.00 ± 112.04 times faster than '/tmp/lolcrab/target/release/lolcrab words'
That's not good. We can probably do a lot better. clolcat
does not handle any escape sequences and so there are reasons to prefer going slower. But they're probably doing something quite clever which, especially when printing files and not stdin, I want to look into.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.