Skip to content

Commit d815e76

Browse files
committed
Extract salutations module
1 parent 72fc422 commit d815e76

File tree

2 files changed

+63
-52
lines changed

2 files changed

+63
-52
lines changed

src/resume/__init__.py

Lines changed: 3 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
from itertools import product
21
from pathlib import Path
3-
import json
4-
import random
2+
3+
from .salutations import typed_salutations
54

65

76
def get_resume(format, name='resume'):
@@ -33,54 +32,6 @@ def experience_skills(job_id=None):
3332
return [s.strip() for s in skills[job_id].split('+') if s]
3433

3534

36-
def salutation_permutations():
37-
"""Say 'Hello, my name is' in a bunch of ways"""
38-
hellojis = '👋 🌊 🙋 🖖'.split()
39-
40-
hello = (
41-
'hello sawubona haai molo dumela'
42-
'hi yo sup hiya hey howzit hoesit aweh hola heita'
43-
).split()
44-
hello.extend(['whakind eksê', 'hoe lyk it'])
45-
46-
my_names_are = [
47-
'my name is',
48-
'my naam is',
49-
'igama lami ngu',
50-
'lebitso la ka ke'
51-
]
52-
53-
salutation_permutations = list(product(
54-
hellojis, hello, my_names_are
55-
))
56-
random.shuffle(salutation_permutations)
57-
58-
salutations = [
59-
f'🤓{emoji} {hello}, {my_name_is} '
60-
for emoji, hello, my_name_is in salutation_permutations
61-
]
62-
return salutations
63-
64-
65-
TYPED_JS = "https://cdn.jsdelivr.net/npm/typed.js@2.0.12"
66-
def typed_salutations():
67-
return typed_js('h1', salutation_permutations())
68-
69-
def typed_js(dom_element, things_to_type):
70-
options = json.dumps(dict(
71-
smartBackspace=True,
72-
startDelay=3000,
73-
showCursor=False,
74-
typeSpeed=50,
75-
strings=things_to_type,
76-
))
77-
78-
return '\n'.join([
79-
f'<script src="{TYPED_JS}"></script>',
80-
f"<script>var typed = new Typed('{dom_element}', {options});</script>",
81-
])
82-
83-
8435
BADGE_URL_TEMPLATE = "https://img.shields.io/badge/{badge_name}?style={style}&logo={logo}&logoColor={colour}"
8536
SKILL_BADGE_MAP = {
8637
# browsers
@@ -134,6 +85,7 @@ def generate_badge_url(skill):
13485
'badge_name style logo colour'.split(),
13586
[skill_id, 'for-the-badge', skill, 'white'],
13687
)))
88+
13789
def skills_badge_urls(company=None):
13890
badges = [
13991
generate_badge_url(skill)
@@ -145,7 +97,6 @@ def skills_badge_urls(company=None):
14597
return ' '.join([f'<img src="{url}"/>' for url in badges])
14698

14799

148-
149100
def define_env(env):
150101
env.variables['skills_badge_urls'] = skills_badge_urls
151102
env.variables['typed_salutations'] = typed_salutations

src/resume/salutations.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
from itertools import product
2+
import json
3+
import random
4+
5+
6+
def salutation_permutations():
7+
"""Say 'Hello, my name is' in a bunch of ways"""
8+
hellojis = '👋 🌊 🙋 🖖'.split()
9+
# https://www.babbel.com/en/magazine/how-to-say-hello-in-10-different-languages
10+
hello = """
11+
hi yo oi
12+
sup hey olá hoi hai hej
13+
ciao hiya aweh hola haai molo
14+
heita hello salut ahlan
15+
howzit hoesit dumela halløj goddag
16+
sawubona
17+
""".split()
18+
hello.extend(['whakind eksê', 'hoe lyk it'])
19+
hello = 'hi yo sup hiya hey haai aweh hola molo haai'.split()
20+
# my_names_are = ['my name is', 'my naam is', 'igama lami ngu']
21+
popeyes = ["i'm ", "ek is ", "ngingu", "ke "]
22+
amongst_our_names = "michael michel mikhail mihály mícheál michele michal miguel mihail michiel mikel mihangel mícheál mikkel".split()
23+
24+
# https://smodin.io/translate-one-text-into-multiple-languages
25+
26+
salutation_permutations = list(product(
27+
hellojis, hello, popeyes, amongst_our_names
28+
))
29+
random.shuffle(salutation_permutations)
30+
31+
salutations = [
32+
f'🤓{emoji}{hello}, {my_name_is}{me}'
33+
for emoji, hello, my_name_is, me in salutation_permutations
34+
]
35+
return salutations
36+
37+
38+
TYPED_JS = "https://cdn.jsdelivr.net/npm/typed.js@2.0.12"
39+
TYPED_TEMPLATE = """
40+
<script src="{js_url}"></script>
41+
<script>
42+
var typed = new Typed('{dom_element}', {options});
43+
</script>
44+
"""
45+
def typed_salutations():
46+
return typed_js('h1', salutation_permutations())
47+
48+
def typed_js(dom_element, things_to_type):
49+
options = json.dumps(dict(
50+
startDelay=3000,
51+
smartDelete=True,
52+
showCursor=False,
53+
typeSpeed=50,
54+
strings=things_to_type,
55+
))
56+
return TYPED_TEMPLATE.format(
57+
js_url=TYPED_JS,
58+
dom_element=dom_element,
59+
options=options
60+
)

0 commit comments

Comments
 (0)