Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate WatchJuliaBurn with Glyphy.jl #32

Closed
adrhill opened this issue Aug 17, 2022 · 3 comments
Closed

Automate WatchJuliaBurn with Glyphy.jl #32

adrhill opened this issue Aug 17, 2022 · 3 comments

Comments

@adrhill
Copy link
Collaborator

adrhill commented Aug 17, 2022

Glyphy.jl could be used to run through all Julia Base functions and automatically generate entries for the func_to_emojis Dictionary.

Proof of concept:

julia> using Glyphy: _query_db

julia> function glyphyfy(func)
           s = string(func)
           findstatement = "select * from unicodechart where name like '%$s%' ESCAPE '`';"
           query = _query_db(findstatement)
           emoji = [Symbol(Char(entry.id)) for entry in query]
           return Symbol(func) => tuple(emoji...)
       end
glyphyfy (generic function with 1 method)

julia> glyphyfy(print)
:print => (:⎙, :㊞, :🐾, :👣, :🖨, :🖶)
@adrhill
Copy link
Collaborator Author

adrhill commented Dec 15, 2023

I've updated this to autogenerate suggestions for any module:

using Glyphy: _query_db

findstatement(name) = "select * from unicodechart where name like '%$name%' ESCAPE '`';"

# NOTE: this list most likely isn't complete
const unicode_emoji_ranges = [
    # Miscellaneous Symbols
    0x2600:0x26FF,
    # Dingbats
    0x2700:0x27BF,
    # Miscellaneous Symbols and Arrows
    0x2B00:0x2BFF,
    # Miscellaneous Symbols and Pictographs
    0x1F300:0x1F5FF,
    # Smileys
    0x1F600:0x1F64F,
    # Transport and Map Symbols
    0x1F680:0x1F6FF,
    # Supplemental Symbols and Pictographs
    0x1F900:0x1F9FF,
    # Flags
    0x1F1E6:0x1F1FF,
]

function isemoji(i::Integer)
    # speed things up with a coarse check...
    i < 0x2600 || i > 0x1F9FF && return false
    i in 0x2BFF:0x1F300 && return false
    # ...then check more precisely
    for r in unicode_emoji_ranges
        i in r && return true
    end
    return false
end

function glyphyfy(name::AbstractString)
    query = _query_db(findstatement(name))
    ids = [UInt(q.id) for q in query]
    emoji = [Char(id) for id in ids if isemoji(id)]
    return name => tuple(emoji...)
end

function wjb_candidates(m::Module)
    fn_names = String.(names(m))
    # short names match with too many glyphs
    filter!(n -> length(n) > 2, fn_names)
    glyphs = glyphyfy.(fn_names)
    return Dict(k => v for (k, v) in glyphs if !isempty(v))
end

function print_md_table(io, candidates)
    println(io, "| Function | Emoji |")
    println(io, "|:---------|:------|")
    for (k, v) in candidates
        println(io, "| $k | $(join(v)) |")
    end
end
print_md_table(candidates) = print_md_table(stdout, candidates)

# Apply it on LinearAlgebra.jl
using LinearAlgebra
candidates = wjb_candidates(LinearAlgebra)
print_md_table(candidates)

which outputs

Function Emoji
triu 😤
dot ⚆⚇⚈⚉⛣⬚⬸💠🔯🕃🕄🤀🤁🤃🤄🤅🤆🤊🤋
cond 🥈
Diagonal ⛞⬔⬕
diag ⛞⬔⬕
kron
cross ☠☦☨☩♰♱⚔⛌⛑⛒⛨✙✚✛✜✝✞✟✠❌❎⯞🎌🕀🕁🕂🕆🕇🕈🕱🚸🤀🤁🤂🤞🥍

@adrhill
Copy link
Collaborator Author

adrhill commented Dec 15, 2023

Running this on Julia Base returns:

