defmodule Fakererer.Blog.En do
@moduledoc "Functions for generating fake blog post data in English."
import Fakererer, only: [sampler: 2, random_between: 2]
@tag_pool [
"elixir", "phoenix", "erlang", "otp", "beam",
"javascript", "typescript", "react", "vue", "angular",
"python", "django", "flask", "fastapi",
"rust", "go", "ruby", "java", "kotlin",
"docker", "kubernetes", "aws", "gcp", "azure",
"devops", "ci-cd", "terraform", "ansible",
"postgresql", "mysql", "redis", "mongodb", "elasticsearch",
"graphql", "rest", "grpc", "websocket",
"machine-learning", "deep-learning", "ai", "nlp", "computer-vision",
"blockchain", "web3", "defi", "smart-contracts",
"security", "authentication", "authorization", "encryption",
"microservices", "monolith", "serverless", "event-driven",
"testing", "tdd", "bdd", "property-based-testing",
"performance", "optimization", "caching", "profiling",
"architecture", "design-patterns", "clean-code", "solid",
"agile", "scrum", "kanban", "productivity",
"open-source", "community", "career", "interview"
]
sampler(:title_prefix, [
"How to", "Why You Should", "The Ultimate Guide to",
"Understanding", "Exploring", "Introduction to",
"Getting Started with", "Deep Dive into", "The Future of",
"Best Practices for", "Building", "Scaling",
"Everything You Need to Know About", "A Comprehensive Look at",
"Mastering", "The Art of", "Demystifying",
"From Zero to Hero with", "Advanced", "The Complete Guide to"
])
sampler(:title_subject, [
"Elixir and Phoenix", "Microservices Architecture", "Machine Learning",
"Blockchain Technology", "Cloud Computing", "DevOps Practices",
"Web Security", "API Design", "Database Optimization",
"Functional Programming", "React and TypeScript", "Kubernetes",
"Docker Containers", "CI/CD Pipelines", "GraphQL APIs",
"Rust Programming", "Go Concurrency", "Python for Data Science",
"System Design", "Distributed Systems", "Real-time Applications",
"Serverless Architecture", "Event-Driven Design", "CQRS and Event Sourcing",
"WebAssembly", "Edge Computing", "IoT Solutions",
"Natural Language Processing", "Computer Vision", "Reinforcement Learning"
])
sampler(:short_info_template, [
"A comprehensive guide covering the fundamentals and advanced concepts.",
"Exploring the latest trends and best practices in the industry.",
"An in-depth look at how modern teams approach this challenge.",
"Learn the essential patterns and techniques used by experts.",
"A practical walkthrough with real-world examples and code samples.",
"Understanding the core principles behind successful implementations.",
"Discover the tools and strategies that top engineers rely on.",
"From theory to practice: building production-ready solutions.",
"A deep dive into the architecture and design decisions that matter.",
"Exploring common pitfalls and how to avoid them in your projects.",
"An expert perspective on the evolution and future direction of the field.",
"Hands-on tutorial covering everything from setup to deployment.",
"Comparing different approaches and choosing the right tool for the job.",
"A beginner-friendly introduction with progressive complexity.",
"Lessons learned from building and maintaining large-scale systems."
])
sampler(:sentence_starter, [
"In today's rapidly evolving tech landscape",
"As developers, we often encounter",
"One of the most important aspects to consider is",
"When building production systems",
"The key to understanding this concept lies in",
"Many teams struggle with",
"It's worth noting that",
"From a practical standpoint",
"The industry has shifted towards",
"Research shows that",
"In our experience",
"The fundamental principle here is",
"What makes this approach unique is",
"Let's take a closer look at",
"The beauty of this pattern is",
"Historically, developers have",
"The challenge most teams face is",
"When we examine the data",
"This approach offers several advantages including",
"The underlying architecture enables"
])
sampler(:sentence_middle, [
"the importance of choosing the right tool for the job cannot be overstated",
"scalability should be a primary concern from day one",
"maintaining code quality requires discipline and good practices",
"the trade-offs between different approaches must be carefully evaluated",
"performance optimization starts with understanding the bottlenecks",
"security considerations should be baked in from the start",
"the ecosystem around this technology has matured significantly",
"developer experience plays a crucial role in adoption",
"the learning curve can be steep but the payoff is substantial",
"community support and documentation quality make a huge difference",
"the underlying principles remain consistent across different implementations",
"real-world usage often differs significantly from theoretical best practices",
"the choice of data structures and algorithms impacts overall performance",
"proper error handling and logging are essential for maintainability",
"the testing strategy should align with the project's risk profile",
"deployment automation reduces the chance of human error",
"monitoring and observability are non-negotiable in production",
"the cost of technical debt compounds over time",
"team communication and documentation are as important as the code itself",
"continuous learning is essential in this ever-changing field"
])
sampler(:sentence_ending, [
"and this trend is expected to continue in the coming years.",
"which ultimately leads to better outcomes for everyone involved.",
"making it a solid choice for teams of all sizes.",
"though it requires careful planning and execution.",
"and the results speak for themselves.",
"so it's important to stay up to date with the latest developments.",
"which is why so many organizations have adopted this approach.",
"but the investment in learning pays dividends over time.",
"and this is reflected in the growing community around it.",
"so choose wisely based on your specific requirements.",
"and don't be afraid to iterate on your initial design.",
"which makes it an excellent candidate for greenfield projects.",
"though legacy systems may require a more gradual migration strategy.",
"and the tooling continues to improve with each release.",
"so start small and scale as your confidence grows.",
"and remember that simplicity should always be the goal.",
"which is a testament to the power of open-source collaboration.",
"so take the time to understand the fundamentals before diving in.",
"and always keep the end user experience in mind.",
"making this one of the most exciting areas in technology today."
])
@doc "Returns a random blog post title."
@spec title() :: String.t()
def title do
"#{title_prefix()} #{title_subject()}"
end
@doc "Returns a random short info / excerpt."
@spec short_info() :: String.t()
def short_info do
count = random_between(1, 2)
1..count
|> Enum.map(fn _ -> short_info_template() end)
|> Enum.join(" ")
end
@doc "Returns a random list of 2-5 tags."
@spec tags() :: [String.t()]
def tags do
count = random_between(2, 5)
Enum.take_random(@tag_pool, count)
end
@doc "Returns random blog post content of approximately 20 sentences."
@spec content() :: String.t()
def content do
target = random_between(18, 22)
sentences =
1..target
|> Enum.map(fn _ ->
"#{sentence_starter()} #{sentence_middle()} #{sentence_ending()}"
end)
Enum.join(sentences, " ")
end
end