Skip to content

Commit

Permalink
Merge branch '🖐️' into lh/🦶🔫
Browse files Browse the repository at this point in the history
  • Loading branch information
theogf authored Dec 18, 2023
2 parents 275bdf1 + 0af154e commit 01ac4c6
Show file tree
Hide file tree
Showing 11 changed files with 111 additions and 98 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ jobs:
arch:
- x64
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v1
- uses: actions/cache@v3
env:
cache-name: cache-artifacts
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
with:
version: 1
- run: |
julia -e 'using Pkg; Pkg.add("Latexify"); Pkg.develop(path="."); include("src/create_README.jl")'
julia -e 'using Pkg; Pkg.add("Latexify"); Pkg.develop(path="."); include("📜/👢🎀.jl")'
echo $(git diff)
- uses: EndBug/add-and-commit@v7
with:
Expand Down
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

[compat]
LinearAlgebra = "1"
Statistics = "1"
LinearAlgebra = "<0.0.1, 1"
Statistics = "<0.0.1, 1"
julia = "1"

[extras]
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[![CI](https://github.com/theogf/WatchJuliaBurn.jl/actions/workflows/CI.yml/badge.svg)](https://github.com/theogf/WatchJuliaBurn.jl/actions/workflows/CI.yml)
# ⌚<img src="https://raw.githubusercontent.com/JuliaLang/julia/🖐️/doc/src/assets/julia.ico" height="26"/>🔥.jl
# ⌚<img src="https://raw.githubusercontent.com/JuliaLang/julia/master/doc/src/assets/julia.ico" height="26"/>🔥.jl

WatchJuliaBurn aims at destroying the look of your code by adding emojis like :smile: and kaomojis like c╯°□°ↄ╯ instead of your favorite Julia functions.
For a serious use of unicode characters see also [Ueauty.jl](https://gitlab.com/ExpandingMan/Ueauty.jl)
Expand All @@ -22,7 +22,7 @@ vcat(round(log(pi)), broadcast(tan ∘ inv, rand(3)))
will return

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

## List of emojis
Expand Down
83 changes: 10 additions & 73 deletions src/WatchJuliaBurn.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
module WatchJuliaBurn

export @🐒
export @🥩_str
export @new_emoji
export emojify
using Base: print

using LinearAlgebra
using Statistics
const emoji_to_func = Dict{Any, Any}()

# Needed for the first global constant.
const 📖 = Dict

const emoji_to_func = 📖{Any, Any}()

"""
@new_emoji emoji function [min_julia version]
Expand Down Expand Up @@ -34,74 +40,7 @@ macro new_emoji(emoji, func, julia_version)
end)
end

## Contains mapping from functions to func_to_emojis
## 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 = Dict(
## Base
:throw => (:(c╯°□°ↄ╯), :(🤮), :(🚮),),
:map => (:(🗺),),
:broadcast => (:(📡),),
:Dict => (:(📖),),
:true => (:(✅), :(👍), :(👌),),
:false => (:👎,),
:delete! => (:(🔥),),
:print => (:(🖨️),),
:nothing => (:(⬛),),
:findall => (:(🕵️),),
:show => (:(☝️),),
:peek => ((:(⛰️), 1.5),),
:chop => ((Symbol(Char(0x0001f333) * Char(0x0001fa93)), 1.2),), # 🌳🪓
:ArgumentError => (:(💬🚨),),
:join => (:(🚪🚶),),
:foldr => (:(🗂), :(📁),),
:first => (:(🥇),),
:findfirst => (:(🔎🥇),),
:keys => (:(🔑), :(🗝),),
:rand => (:(🎰),:(🎲),),
:kill => (:(⚰️),),
:run => (:(🏃),),
:error => (:(💣),),
:cd => (:(💿),),
:zip => (:(🤐),),
## Arrays
:cat => (:(😻), :(😹), :(🐈),),
:vcat => (:(⬇️😻), :(⬇️😹), :(⬇️🐈),),
:hcat => (:(➡️😻), :(➡️😹), :(➡️🐈),),
:Matrix => (:(🔢),),
:collect => (:(🧺),),
:axes => ((Symbol(Char(0x1fa93)^2), 1.2),), # 🪓🪓
:fill => (:(🚰),),
## Math
:pi => (:(🥧), :(🍰),),
:tan => (:(🧑🏻➡️🧑🏽), :(👩🏻➡️👩🏽),),
:log => ((Symbol(Char(0x1fab5)), 1.5),), # 🪵
:clamp => (:(🗜️),),
:mod => (:(🛵🔧),),
:inv => (:(),),
:imag => (:(🔮),),
:round => (:(🎠), :(🔵),),
:time => (:(🕛),),
:cot => (:(🧥), :(🥼)),
:count => (:(🧮),),
:count_ones => (:(🧮1️⃣1️⃣),),
:count_zeros => (:(🧮0️⃣0️⃣),),
:findnext => ((:🔎⏭),),
:isreal => ((:🛸❓),),
:float => ((:⛵️),),
:sign => ((Symbol(Char(0x1faa7)), 1.5),(Symbol(Char(0x1f68f)), 1.5),), # 🪧, 🚏
:abs => ((:👔💪),(:🎽💪),),
:view => (:(👀), (:👁️),),
:write => (:(🖊️), :(✍️), :(🖋️),),
:Threads => (:(🧵),),
:time => (:(⏱️), :(⌛), :(⏲️),),
:string => (:(🎻),),
:download => (:(📥),),
:sleep => (:(😴), :(💤),),
:exit => (:(🚪),),
:pop! => (:(🍾), :(🏹🎈)),
:(mean skipmissing) => (:(😠),),
)
include("📖.jl")

for func in keys(func_to_emojis)
for symbol_info in func_to_emojis[func]
Expand All @@ -115,13 +54,11 @@ end

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

include("emojify.jl")
include("monkeycatch.jl")
export @🐒
include("😃→🗿.jl")
include("🙈🙊🙉.jl")

"""
arbitrary_pointer(page_size=0xfff)
Expand Down
68 changes: 68 additions & 0 deletions src/📖.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
## Contains mapping from functions to func_to_emojis
## 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 = 📖(
## Base
:throw => (:(c╯°□°ↄ╯), :(🤮), :(🚮),),
:map => (:(🗺),),
:broadcast => (:(📡),),
:Dict => (:(📖),),
:true => (:(✅), :(👍), :(👌),),
:false => (:👎,),
:delete! => (:(🔥),),
:print => (:(🖨️),),
:nothing => (:(⬛),),
:findall => (:(🕵️),),
:show => (:(☝️),),
:peek => ((:(⛰️), 1.5),),
:chop => ((Symbol(Char(0x0001f333) * Char(0x0001fa93)), 1.2),), # 🌳🪓
:ArgumentError => (:(💬🚨),),
:join => (:(🚪🚶),),
:foldr => (:(🗂), :(📁),),
:first => (:(🥇),),
:findfirst => (:(🔎🥇),),
:keys => (:(🔑), :(🗝),),
:rand => (:(🎰),:(🎲),),
:kill => (:(⚰️),),
:run => (:(🏃),),
:error => (:(💣),),
:cd => (:(💿),),
:zip => (:(🤐),),
## Arrays
:cat => (:(😻), :(😹), :(🐈),),
:vcat => (:(⬇️😻), :(⬇️😹), :(⬇️🐈),),
:hcat => (:(➡️😻), :(➡️😹), :(➡️🐈),),
:Matrix => (:(🔢),),
:collect => (:(🧺),),
:axes => ((Symbol(Char(0x1fa93)^2), 1.2),), # 🪓🪓
:fill => (:(🚰),),
## Math
:pi => (:(🥧), :(🍰),),
:tan => (:(🧑🏻➡️🧑🏽), :(👩🏻➡️👩🏽),),
:log => ((Symbol(Char(0x1fab5)), 1.5),), # 🪵
:clamp => (:(🗜️),),
:mod => (:(🛵🔧),),
:inv => (:(),),
:imag => (:(🔮),),
:round => (:(🎠), :(🔵),),
:time => (:(🕛),),
:cot => (:(🧥), :(🥼)),
:count => (:(🧮),),
:count_ones => (:(🧮1️⃣1️⃣),),
:count_zeros => (:(🧮0️⃣0️⃣),),
:findnext => ((:🔎⏭),),
:isreal => ((:🛸❓),),
:float => ((:⛵️),),
:sign => ((Symbol(Char(0x1faa7)), 1.5),(Symbol(Char(0x1f68f)), 1.5),), # 🪧, 🚏
:abs => ((:👔💪),(:🎽💪),),
:view => (:(👀), (:👁️),),
:write => (:(🖊️), :(✍️), :(🖋️),),
:Threads => (:(🧵),),
:time => (:(⏱️), :(⌛), :(⏲️),),
:string => (:(🎻),),
:download => (:(📥),),
:sleep => (:(😴), :(💤),),
:exit => (:(🚪),),
:pop! => (:(🍾), :(🏹🎈)),
:(mean skipmissing) => (:(😠),),
)
10 changes: 5 additions & 5 deletions src/emojify.jl → src/😃→🗿.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function emojify_file(filepath::String; overwrite=👍)
str = String(read(filepath))
str = emojify_string(str)
if overwrite
write(filepath, str)
🖊️(filepath, str)
return
else
return str
Expand All @@ -28,20 +28,20 @@ end

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

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

function to_string(emoji::Tuple)
return string(emoji[1])
return 🎻(emoji[1])
end

## Allow to get a random string every time it's printed
## Allow to get a random 🎻 every ⏲️ it's printed
struct RandString{TS}
strings::TS
end
Expand Down
18 changes: 9 additions & 9 deletions src/monkeycatch.jl → src/🙈🙊🙉.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ finally
baz()
end
```
you can now write the far more legible:
you can now ✍️ the far more legible:
```julia
💣 = foo
😥 = bar
Expand All @@ -30,12 +30,12 @@ you can now write the far more legible:
```
"""
macro 🐒(monkeyexpression::Expr)
monkeyexpression.head == :block || error("You have to wrap this in a begin...end block, sorry!")
monkeyexpression.head == :block || 💣("You have to wrap this in a begin...end block, sorry!")
newexpr = Expr(:block)
tryblock = Expr(:block)
catchme = false
catchblock = false
finallyblock = nothing
catchme = 👎
catchblock = 👎
finallyblock =
state = :start # where are we in the expression
for sub in monkeyexpression.args
if state == :start
Expand All @@ -44,7 +44,7 @@ macro 🐒(monkeyexpression::Expr)
elseif sub isa LineNumberNode
push!(newexpr.args, sub)
else
error("Missing 🙈")
💣("Missing 🙈")
end
elseif state == :try
if sub isa Symbol && sub == :🙊
Expand All @@ -56,7 +56,7 @@ macro 🐒(monkeyexpression::Expr)
if length(sub.args) == 2
catchme = sub.args[2]
else
error("Can only catch a single error at once, duh!")
💣("Can only catch a single 💣 at once, duh!")
end
elseif sub isa Symbol && sub == :🙉
state = :finally
Expand All @@ -76,10 +76,10 @@ macro 🐒(monkeyexpression::Expr)
end
end
if state == :try
error("Syntax: 🙈 without 🙊 or 🙉")
💣("Syntax: 🙈 without 🙊 or 🙉")
end
tryexpr = Expr(:try, tryblock, catchme, catchblock)
if !(finallyblock === nothing)
if !(finallyblock === )
push!(tryexpr.args, finallyblock)
end
push!(newexpr.args, tryexpr)
Expand Down
6 changes: 4 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using WatchJuliaBurn
using WatchJuliaBurn: arbitrary_pointer
using Test
using LinearAlgebra

Expand Down Expand Up @@ -53,8 +54,9 @@ using LinearAlgebra
@test 🔮(1 + 2im) == 2

## Monkey try/catch/finally
include("monkeytests.jl")

include("🐒tests.jl")
# Arbitrary pointers don't segfault on read
@test sum(unsafe_load(arbitrary_pointer()) for _ in 1:10_000_000) != 1729

end
File renamed without changes.
10 changes: 8 additions & 2 deletions src/create_README.jl → 📜/👢🎀.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ function to_version(emojis)
end
end


ar = reduce(vcat, ['`' * string(key) * '`' to_string(emojis) to_version(emojis)]
for (key, emojis) in ord_keys)
ar = vcat(["Function" "Emojis" "Julia Version"], ar)

md_ar = md(ar; latex=false)

code_snippet = "vcat(round(log(pi)), broadcast(tan ∘ inv, rand(3)))"

dots = "https://raw.githubusercontent.com/JuliaLang/julia/🖐️/doc/src/assets/julia.ico"
dots = "https://raw.githubusercontent.com/JuliaLang/julia/master/doc/src/assets/julia.ico"
intro = """[![CI](https://github.com/theogf/WatchJuliaBurn.jl/actions/workflows/CI.yml/badge.svg)](https://github.com/theogf/WatchJuliaBurn.jl/actions/workflows/CI.yml)
# ⌚<img src="$(dots)" height="26"/>🔥.jl
Expand Down Expand Up @@ -76,6 +76,12 @@ Parsing may behave weird when there are infix operators around the block. Try en
You can use the [EmojiSymbols.jl](https://github.com/wookay/EmojiSymbols.jl) package to super-turbo-charge your REPL experience!
"""

# Overwrite the README
open(joinpath(@__DIR__, "..", "README.md"), "w") do io
write(io, intro * string(md_ar) * outro)
end

# Emojify all the src files of WatchJuliaBurn.
foreach(walkdir(joinpath(pkgdir(WatchJuliaBurn), "src"))) do (root, dirs, files)
foreach(emojify, joinpath.(root, filter(!(["📖.jl", "WatchJuliaBurn.jl"]), files)))
end

0 comments on commit 01ac4c6

Please sign in to comment.