Skip to content

Commit

Permalink
A whole new world (#41)
Browse files Browse the repository at this point in the history
* Add a bunch of new emoji

* Emojify source code

---------

Co-authored-by: @adrhill
  • Loading branch information
theogf committed Dec 21, 2023
1 parent a76ce99 commit 325ac01
Show file tree
Hide file tree
Showing 8 changed files with 174 additions and 114 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ jobs:
- '1.3'
- '1.4'
- '1.5'
- '1.6'
- '1.7'
- '1.8'
- '1'
- 'nightly'
os:
Expand Down
160 changes: 95 additions & 65 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ For a serious use of unicode characters see also [Ueauty.jl](https://gitlab.com/

## Add your own awfulness!

Don't hesitate to add your worst creations via PR. All you need to do is to add the function and emoji to the `func_to_emojis` internal `Dict`. Don't touch the `README`!
Don't hesitate to add your worst creations via PR. All you need to do is to add the function and emoji to the `😃📖` internal `📖` in `src/📖.jl`. Don't touch the `README`!
It will be automatically generated after your PR is merged. Also tests are optional since tests are for losers!

## Emojify your code

You can use the `emojify` function to recursively emojify all the files in a given path. `emojify` will replace all functions for which an alias is known
by the corresponding emoji (a random one is picked every time if multiple options are possible).
by the corresponding emoji (a random one is picked every ⏲️ if multiple options are possible).
For example:

```julia
Expand All @@ -22,73 +22,103 @@ vcat(round(log(pi)), broadcast(tan ∘ inv, rand(3)))
will return

```julia
⬇️😻(🔵(🪵(🥧)), 📡(🧑🏻➡️🧑🏽 , 🎲(3)))
⬇️😻(🎠(🪵(🍰)), 📡(🧑🏻➡️🧑🏽 , 🎲(3)))
```

## List of emojis

| Function | Emojis | Julia Version |
| --------------------:| --------------:| -------------:|
| `ArgumentError` | 💬🚨 | |
| `Dict` | 📖 | |
| `Matrix` | 🔢 | |
| `Threads` | 🧵 | |
| `abs` | 👔💪, 🎽💪 | |
| `axes` | 🪓🪓 | 1.2 |
| `broadcast` | 📡 | |
| `cat` | 😻, 😹, 🐈 | |
| `cd` | 💿 | |
| `chop` | 🌳🪓 | 1.2 |
| `clamp` | 🗜️ | |
| `collect` | 🧺 | |
| `cot` | 🧥, 🥼 | |
| `count` | 🧮 | |
| `count_ones` | 🧮1️⃣1️⃣ | |
| `count_zeros` | 🧮0️⃣0️⃣ | |
| `delete!` | 🔥 | |
| `download` | 📥 | |
| `error` | 💣 | |
| `exit` | 🚪 | |
| `false` | 👎 | |
| `fill` | 🚰 | |
| `findall` | 🕵️ | |
| `findfirst` | 🔎🥇 | |
| `findnext` | 🔎⏭ | |
| `first` | 🥇 | |
| `float` | ⛵️ | |
| `foldr` | 🗂, 📁 | |
| `hcat` | ➡️😻, ➡️😹, ➡️🐈 | |
| `imag` | 🔮 | |
| `inv` || |
| `isreal` | 🛸❓ | |
| `join` | 🚪🚶 | |
| `keys` | 🔑, 🗝 | |
| `kill` | ⚰️ | |
| `log` | 🪵 | 1.5 |
| `map` | 🗺 | |
| `mean ∘ skipmissing` | 😠 | |
| `mod` | 🛵🔧 | |
| `nothing` || |
| `peek` | ⛰️ | 1.5 |
| `pi` | 🥧, 🍰 | |
| `pop!` | 🍾, 🏹🎈 | |
| `print` | 🖨️ | |
| `rand` | 🎰, 🎲 | |
| `raw` | 🥩 | |
| `round` | 🎠, 🔵 | |
| `run` | 🏃 | |
| `show` | ☝️ | |
| `sign` | 🪧, 🚏 | 1.5, 1.5 |
| `sleep` | 😴, 💤 | |
| `string` | 🎻 | |
| `tan` | 🧑🏻➡️🧑🏽, 👩🏻➡️👩🏽 | |
| `throw` | c╯°□°ↄ╯, 🤮, 🚮 | |
| `time` | ⏱️, ⌛, ⏲️ | |
| `true` | ✅, 👍, 👌 | |
| `vcat` | ⬇️😻, ⬇️😹, ⬇️🐈 | |
| `view` | 👀, 👁️ | |
| `write` | 🖊️, ✍️, 🖋️ | |
| `zip` | 🤐 | |
| Function | Emojis | Julia Version |
| --------------------:| -------------------------------:| -------------:|
| `AbstractChar` | 🫥🚗 | |
| `AbstractDict` | 🫥📖 | |
| `AbstractDisplay` | 🫥📺 | |
| `AbstractFloat` | 🫥🛟 | |
| `AbstractMatrix` | 🫥🔢 | |
| `AbstractString` | 🫥🧵 | |
| `ArgumentError` | 💬🚨 | |
| `Bool` | 👍👎 | |
| `Char` | 🚗 | |
| `Dict` | 📖 | |
| `ENV` | 🧧 | |
| `IO` | 🪀½, 👁️😲 | |
| `Matrix` | 🔢 | |
| `String` | 🧵 | |
| `Threads` | 🪢 | |
| `abs` | 👔💪, 🎽💪 | |
| `any` | 👩 | |
| `axes` | 🪓🪓 | 1.2 |
| `broadcast` | 📡 | |
| `cat` | 😻, 😹, 🐈 | |
| `cd` | 💿, 🇨🇩 | |
| `chop` | 🥢, 🌳🪓 | 1, 1.2 |
| `clamp` | 🗜️ | |
| `collect` | 🧺 | |
| `cot` | 🧥, 🥼 | |
| `count` | 🧮 | |
| `count_ones` | 🧮1️⃣1️⃣ | |
| `count_zeros` | 🧮0️⃣0️⃣ | |
| `delete!` | 🔥 | |
| `display` | 📺 | |
| `div` | (Symbol(Char(0x0001f93f)), 1.2) | |
| `download` | 📥 | |
| `dump` | 💩 | |
| `eachindex` | ☝️☝️ | |
| `error` | 💣 | |
| `exit` | 🚪 | |
| `false` | 👎 | |
| `fill` | 🚰 | |
| `findall` | 🕵️ | |
| `findfirst` | 🔎🥇 | |
| `findnext` | 🔎⏭ | |
| `first` | 🥇 | |
| `float` | ⛵️, 🛟 | |
| `flush` | 😳 | |
| `foldr` | 🗂, 📁 | |
| `get` | 🤲 | |
| `getfield` | 🤲🌽, 🤲🌾 | |
| `getglobal` | 🤲🌍 | |
| `getindex` | 🤲☝️ | |
| `getkey` | 🤲🔑, 🤲🗝 | |
| `getproperty` | 🤲🏡 | |
| `hcat` | ➡️😻, ➡️😹, ➡️🐈 | |
| `im` | 🇮🇲 | |
| `imag` | 🔮 | |
| `inv` || |
| `isreal` | 🛸❓ | |
| `join` | 🚪🚶 | |
| `keys` | 🔑, 🗝 | |
| `kill` | ⚰️ | |
| `length` | 📏 | |
| `log` | 🪵 | 1.5 |
| `map` | 🗺 | |
| `mean ∘ skipmissing` | 😠 | |
| `mod` | 🛵🔧 | |
| `nothing` || |
| `peek` | ⛰️ | 1.5 |
| `pi` | 🥧, 🍰 | |
| `pop!` | 🍾, 🏹🎈 | |
| `print` | 🖨️ | |
| `push!` | 🏋️ | |
| `rand` | 🎰, 🎲 | |
| `raw` | 🥩 | |
| `round` | 🎠, 🔵 | |
| `run` | 🏃 | |
| `searchsorted` | 🔎🔤 | |
| `secd` | 🥈 | |
| `show` | ☝️ | |
| `sign` | 🪧, 🚏 | 1.5, 1.5 |
| `sleep` | 😴, 💤 | |
| `sort` | 🔤 | |
| `string` | 🎻 | |
| `tan` | 🧑🏻➡️🧑🏽, 👩🏻➡️👩🏽 | |
| `throw` | c╯°□°ↄ╯, 🤮, 🚮 | |
| `time` | 🕛, ⏱️, ⌛, ⏲️ | |
| `tr` | 🇹🇷 | |
| `true` | ✅, 👍, 👌 | |
| `vcat` | ⬇️😻, ⬇️😹, ⬇️🐈 | |
| `view` | 👀, 👁️ | |
| `write` | 🖊️, ✍️, 🖋️ | |
| `zip` | 🤐 | |
## Control Flow
You can now replace boring old try/catch/finally clauses with fancy monkey flow!

Expand Down
6 changes: 3 additions & 3 deletions src/WatchJuliaBurn.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ end

include("📖.jl")

for func in keys(func_to_emojis)
for symbol_info in func_to_emojis[func]
for func in keys(😃📖)
for symbol_info in 😃📖[func]
if symbol_info isa Symbol
@eval @new_emoji $(symbol_info) $(func)
elseif symbol_info isa Tuple
Expand All @@ -54,7 +54,7 @@ end

## Additional features (does not pass with @new_emoji)
@eval $(Symbol("@🥩_str")) = $(getfield(Main, Symbol("@raw_str")))
func_to_emojis[:(raw)] = (:(🥩),)
😃📖[:(raw)] = (:(🥩),)
emoji_to_func[:(🥩"")] = (:(raw""), "")

include("😃→🗿.jl")
Expand Down
45 changes: 36 additions & 9 deletions src/📖.jl
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
## Contains mapping from functions to func_to_emojis
## Contains mapping from functions to 😃📖
## Each function (treated as a Symbol) maps to a Tuple of Symbols and Tuple{Symbol,Float64} for
## emojis needing a specific version
const func_to_emojis = 📖(
const 😃📖 = 📖(
## Base
:ENV => (:(🧧),),
# Symbol(Char(0x1fae5))
:ArgumentError => (:(💬🚨),),
:AbstractChar => ((Symbol(Char(0x1fae5) * '🚗'), 1.8),),
:AbstractDict => ((Symbol(Char(0x1fae5) * '📖'), 1.8),),
:AbstractDisplay => ((Symbol(Char(0x1fae5) * '📺'), 1.8),),
:AbstractFloat => ((Symbol(Char(0x1fae5) * Char(0x1f6df)), 1.8),),
:AbstractString => ((Symbol(Char(0x1fae5) * '🧵'), 1.8),),
:Bool => (:(👍👎),),
:Char => (:(🚗),),
:Dict => (:(📖),),
:Threads => (:(🧵),),
:IO => ((Symbol(Char(0x1fa80) * '½'), 1.2), :(👁️😲),), # 🪀½
:Pair => (:(🍐),),
:Threads => ((Symbol(Char(0x1faa2)), 1.5),),
:String => (:(🧵),),
:any => (:(👩),), # (her name is Annie)
:broadcast => (:(📡),),
:cd => (:(💿),),
:chop => (:(🥢), (Symbol(Char(0x0001f333) * Char(0x0001fa93)), 1.2),), # 🌳🪓
:cd => (:(💿), :(🇨🇩)),
:chop => (:(🥢), (Symbol(Char(0x1f333) * Char(0x1fa93)), 1.2),), # 🌳🪓
:delete! => (:(🔥),),
:display => (:(📺),),
:download => (:(📥),),
:dump => (:(💩),),
:error => (:(💣),),
:exit => (:(🚪),),
:false => (:👎,),
Expand All @@ -22,32 +36,43 @@ const func_to_emojis = 📖(
:flush => (:(😳),),
:foldr => (:(🗂), :(📁),),
:get => (:(🤲),),
:getfield => (:(🤲🌽), (:🤲🌾),),
:getkey => (:(🤲🔑), :(🤲🗝),),
:getproperty => (:(🤲🏡),),
:join => (:(🚪🚶),),
:keys => (:(🔑), :(🗝),),
:kill => (:(⚰️),),
:map => (:(🗺),),
:nothing => (:(⬛),),
:peek => ((:(⛰️), 1.5),),
:pop! => (:(🍾), :(🏹🎈)),
:print => (:(🖨️),),
:rand => (:(🎰),:(🎲),),
:run => (:(🏃),),
:searchsorted => (:(🔎🔤),),
:show => (:(☝️),),
:sleep => (:(😴), :(💤),),
:sort => (:(🔤),),
:string => (:(🎻),),
:throw => (:(c╯°□°ↄ╯), :(🤮), :(🚮),),
:time => (:(🕛), :(⏱️), :(⌛), :(⏲️),),
:true => (:(✅), :(👍), :(👌),),
:write => (:(🖊️), :(✍️), :(🖋️),),
:zip => (:(🤐),),
## Arrays
## Arrays and iterators
:AbstractMatrix => ((Symbol(Char(0x1fae5) * '🔢'), 1.8),),
:Matrix => (:(🔢),),
:axes => ((Symbol(Char(0x1fa93)^2), 1.2),), # 🪓🪓
:cat => (:(😻), :(😹), :(🐈),),
:vcat => (:(⬇️😻), :(⬇️😹), :(⬇️🐈),),
:hcat => (:(➡️😻), :(➡️😹), :(➡️🐈),),
:collect => (:(🧺),),
:eachindex => (:(☝️☝️),),
:fill => (:(🚰),),
:getindex => (:(🤲☝️),),
:push! => (:(🏋️),),
:pop! => (:(🍾), :(🏹🎈)),
:length => (:(📏),),
:view => (:(👀), :(👁️),),
## Math
:abs => ((:👔💪),(:🎽💪),),
:clamp => (:(🗜️),),
Expand All @@ -56,7 +81,8 @@ const func_to_emojis = 📖(
:count_ones => (:(🧮1️⃣1️⃣),),
:count_zeros => (:(🧮0️⃣0️⃣),),
:div => (:(Symbol(Char(0x1f93f)), 1.2),), # 🤿
:float => ((:⛵️),),
:float => (:(⛵️), (Symbol(Char(0x1f6df)), 1.8),), # 🛟
:im => (:(🇮🇲),), # Island of Man flag
:imag => (:(🔮),),
:inv => (:(),),
:isreal => ((:🛸❓),),
Expand All @@ -65,7 +91,8 @@ const func_to_emojis = 📖(
:mod => (:(🛵🔧),),
:pi => (:(🥧), :(🍰),),
:round => (:(🎠), :(🔵),),
:secd => (:(🥈),),
:sign => ((Symbol(Char(0x1faa7)), 1.5),(Symbol(Char(0x1f68f)), 1.5),), # 🪧, 🚏
:tan => (:(🧑🏻➡️🧑🏽), :(👩🏻➡️👩🏽),),
:view => (:(👀), (:👁️),),
:tr => (:(🇹🇷),),
)
33 changes: 13 additions & 20 deletions src/😃→🗿.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""
emojify(path::String)
emojify(path::🧵)
Go recursively over all the files contained in path and replace
all possible occurence of functions with random emoji aliases
"""
function emojify(path::String; overwrite=👌)
function emojify(path::🧵; overwrite=👌)
if isdir(path)
for subpath in readdir(path)
emojify(joinpath(path, subpath); overwrite=overwrite)
Expand All @@ -15,8 +15,8 @@ function emojify(path::String; overwrite=👌)
return
end

function emojify_file(filepath::String; overwrite=👍)
str = String(read(filepath))
function emojify_file(filepath::🧵; overwrite=👍)
str = 🧵(read(filepath))
str = emojify_string(str)
if overwrite
🖊️(filepath, str)
Expand All @@ -26,26 +26,19 @@ function emojify_file(filepath::String; overwrite=👍)
end
end

function emojify_string(str::String)
for func in 🔑(func_to_emojis)
str = replace(str, Regex("\\b" * 🎻(func) * "\\b") => RandString(to_string.(func_to_emojis[func])))
function emojify_string(str::🧵)
for func in 🔑(😃📖)
str = replace(str, Regex("\\b" * 🎻(func) * "\\b") => 🎰🧵(🥈🎻.(😃📖[func])))
end
return str
end

function to_string(emoji::Symbol)
🎻(emoji)
end

function to_string(emoji::Tuple)
return 🎻(emoji[1])
end
🥈🎻(😃::Union{Symbol,Expr}) = 🎻(😃)
🥈🎻(😃::Tuple) = 🎻(🥇(😃))

## Allow to get a random 🎻 every ⏲️ it's printed
struct RandString{TS}
strings::TS
## Allow to 🤲 a random 🎻 every ⏲️ it's printed
struct 🎰🧵{T🧵} # RandString
🎻🎻🎻::T🧵
end

function 🖨️(io::IO, rs::RandString)
🖨️(io, 🎲(rs.strings))
end
🖨️(io::👁️😲, rs::🎰🧵) = 🖨️(io, 🎲(rs.🎻🎻🎻))
2 changes: 1 addition & 1 deletion src/🙈🙊🙉.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ macro 🐒(monkeyexpression::Expr)
elseif sub isa Expr && sub.args[1] == :🙊
state = :catch
catchblock = Expr(:block)
if length(sub.args) == 2
if 📏(sub.args) == 2
catchme = sub.args[2]
else
💣("Can only catch a single 💣 at once, duh!")
Expand Down
Loading

0 comments on commit 325ac01

Please sign in to comment.