Function Emoji
ENV ✉📨📩🖂🖃🖄🖅🖆🧧
rem 🎑🎗
parent ❨❩❪❫
angle ⛛❬❭❮❯❰❱➝➞➟➠⭍⭠⭡⭢⭣⭤⭥⭦⭧⭨⭩⭪⭫⭬⭭⭮⭯⭰⭱⭲⭳⭶⭷⭸⭹⭺⭻⭼⭽⮀⮁⮂⮃⮄⮅⮆⮇⮌⮍⮎⮏⮠⮡⮢⮣⮤⮥⮦⮧⮹⯅⯆⯇⯈⯬⯭⯮⯯⯾🔺🔻🔼🔽🛆
empty 🗅🗆🗇🗋🗌🗍
range 📙🔶🔸🧡
round ⛱➜📍🛆🛝
dump 🥟
Text 🖹🖺🗟
Base
floor 🤣
flush 😳
reverse ☙⭁⭂⭇⭈⭋⭌⯾🖑🖒🖓🖔🖕
hton 🕾🕿
view 🎑
zip 🤐
mark ✅✓✔❌❎❓❔❕❗❛❜❝❞❟❠❢❣❮❯⯒💋📑🔖🔛🕅🗸
close ⛜🌂📕📪📫🔐😆😚😝😽🚾🤫
map ⛯🍁🗺
mod 🏻🏼🏽🏾🏿📳🖀🛌🤻
last ☾♳♴♵♶♷♸♹🌗🌜
strip
merge ⛘⛙
exp 😑🤯
max 🗖
Pair ⮄⮅⮆⮇
print 🐾👣🖨🖶
log ⯳⯴⯵⯶⯷⯸
cat ✆✕✖⯐🐈🐱😸😹😺😻😼😽😾😿🙀
cis ✀✁✂✃✄
kron
open ✛✜✫✲✼❂➾⭮⭯👐📂📖📬📭🔁🔂🔃🔄🔓🗁😃😄😅😆😦😮😰😺🤮
run 🎽🏃
inv
conj
abs 📑
Set ⭄🌇🏵🏶📼🚾
div ⚮➗🗂🤿
first ☽🌓🌛🥇
get 🤲
eps 💪
sign ☡☢☣♀♂♭♮♯♾⚠⚡⚢⚣⚤⚥⚦⚧⚨⚩⛚✆❡➕➖➗⭀⯑⯹🍥👊👋👌👍👎👏👐💲💴💵💶💷💹🖏🖒🖓🚧🚫🛇🛑🤘🤟
show 🚿
Val
lock ⚤⭮⭯⮌⮍⮎⮏⮔🔁🔂🔃🔄🔏🔐🔒🔓🕐🕑🕒🕓🕔🕕🕖🕗🕘🕙🕚🕛🕜🕝🕞🕟🕠🕡🕢🕣🕤🕥🕦🕧🕰🗘
NaN 🍌🏱🏲🤰
esc ☋☪⚕🌒🌘🌙🎝🔭
one ☎☏☠⛕⛼✆❶➀➊⯰🍖🍯🎙🎤🎧🎷🐝💎💰💸📞📣📱📲📴📵🔂🔉🔞🕐🕜🕩🕱🕻🕼🕽🕾🕿🖀🖁🖯🙋🤑🤨🤪🥌🦰🦱🦲🦳🦴
tan ⮹🍊🎋🦧🧍
touch 🕾🕿
stat 🗽🚉
chop 🥢
min ♊❖➖🍜🎗🎭🏸💽📨🗕😱🚍🚐🚔🚖🚘🛱🦩
position ☍⯐🧘
sleep 💤😪😴🛌
nor ➚➶➹⬀⬁⬈⬉⭎⭚⭜⭞⭟⭦⭧⭶⭷🕎🚝🛪
Inf ⯹💁🛈
ones ☠📵🕱
tand 🧍
size 🗚🗛
all ☐☑☒♽⚬⚴⚽⚾⛞⛹✗✘✣✤✾❁❉⬝⬞⬩⬪⬫⬰⭑⭒⮽🌤🍂🍙🎈🎊🎾🏀🏈🏉🏏🏐🏑🏓💬💭🔡🔮🔸🔹🔼🔽🖊🖲🗳🗴🗵🗶🗷🗹🛨🛩🤙🤪🤾🥍🥎🥘🧶
sec 🥈
sin ⛌⛒❛❜❟🕴😗😙😚😽🙋🙌🚸
read 🍞🥖🥙🧵

@adrhill
Copy link
Collaborator Author

adrhill commented Dec 15, 2023

Some suggestions I like:

  • ENV 🧧
  • div 🤿
  • flush 😳
  • get 🤲
  • chop 🥢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant