# Post your handy utility scripts!

**URL:** <https://forum.endeavouros.com/t/post-your-handy-utility-scripts/7213>\
**Category:** Community contributions\
**Created:** [August 21, 2020, 12:38pm UTC](https://forum.endeavouros.com/t/post-your-handy-utility-scripts/7213 "2020-08-21T12:38:24Z")\
**Posts on this page:** 20\
**Page:** 7

<div class="post-metadata">

**Author:** ![vlkon](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/v/35a633/32.png) [@vlkon](https://forum.endeavouros.com/u/vlkon)\
**Post date:** [June 10, 2021, 9:32pm UTC](https://forum.endeavouros.com/t/post-your-handy-utility-scripts/7213/122 "2021-06-10T21:32:07Z")

</div>

Hey, I paid for that CPU so I want to use every damn cpu core/thread it has. 😜

---

<div class="post-metadata">

**Author:** ![keybreak](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/keybreak/32/9257_2.png) [@keybreak](https://forum.endeavouros.com/u/keybreak)\
**Post date:** [June 10, 2021, 9:33pm UTC](https://forum.endeavouros.com/t/post-your-handy-utility-scripts/7213/123 "2021-06-10T21:33:05Z")

</div>

You were warned… 🙃

![image](https://forum.endeavouros.com/uploads/default/original/3X/8/0/80fd580227964192be661467b6baa2cb3903292e.jpeg)

---

<div class="post-metadata">

**Author:** ![Kresimir](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/kresimir/32/73739_2.png) [@Kresimir](https://forum.endeavouros.com/u/Kresimir)\
**Post date:** [June 10, 2021, 10:19pm UTC](https://forum.endeavouros.com/t/post-your-handy-utility-scripts/7213/124 "2021-06-10T22:19:46Z")

</div>

The best thing about arrays is that they occupy a contiguous part of memory, which makes makes it possible to access any element by its index. It takes the same amount of time to read item 0 and item 10000, you don’t have to iterate through all of the array to find the element at a given position. In CS jargon, this makes the array a “random access data structure”, and the time it takes to access any element is said to be O(1) (it does not depend on the position of the element nor the size of the array).

So in “my method”, getting a random element from the array does not depend on the size of that array (though the probability distribution is bugged with big arrays). You just get the random index, and then access the element at that position. A single array access operation.

On the other hand, shuffling the array (with the best possible algorithm and sufficient memory) requires O(_n_) time, where _n_ is the size of the array, meaning that 10 times bigger array takes 10 times longer to shuffle. Every element in the array has to be accessed at least once to shuffle it. Now, if you combine that with calling a (rather bloated) external program like `sed` on every element of the array… this is where you lose all that time.

---

<div class="post-metadata">

**Author:** ![Kresimir](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/kresimir/32/73739_2.png) [@Kresimir](https://forum.endeavouros.com/u/Kresimir)\
**Post date:** [June 11, 2021, 7:37pm UTC](https://forum.endeavouros.com/t/post-your-handy-utility-scripts/7213/125 "2021-06-11T19:37:17Z")

</div>

Here is the best alias ever:

```nohighlight
alias 🐱='cat'

```

It works flawlessly.

---

<div class="post-metadata">

**Author:** ![freebird54](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/freebird54/32/83106_2.png) [@freebird54](https://forum.endeavouros.com/u/freebird54)\
**Post date:** [June 11, 2021, 7:50pm UTC](https://forum.endeavouros.com/t/post-your-handy-utility-scripts/7213/126 "2021-06-11T19:50:58Z")

</div>

Isn’t that dangerous to a frog? I had to restrict my cat to the house when at the lake…

😺

---

<div class="post-metadata">

**Author:** ![jonathon](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/jonathon/32/18722_2.png) [@jonathon](https://forum.endeavouros.com/u/jonathon)\
**Post date:** [June 11, 2021, 11:35pm UTC](https://forum.endeavouros.com/t/post-your-handy-utility-scripts/7213/127 "2021-06-11T23:35:26Z")

</div>

> [@Kresimir](#):
>
> `alias 🐱='cat'`

An Arch TU told me about this: [https://wiki.archlinux.org/title/IBus#Emoji\_input](https://wiki.archlinux.org/title/IBus#Emoji_input)

It brought my system into the 21st century… 🤣

```auto
$ 🦄🌈
zsh: command not found: 🦄🌈

```

😭

---

<div class="post-metadata">

**Author:** ![vlkon](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/v/35a633/32.png) [@vlkon](https://forum.endeavouros.com/u/vlkon)\
**Post date:** [June 12, 2021, 8:39am UTC](https://forum.endeavouros.com/t/post-your-handy-utility-scripts/7213/128 "2021-06-12T08:39:35Z")

</div>

> [@jonathon](#):
>
> It brought my system into the 21st century… 🤣

Try 21st century B.C. 🤣

> **c++ source code**
>
> ```auto
> #include <iostream>
> 
> #define 𓂘 {
> #define 𓂓 }
> #define 𓂁 <<
> #define 𓂄 >>
> #define 𓇼 *
> #define 𓋠 +
> #define 𓈈 =
> 
> #define 𓁭𓃌𓁔 std::cout
> #define 𓁭𓃌𓁅 std::cin
> #define 𓀡𓀽𓃩 int
> #define 𓃽𓀌𓀓𓁰 char
> #define 𓁜𓂀𓁠 template
> #define 𓐭𓁉𓄙𓅊 class
> #define 𓅘𓁚𓆫 public
> #define 𓀠𓉠𓌲 const
> #define 𓍹𓎬𓍻 return
> #define 𓆌𓆚𓆣 auto
> #define 𓄃𓃠 '\n'
> #define 𓁩𓉢𓁪 main
> 
> 𓁜𓂀𓁠 <𓐭𓁉𓄙𓅊 𓆦>
> 𓆌𓆚𓆣 𓁂𓇽𓁡(𓆦 𓀠𓉠𓌲 𓅇, 𓆦 𓀠𓉠𓌲 𓅓) 𓂘 𓍹𓎬𓍻 𓅇 𓋠 𓅓; 𓂓
> 
> 𓁜𓂀𓁠 <𓐭𓁉𓄙𓅊 𓆦>
> 𓐭𓁉𓄙𓅊 𓇣𓈌𓂓
> 𓂘
> 𓅘𓁚𓆫:
> 𓁜𓂀𓁠 <𓐭𓁉𓄙𓅊 𓋍>
> 𓆌𓆚𓆣 𓃚𓌌𓋹𓅀(𓋍&& 𓋗, 𓆦 𓀠𓉠𓌲 𓅇, 𓆦 𓀠𓉠𓌲 𓅓)
> 𓂘
> 𓍹𓎬𓍻 𓋗(𓅇, 𓅓);
> 𓂓
> 𓂓;
> 
> 𓀡𓀽𓃩 𓁩𓉢𓁪()
> 𓂘
> 𓇣𓈌𓂓<𓀡𓀽𓃩> 𓅅𓀎𓃦;
> 𓀡𓀽𓃩 𓃕 𓈈 𓅅𓀎𓃦.𓃚𓌌𓋹𓅀(𓁂𓇽𓁡<𓀡𓀽𓃩>, 1, 2);
> 
> 𓁭𓃌𓁔 𓂁 𓃕 𓂁 𓄃𓃠;
> 𓂓
> 
> ```

[link to source](https://mariusbancila.ro/blog/2019/05/16/cpp-is-fun/)

---

<div class="post-metadata">

**Author:** ![Kresimir](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/kresimir/32/73739_2.png) [@Kresimir](https://forum.endeavouros.com/u/Kresimir)\
**Post date:** [June 16, 2021, 6:00pm UTC](https://forum.endeavouros.com/t/post-your-handy-utility-scripts/7213/129 "2021-06-16T18:00:20Z")

</div>

It would have been awesome if these were actual Middle Egyptian words, it’s just hieroglyphic gibberish. Still, very impressive!

---

<div class="post-metadata">

**Author:** ![vlkon](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/v/35a633/32.png) [@vlkon](https://forum.endeavouros.com/u/vlkon)\
**Post date:** [June 16, 2021, 6:21pm UTC](https://forum.endeavouros.com/t/post-your-handy-utility-scripts/7213/130 "2021-06-16T18:21:50Z")

</div>

I am no expert but I guess that the amount of people who are fluent both in c++ and Middle Egyptian could be counted on one hand even by a clumsy carpenter.  
But then again, I may be surprised.

---

<div class="post-metadata">

**Author:** ![Kresimir](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/kresimir/32/73739_2.png) [@Kresimir](https://forum.endeavouros.com/u/Kresimir)\
**Post date:** [June 16, 2021, 6:29pm UTC](https://forum.endeavouros.com/t/post-your-handy-utility-scripts/7213/131 "2021-06-16T18:29:19Z")

</div>

The user `nobody` is fluent in Middle Egyptian, the last native speaker of it died 3500 years ago. We can only guess how it sounded.

I’ve been learning it for 4-5 years now, and I know enough to be able to read hieroglyphic, but _very_ slowly and with a help of a dictionary. I’ll never be fluent in it, unfortunately. But I find it really fun. So this combination of C++ and hieroglyphs is right up my alley 😂

---

<div class="post-metadata">

**Author:** ![freebird54](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/freebird54/32/83106_2.png) [@freebird54](https://forum.endeavouros.com/u/freebird54)\
**Post date:** [June 16, 2021, 8:16pm UTC](https://forum.endeavouros.com/t/post-your-handy-utility-scripts/7213/132 "2021-06-16T20:16:41Z")

</div>

But - the really burning question is: Is there a 🐸 hieroglyph? I know frogs were around then and there…

---

<div class="post-metadata">

**Author:** ![Kresimir](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/kresimir/32/73739_2.png) [@Kresimir](https://forum.endeavouros.com/u/Kresimir)\
**Post date:** [June 16, 2021, 8:24pm UTC](https://forum.endeavouros.com/t/post-your-handy-utility-scripts/7213/133 "2021-06-16T20:24:35Z")

</div>

Of course there is!

It’s glyph I7 in the [Gardiner’s Sign List](https://en.wikipedia.org/wiki/List_of_Egyptian_hieroglyphs#I) (glyph no. 7 under section I. Amphibious animals, reptiles, etc.).

There is also a tadpole, which is I8.

Frogs were very important in ancient Egyptian culture, religion, mysticism, and philosophy. They are symbols of fertility, childbirth, resurrection, and primeval times (before the creation of the universe). I could go on and on about this, but it’s quite off topic. 🐸

The Middle Egyptian word for frog was _qrr,_ probably pronounced something like ‘qurar’ (which is something a frog would say). Another onomatopoetic noun for an animal is _mjw_ which means cat (probably pronounced ‘miaw’).

---

<div class="post-metadata">

**Author:** ![freebird54](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/freebird54/32/83106_2.png) [@freebird54](https://forum.endeavouros.com/u/freebird54)\
**Post date:** [June 16, 2021, 8:29pm UTC](https://forum.endeavouros.com/t/post-your-handy-utility-scripts/7213/134 "2021-06-16T20:29:15Z")

</div>

Thank you! I learn the most interesting things here on the EnOS forum! 🐈 🐸

---

<div class="post-metadata">

**Author:** ![codic12](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/codic12/32/23959_2.png) [@codic12](https://forum.endeavouros.com/u/codic12)\
**Post date:** [June 20, 2021, 6:43am UTC](https://forum.endeavouros.com/t/post-your-handy-utility-scripts/7213/135 "2021-06-20T06:43:45Z")

</div>

Absolutely beautiful! `𓋍&&` is a work of art…

---

<div class="post-metadata">

**Author:** ![Kresimir](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/kresimir/32/73739_2.png) [@Kresimir](https://forum.endeavouros.com/u/Kresimir)\
**Post date:** [July 7, 2021, 4:09pm UTC](https://forum.endeavouros.com/t/post-your-handy-utility-scripts/7213/136 "2021-07-07T16:09:59Z")

</div>

Here is a little script that generates mixed case:

```plaintext
#!/bin/bash
# A sImPlE sCrIpt tHAt GeNErAtEs MiXed cAse FroM ItS STdIn

max_repeat=2

function coinflip() {
  printf $(($RANDOM%2))
}

while read line; do
  uppercase_line="${line^^}"
  lowercase_line="${line,,}"
  len=${#line}
  flip=$(coinflip)
  n=0

  for ((i = 0; i < len; i++)); do
    oldflip=$flip
    flip=$(coinflip)

    if ((flip == oldflip)); then
      ((n++))
    fi

    if ((n >= max_repeat)); then
      n=0
      ((flip = !flip))
    fi

    if ((flip)); then
      printf '%s' "${uppercase_line:$i:1}"
    else
      printf '%s' "${lowercase_line:$i:1}"
    fi
  done

  printf '\n'
done < "${1:-/dev/stdin}"

```

Usage:

```plaintext
$ ./mixcase <<< 'Just pipe text into it and it will create mixed case!'
jUsT pIpE tExt inTo iT aNd It wiLL cReaTe miXeD cASe!

```

 ![mocking_spongebob](https://forum.endeavouros.com/uploads/default/original/3X/0/6/0666e8228c8e2fc5303b83d7b7a209596e9b8a78.jpeg)

Useful for most online interactions.

2023-08-23: Updated the script to not use `sed`, but instead use built-in Bash string manipulation techniques.

---

<div class="post-metadata">

**Author:** ![ericbandrakim](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/ericbandrakim/32/31129_2.png) [@ericbandrakim](https://forum.endeavouros.com/u/ericbandrakim)\
**Post date:** [July 7, 2021, 5:47pm UTC](https://forum.endeavouros.com/t/post-your-handy-utility-scripts/7213/137 "2021-07-07T17:47:12Z")

</div>

nice …

---

<div class="post-metadata">

**Author:** ![xircon](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/xircon/32/9124_2.png) [@xircon](https://forum.endeavouros.com/u/xircon)\
**Post date:** [July 19, 2021, 9:43pm UTC](https://forum.endeavouros.com/t/post-your-handy-utility-scripts/7213/138 "2021-07-19T21:43:03Z")

</div>

Gnome disable lid switch / enable lid switch:

```auto
#!/usr/bin/env bash

if [["$1" == "1"]]; then
    kill -9 ` pgrep -f gnome-tweak-tool-lid-inhibitor`
    echo "Lid switch working"
fi

if [["$1" == "0"]]; then
    /usr/lib/gnome-tweak-tool-lid-inhibitor&
    echo "Lid switch disabled"
fi

if [["$1" == ""]]; then
    echo "Usage:"
    echo "Disable lid switch - lidsw 0"
    echo "Enable lid switch - lidsw 1"
fi

```

For when you are streaming a film and need to close your laptop lid 😃 Quicker than tweaks…

---

<div class="post-metadata">

**Author:** ![ceph](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/ceph/32/30222_2.png) [@ceph](https://forum.endeavouros.com/u/ceph)\
**Post date:** [July 20, 2021, 3:25am UTC](https://forum.endeavouros.com/t/post-your-handy-utility-scripts/7213/139 "2021-07-20T03:25:11Z")

</div>

How do you get the emoji’s quickly on the terminal?  
I could think of opening emoji selector, searching, selecting(will copy it) and pasting it on the terminal, but is there any easier way? also helpful if not just in terminal but over the OS.  
So far, I could be able to find this : [https://hub.espanso.org/packages/all-emojis/#](https://hub.espanso.org/packages/all-emojis/#)

---

<div class="post-metadata">

**Author:** ![Kresimir](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/kresimir/32/73739_2.png) [@Kresimir](https://forum.endeavouros.com/u/Kresimir)\
**Post date:** [July 20, 2021, 6:25am UTC](https://forum.endeavouros.com/t/post-your-handy-utility-scripts/7213/140 "2021-07-20T06:25:23Z")

</div>

> [@ceph](#):
>
> How do you get the emoji’s quickly on the terminal?

See @jonathon post:

> [@Post your handy utility scripts!](https://forum.endeavouros.com/t/post-your-handy-utility-scripts/7213/127):
>
> An Arch TU told me about this: [https://wiki.archlinux.org/title/IBus#Emoji\_input](https://wiki.archlinux.org/title/IBus#Emoji_input) It brought my system into the 21st century… rofl $ unicornrainbowzsh: command not found: unicornrainbowsob

It’s slightly finicky to get it to work, but once you do, it’s really nice.

---

<div class="post-metadata">

**Author:** ![ericbandrakim](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/ericbandrakim/32/31129_2.png) [@ericbandrakim](https://forum.endeavouros.com/u/ericbandrakim)\
**Post date:** [July 23, 2021, 9:44am UTC](https://forum.endeavouros.com/t/post-your-handy-utility-scripts/7213/141 "2021-07-23T09:44:43Z")

</div>

When installed **emojione-picker**.

```auto
$ yay emojione-picker-git

```

You can do

```auto
$ emojione-picker --help

```

From there you can select an emoji 🙂

Just found out myself.  
 ![Screenshot_2021-07-23_11-47-44](https://forum.endeavouros.com/uploads/default/original/3X/5/3/538fb62d434cf7fcfdeaeb4056ddcc8d889cda71.png)

edit typo

[Previous page](https://forum.endeavouros.com/t/post-your-handy-utility-scripts/7213.md?page=6)

[Next page](https://forum.endeavouros.com/t/post-your-handy-utility-scripts/7213.md?page=8)
