<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Michael M.H on Medium]]></title>
        <description><![CDATA[Stories by Michael M.H on Medium]]></description>
        <link>https://medium.com/@anteprocess?source=rss-1682466f6af5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*tKCi0VQe7R01TIUCD_vlvA.png</url>
            <title>Stories by Michael M.H on Medium</title>
            <link>https://medium.com/@anteprocess?source=rss-1682466f6af5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 04:25:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@anteprocess/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Python in 2026: 6 Amazing Things You Can Build (Even as a Beginner)]]></title>
            <link>https://medium.com/@anteprocess/python-in-2026-6-amazing-things-you-can-build-even-as-a-beginner-0e28347c0cd0?source=rss-1682466f6af5------2</link>
            <guid isPermaLink="false">https://medium.com/p/0e28347c0cd0</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[python-web-developer]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[python-programming]]></category>
            <dc:creator><![CDATA[Michael M.H]]></dc:creator>
            <pubDate>Fri, 05 Jun 2026 09:41:29 GMT</pubDate>
            <atom:updated>2026-06-05T09:43:10.817Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/905/1*Fukc3ru6cnsXFx4wKMiVbg.png" /></figure><p>Okay, so today I just want to yap about Python. Yes, if you’ve spent any time around technology recently, you’ve probably heard people talking about Python.</p><p>From artificial intelligence to automation, Python has become one of the most influential programming languages in the world. In fact, many of the technologies we use every day are powered by Python behind the scenes.</p><p><strong>But what exactly can Python do?</strong></p><p>Whether you’re a student, career changer, entrepreneur, or simply curious about coding, this guide will show you why millions of people are learning Python and how it can open doors to some of the fastest-growing careers in tech.</p><h3>Why Is Python So Popular?</h3><p>In the first place, Python was first released in 1991, but today it powers everything from AI systems to billion-dollar startups.</p><p>What makes Python special is its simplicity. When you compare it to many programming languages, Python’s syntax is easy to read and understand, making it one of the best languages for beginners while still being powerful enough for professional developers.</p><p>Let’s explore six incredible things you can build with Python.</p><h3>1. Artificial Intelligence and Machine Learning</h3><p>If there is one area where Python dominates, it’s AI.</p><p>Many of the world’s most advanced AI systems rely on Python. Popular frameworks like TensorFlow and PyTorch allow developers to create machine learning models, neural networks, and deep learning applications.</p><p>Some examples include:</p><ul><li>Chatbots and virtual assistants</li><li>Image recognition systems</li><li>Language translation tools</li><li>Recommendation engines like Netflix and YouTube</li><li>Predictive analytics for businesses</li></ul><p>With AI continuing to reshape industries, Python has become the go-to language for aspiring AI engineers and data scientists.</p><h3>2. Websites and Web Applications</h3><p>Did you know that Python can power entire websites?</p><p>Using frameworks such as Django and Flask, developers can create everything from simple business websites to massive online platforms.</p><p>Python helps handle:</p><ul><li>User accounts</li><li>Databases</li><li>Authentication systems</li><li>APIs</li><li>Content management systems</li></ul><p>Many startups choose Python because it allows them to build products quickly without sacrificing scalability.</p><h3>3. Game Development</h3><p>While Python may not be the first language that comes to mind for AAA video games, it’s surprisingly capable for game development.</p><p>Libraries like Pygame allow beginners to create:</p><ul><li>Platformers</li><li>Puzzle games</li><li>Retro arcade games</li><li>Educational games</li></ul><p>Many developers even use Python as their first step into game development because they can build projects with relatively little code.</p><p>For aspiring game creators, Python offers a fun and approachable starting point.</p><h3>4. Blockchain and FinTech Applications</h3><p>Blockchain technology isn’t limited to cryptocurrencies.</p><p>Python is widely used for developing blockchain applications because it offers excellent support for cryptography, networking, and complex calculations.</p><p>Developers use Python to create:</p><ul><li>Cryptocurrency tools</li><li>Smart contract prototypes</li><li>Digital payment systems</li><li>Financial analytics platforms</li></ul><p>As digital finance continues to grow, Python remains a valuable skill in the FinTech industry.</p><h3>5. Web Scraping and Automation</h3><p>Imagine automatically collecting information from hundreds of websites. Python excels at automation.</p><p>Using tools like Selenium and Beautiful Soup, developers can:</p><ul><li>Monitor stock prices</li><li>Gather market research</li><li>Track competitor data</li><li>Automate repetitive office tasks</li><li>Generate reports automatically</li></ul><p>Many businesses save hundreds of hours every year by automating manual work with Python scripts.</p><p>For productivity alone, this is one of Python’s most practical applications.</p><h3>6. Data Analysis and Big Data</h3><p>Modern companies generate enormous amounts of data every day.</p><p>Python helps turn that data into useful insights.</p><p>Powerful libraries such as Pandas, NumPy, and SciPy allow developers and analysts to:</p><ul><li>Clean data</li><li>Analyze trends</li><li>Build dashboards</li><li>Generate reports</li><li>Visualize business performance</li></ul><p>Whether you’re working in finance, healthcare, marketing, or sports analytics, Python has become one of the most valuable data skills you can learn.</p><h3>What Python Isn’t Great At</h3><p>Despite its versatility, Python isn’t perfect. Here are a few areas where other languages often perform better:</p><h3>Mobile Apps</h3><p>While Python can be used for mobile development, most professional Android and iOS applications are built using languages like Kotlin, Swift, or Flutter.</p><h3>Desktop Applications</h3><p>Python can create desktop software, but platforms such as C# are generally preferred for Windows applications.</p><h3>High-Performance Systems</h3><p>For applications requiring extreme speed, such as advanced game engines, operating systems, or high-frequency trading systems, languages like C++ and Rust often outperform Python.</p><h3>Famous Products Built with Python</h3><p>One reason Python has become so respected is the number of major companies that rely on it. Some well-known examples include:</p><ul><li>YouTube</li><li>Instagram</li><li>Reddit</li><li>Dropbox</li><li>Anki</li></ul><p>These platforms serve hundreds of millions of users worldwide, proving that Python can scale from small projects to global products.</p><h3>Is Python Worth Learning in 2026?</h3><p>Absolutely. Few skills offer the same combination of accessibility, versatility, and career potential.</p><p>Python allows beginners to start building useful projects quickly while also providing a pathway into some of the highest-paying fields in technology, including:</p><ul><li>Artificial Intelligence</li><li>Machine Learning</li><li>Data Science</li><li>Software Engineering</li><li>Automation</li><li>Cybersecurity</li><li>FinTech</li></ul><p>The best part?</p><p>You don’t need a computer science degree to get started.</p><p>Many successful developers began with simple Python tutorials and gradually built their skills through practice.</p><h3>Final Thoughts</h3><p>Python isn’t just another programming language; it’s the foundation behind many of the technologies shaping our future.</p><p>Whether you want to build AI tools, automate your work, analyze data, create websites, or launch the next big startup, Python provides one of the fastest and most accessible paths into the world of technology.</p><p>The question isn’t whether Python is useful.</p><p>The real question is:</p><p><strong>What will you build with it? Anyway, that&#39;s about it for today! Feel free to follow me for more tech-related posts!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0e28347c0cd0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building an Android App: What I Learned Making a Finance Manager]]></title>
            <link>https://medium.com/@anteprocess/building-an-android-app-what-i-learned-making-a-finance-manager-1d1c82931497?source=rss-1682466f6af5------2</link>
            <guid isPermaLink="false">https://medium.com/p/1d1c82931497</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[android-development]]></category>
            <dc:creator><![CDATA[Michael M.H]]></dc:creator>
            <pubDate>Mon, 22 Dec 2025 14:57:40 GMT</pubDate>
            <atom:updated>2025-12-22T14:59:30.025Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi, this is Mike🤖! So here is a guide to Android development with real-world examples!!</p><p>Anyway, remember when you first thought about building an Android app? Maybe you followed a tutorial, made a “Hello World” app, and then… got stuck? Yeah, me too. So today, I want to share that simple journey with you, the mistakes, the discoveries, and the <strong>oh, THAT’S how it works! </strong>moments with some example codes from my simple Android Finance manager App called <strong>Cost Jot,</strong> made with Kotlin. Let’s dive in!</p><h3>🤖About Cost Jot</h3><p>Cost Jot is a free, open-source finance manager that respects your privacy. No cloud, no tracking. Built with modern Android technologies as a learning project that evolved into a real-world application.</p><p><strong><em>Download: Cost Jot on Google Play</em></strong><br><a href="https://play.google.com/store/apps/details?id=com.anteprocess.costjot">https://play.google.com/store/apps/details?id=com.anteprocess.costjot</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*uSaGg7vSmXuyLZgyE9vvqQ.png" /><figcaption><a href="https://play.google.com/store/apps/details?id=com.anteprocess.costjot">https://play.google.com/store/apps/details?id=com.anteprocess.costjot</a></figcaption></figure><h4>⚙️<strong>The Problem: Why I Built This App?</strong></h4><p>Before we talk about code, let’s talk about WHY. See, I tried a bunch of finance apps, and they all had the same problems:</p><p>• They wanted me to create an account and store my data on their servers<br>• They tracked what I did (for “improving the experience”)<br>• They cost money every month<br>• They needed internet to work (no WiFi? Too bad!)</p><p>I thought: “<strong>Can’t I just… keep my data on my phone?</strong>” Turns out, yes! That’s what <strong>Cost Jot</strong> became: a simple app that works completely offline.</p><p>If you’re new to Android development, this is actually a great type of app to start with because:<br>• You don’t need to build a backend server<br>• You don’t need to learn API calls (yet)<br>• Everything is on the phone, so debugging is easier<br>• You can actually finish it (seriously, scope creep is real)</p><h3>📌Understanding App Architecture (MVVM)</h3><p>Okay, this is where most tutorials lose beginners. They throw around words like “MVVM” and “Clean Architecture” without explaining WHY you’d use them.</p><p>Here’s the simple version: Don’t put everything in one file.</p><p>When I started, I thought “I’ll just put my database code, my UI code, and my logic all in MainActivity.kt, easy!” That works… until you need to change something. Then everything breaks.</p><h4>📌<strong>How I Organized the Code:</strong></h4><p>Think of your app like a restaurant:</p><p>• UI (Screens) = The dining room where customers see the menu<br>• ViewModel = The waiter who takes orders and brings food<br>• UseCase = The chef who actually makes the food<br>• Repository = The pantry where ingredients are stored<br>• Database = The actual shelves in the pantry</p><p>📌<strong>Real example from Cost Jot</strong><br>When someone adds a transaction:<br>1. User fills out the form (AddTransactionScreen.kt)<br>2. Screen tells ViewModel “hey, save this” (TransactionsViewModel.kt)<br>3. ViewModel tells UseCase “process this transaction” (AddTransactionUseCase.kt)<br>4. UseCase tells Repository “put this in the database” (TransactionsRepository.kt)<br>5. Repository talks to Room Database (TransactionDao.kt)</p><p>Here’s the actual UseCase code that executes recurring transactions:</p><pre>class ExecuteRecurringTransactionsUseCase @Inject constructor(<br>    private val recurringTransactionRepository: RecurringTransactionRepository,<br>    private val transactionRepository: TransactionsRepository<br>) {<br>    suspend operator fun invoke(): Result&lt;Int&gt; {<br>        return try {<br>            val activeRecurring = recurringTransactionRepository.getAllActive().first()<br>            val today = LocalDate.now()<br>            var executedCount = 0<br>            <br>            activeRecurring.forEach { recurring -&gt;<br>                if (shouldExecuteToday(recurring, today)) {<br>                    executeRecurringTransaction(recurring)<br>                    executedCount++<br>                }<br>            }<br>            <br>            Result.Success(executedCount)<br>        } catch (e: Exception) {<br>            Result.Error(Exception(&quot;Failed to execute recurring transactions:<br> ${e.message}&quot;))<br>        }<br>    }</pre><p>This separation saved me when I added recurring transactions. I didn’t have to rewrite the UI. I just added a new UseCase and plugged it in.</p><h4>📌<strong>Jetpack Compose: Building the UI</strong></h4><p>If you’re learning Android now, you’ve probably heard: “<strong>Use Jetpack Compose, not XML!</strong>” But what IS Compose?</p><p><strong>Simple answer:</strong> It’s a way to build UI using Kotlin code instead of XML files. It’s like building with LEGO blocks; you stack pieces together. But the Biggest “<strong>Gotcha</strong>” for Beginners is the <strong>State</strong></p><p>Here’s a mistake I made early on that drove me crazy. I had a button that should count clicks. I wrote.</p><pre>var count = 0 // This doesn’t work!<br>Button(onClick = { count++ }) {<br>  Text(“Clicked $count times”)<br>}</pre><p>I’d click the button… nothing happened. Why? Because Compose doesn’t know how to update the screen when the count changes. The fix you gotta tell Compose to watch for changes using StateFlow.</p><pre>private val _selectedCurrency = MutableStateFlow(“USD”)<br>val selectedCurrency = _selectedCurrency</pre><p>The pattern you’ll use everywhere:<br>1. ViewModel holds the data in a StateFlow<br>2. Screen observes it with collectAsState()<br>3. When data changes, screen updates automatically→ Making Lists Fast</p><p>But then, when I added 1000 test transactions, my app became super slow when scrolling. The problem? <strong>I was doing calculations every time the screen scrolled.</strong></p><p><strong>What I learned: Do heavy work in the ViewModel BEFORE showing data, not while scrolling.</strong></p><p><strong>Beginner tip:</strong> Always add key = { item.id } to your LazyColumn items. It helps Compose know which items are which when the list changes. This one optimization made scrolling smooth.</p><h4>🏦Saving Data with Room Database</h4><p>You can’t have a finance app without saving data, right? This is where Room Database comes in.</p><p>Think of Room as a fancy filing cabinet that:<br>• Saves data even when the app closes<br>• Let&#39;s you search through data super fast<br>• Works completely offline → Setting Up Is Easy… Until You Need to Change Things</p><p>Creating your first database table is straightforward. You create a data class, add some annotations, and done!</p><p>Here’s the actual Transaction entity from <strong>Cost Jot</strong>:</p><pre>@Entity(tableName = &quot;transactions_table&quot;)<br>data class TransactionModel(<br>    @PrimaryKey(autoGenerate = true)<br>    @ColumnInfo(name = &quot;id&quot;)<br>    var id: Int = 0,<br>    @ColumnInfo(name = &quot;title&quot;)<br>    var title: String,<br>    @ColumnInfo(name = &quot;amount&quot;)<br>    var amount: Double,<br>    @ColumnInfo(name = &quot;date&quot;)<br>    var date: String,<br>    @ColumnInfo(name = &quot;transactionType&quot;)<br>    var transactionType: String,<br>    @ColumnInfo(name = &quot;category&quot;)<br>    var category:TransactionCategory,<br>    @ColumnInfo(name = &quot;note&quot;)<br>    var note: String?,<br>    @ColumnInfo(name = &quot;accountId&quot;)<br>    var accountId: Int? = null,<br>    ) :Serializable</pre><p>But then… You need to add a new feature. For me, it was recurring transactions. I needed a new table!</p><p>This is called a “<strong>migration</strong>,” and it scared me at first. But here’s the secret: you’re just writing SQL to create the new table.</p><p>📌<strong>Important tip for beginners: </strong>Always increment your database version number when you change the structure, or your app will crash! → Testing Database Changes</p><p>Here’s how I test migrations without breaking users’ data:<br>1. Install the old version of my app on an emulator<br>2. Add some test data<br>3. Install the new version<br>4. Check if the data is still there</p><p>Sounds tedious, but it saved me from SO many crashes.</p><h4>Making Things Happen in the Background</h4><p>Here’s a cool feature: <strong>recurring transactions</strong>. If you pay rent every month, the app should create that transaction automatically, right? Even when the app is closed?</p><p>📍That’s where WorkManager comes in. It runs code in the background, even if:</p><p>• The app is closed<br>• The phone restarts<br>• Your battery is low→ The 15-Minute Rule</p><p>I wanted to check every minute if a recurring transaction was due. But Android said “nope!”</p><p>Minimum check interval: 15 minutes. This is to save battery. You can’t fight it, so work with it. Here’s how I handle debug vs production intervals in MainActivity:</p><pre>companion object {<br>// ⚠️ TESTING MODE: Set to true to run every 15 minutes for testing<br>// ⚠️ Set to false for production (runs every 4 hours)private const val DEBUG_MODE = true<br>private const val DEBUG_INTERVAL = 15L // Minutes<br>private const val PRODUCTION_INTERVAL = 4L // Hours<br>}</pre><h4>The Tricky Part: Using Hilt with WorkManager</h4><p>Hilt is a tool that helps pass data around your app (it’s called “dependency injection”). But getting it to work with WorkManager took me forever to figure out. You need two things:</p><p>📌Thing 1 - Configure AndroidManifest to disable default initialization:</p><pre>&lt;! — Disable default WorkManager initialization →<br>&lt;provider<br>android:name=”androidx.startup.InitializationProvider”<br>android:authorities=”${applicationId}.androidx-startup”<br>android:exported=”false”<br>tools:node=”merge”&gt;<br>  &lt;meta-data<br>  android:name=”androidx.work.WorkManagerInitializer”<br>  android:value=”androidx.startup”<br>  tools:node=”remove” /&gt;<br>&lt;/provider&gt;</pre><p>📌Thing 2 — Set up Application class with custom WorkManager config:</p><pre>@HiltAndroidApp<br>class HouseholdApplication : Application(), Configuration.Provider {<br>    <br>    @Inject<br>    lateinit var workerFactory: HiltWorkerFactory<br>    <br>    override val workManagerConfiguration: Configuration<br>        get() = Configuration.Builder()<br>            .setWorkerFactory(workerFactory)<br>            .build()<br>    <br>.....<br>}</pre><p>Beginner tip: If WorkManager isn’t working, check these two spots first. That’s where my issues usually were.</p><h3><strong>Making Charts Look Good</strong></h3><p>For the reports screen, I wanted pie charts to show spending by category. Sounds simple, but when you have 10+ categories, all the labels overlap, and it looks terrible!</p><p>The Problem: Too much text crammed on the chart.<br>The Solution: Make the chart smarter based on how much data there is.</p><p>Here’s the actual dynamic chart configuration code:</p><pre>@Composable<br>fun ExpensePieChart(expensesByCategory: Map&lt;String, Double&gt;) {<br>    val categoryCount = expensesByCategory.size<br>    <br>    Card(<br>        modifier = Modifier<br>            .fillMaxWidth()<br>            .height(if (categoryCount &gt; 5) 350.dp else 300.dp),<br>        shape = RoundedCornerShape(16.dp)<br>    ) {<br>        AndroidView(<br>            factory = { context -&gt;<br>                PieChart(context).apply {<br>                    description.isEnabled = false<br>                    isDrawHoleEnabled = true<br>                    setHoleColor(android.graphics.Color.WHITE)<br>                    holeRadius = 58f<br>                    transparentCircleRadius = 61f<br>                    setDrawCenterText(true)<br>                    centerText = &quot;Expenses\nBy Category&quot;<br>                    setUsePercentValues(true)<br>                    setEntryLabelColor(android.graphics.Color.BLACK)<br>                    setDrawEntryLabels(false) // Hide slice labels to prevent cramming<br>                    <br>                    // Configure legend<br>                    legend.apply {<br>                        isEnabled = true<br>                        verticalAlignment = com.github.mikephil.charting.components.Legend.LegendVerticalAlignment.BOTTOM<br>                        horizontalAlignment = com.github.mikephil.charting.components.Legend.LegendHorizontalAlignment.CENTER<br>                        orientation = com.github.mikephil.charting.components.Legend.LegendOrientation.HORIZONTAL<br>                        setDrawInside(false)<br>                        xEntrySpace = 7f<br>                        yEntrySpace = 5f<br>                        textSize = if (categoryCount &gt; 6) 9f else 11f<br>                        formSize = if (categoryCount &gt; 6) 8f else 10f<br>                        form = com.github.mikephil.charting.components.Legend.LegendForm.CIRCLE<br>                    }<br>                }<br>            },<br>            update = { pieChart -&gt;<br>                val entries = expensesByCategory.map { (category, amount) -&gt;<br>                    PieEntry(amount.toFloat(), category)<br>                }<br>                <br>                val dataSet = PieDataSet(entries, &quot;&quot;).apply {<br>                  <br>                    // Dynamic text size based on category count<br>                    valueTextSize = when {<br>                        categoryCount &gt; 8 -&gt; 0f // Hide percentages if too many<br>                        categoryCount &gt; 5 -&gt; 10f<br>                        else -&gt; 12f<br>                    }<br>                    valueTextColor = android.graphics.Color.WHITE<br>                    // Only show percentage if &gt;= 5%<br>                    setValueFormatter(object : com.github.mikephil.charting.formatter.ValueFormatter() {<br>                        override fun getFormattedValue(value: Float): String {<br>                            return if (value &gt;= 5f) &quot;${value.toInt()}%&quot; else &quot;&quot;<br>                        }<br>                    })<br>                }<br>                <br>                pieChart.data = PieData(dataSet)<br>                pieChart.invalidate()<br>            },<br>            modifier = Modifier<br>                .fillMaxSize()<br>                .padding(16.dp)<br>        )<br>    }<br>}</pre><p>The chart checks: “<strong>How many categories?</strong>” Then</p><p>• If 5 or less → Show labels on slices<br>• If 6–8 → Smaller text<br>• If more than 8 → Hide percentage labels, show only in legend</p><p>Lesson learned: Always test your UI with LOTS of data, not just 2–3 test items. That’s where things break.</p><p><strong>What “Privacy-First” Really Means</strong></p><p>Everyone talks about privacy, but what does it actually mean in code?</p><p>📍<strong>1. No Internet Permission</strong></p><p>The simplest thing: I didn’t add internet permission to the app. Look in the AndroidManifest — it’s not there.</p><p>This means the app CANNOT connect to the internet, even if it wanted to. No analytics, no tracking, no data leaving the phone.</p><p>📍<strong>2. Users Can Export Everything</strong></p><p>If someone wants to stop using the app, they should be able to take their data with them. That’s why I added export to JSON and CSV.</p><p>Here’s how the export creates a complete JSON backup:</p><pre>    /**<br>     * Generate JSON string for export<br>     */<br>    fun generateExportJson(): String {<br>        val data = _exportData.value ?: return &quot;{}&quot;<br>        <br>        val jsonObject = JSONObject().apply {<br>            put(&quot;appName&quot;, &quot;Household Account&quot;)<br>            put(&quot;version&quot;, &quot;1.0&quot;)<br>            put(&quot;exportDate&quot;, SimpleDateFormat(&quot;yyyy-MM-dd HH:mm:ss&quot;, Locale.getDefault()).format(Date(data.timestamp)))<br>            put(&quot;timestamp&quot;, data.timestamp)<br>            <br>            if (data.transactions.isNotEmpty()) {<br>                put(&quot;transactions&quot;, JSONArray().apply {<br>                    data.transactions.forEach { transaction -&gt;<br>                        put(JSONObject().apply {<br>                            put(&quot;id&quot;, transaction.id)<br>                            put(&quot;title&quot;, transaction.title)<br>                            put(&quot;amount&quot;, transaction.amount)<br>                            put(&quot;date&quot;, transaction.date)<br>                            put(&quot;transactionType&quot;, transaction.transactionType)<br>                            put(&quot;category&quot;, transaction.category.title)<br>                            put(&quot;note&quot;, transaction.note ?: &quot;&quot;)<br>                            put(&quot;accountId&quot;, transaction.accountId ?: 0)<br>                        })<br>                    }<br>                })<br>            }<br>            .... Truncated <br>        }<br>        <br>        return jsonObject.toString(2) // Pretty print with 2-space indentation<br>    }</pre><p>📍<strong>3. Everything Stays on the Phone</strong></p><p>The room database stores everything locally. No servers, no cloud, no “sync”. This makes development easier (no backend!) and users happier (their data is theirs).</p><p>Mistakes I Made in the Past (Learn from Me!)</p><p><strong>Mistake #1: Forgetting to Add Keys</strong></p><p>In Compose, when you show a list, add a key parameter. Without it, your list will be slow.</p><p>Slow: Compose recreates everything</p><pre>items(transactions) { transaction -&gt;<br>    TransactionCard(transaction)<br>    ...<br>    }</pre><p>Fast: Compose reuses items</p><pre>items(transactions, key = { it.id }) { transaction -&gt;<br>  TransactionCard(transaction)<br>  .....<br>  }</pre><p>This one line made scrolling go from janky to smooth for me.</p><p><strong>Mistake #2</strong>: <strong>Doing Math in the UI</strong><br>Don’t calculate stuff while displaying it. Calculate first, then display.</p><p>Bad: Calculating the percentage every time the card shows<br>Good: Calculate in the ViewModel, just show the number</p><p><strong>Mistake #3: Ignoring Screen Rotation</strong></p><p>Rotate your phone while testing! A lot of things break on rotation. Use a ViewModel to keep data alive during rotation.</p><p>Or use rememberSaveable instead of remember for simple states:</p><p><strong>// Lost on rotation</strong></p><pre>var showDialog by remember { mutableStateOf(false) }</pre><p><strong>// Survives rotation</strong></p><pre>var showDialog by rememberSaveable { mutableStateOf(false) }</pre><p>📍<strong>Tools That Helped Me<br>1. Logcat with Filters</strong><br>Instead of reading 10,000 log lines, filter to just what you need:</p><pre>adb logcat -s YourWorkerName:D</pre><p>This shows only logs from your background worker. Saved me hours of searching.</p><p>📍<strong>2. Database Inspector in Android Studio</strong></p><p>You can actually SEE your database while the app runs!<br><em>Tools &gt; App Inspection &gt; Database Inspector</em></p><p>Super helpful for checking if your data is saving correctly.</p><p>📍<strong>3. Compose Preview</strong></p><p>Add <strong>@Preview</strong> above your Composable functions and see them instantly without running the app:</p><pre>@Preview(showBackground = true)<br>@Composable<br>fun MyCardPreview() {<br>    TransactionCard(…)<br>}</pre><p>This made UI development SO much faster.<br>How Fast Is It?</p><p>After finishing, I measured performance on a regular (not expensive) phone:</p><p>• App opens: Less than 1 second<br>• Scrolling 1000 items: Smooth, no lag<br>• Saving a transaction: Instant<br>• Exporting 1000 transactions: About 0.2 seconds</p><p>How I measured: Android Studio has a “Profiler” tool (<em>View &gt; Tool Windows &gt; Profiler</em>). It shows exactly what’s slow in your app.</p><p>If you’re not measuring, you’re guessing!</p><h3>💡<strong>What I’d Do Differently Next Time</strong></h3><p>📍<strong>1. Use Compose from the Start</strong></p><p>I started with XML layouts, then switched to Compose. The switch was painful. If I did it again, I’d go straight to Compose.</p><p>📍<strong>2. Write Tests Earlier</strong></p><p>I added tests after building features. Should’ve written them during development. Testing use cases is actually easy because they’re just Kotlin classes, no Android stuff needed!</p><p>📍<strong>3. Stick to One Design System</strong></p><p>I mixed the Material 2 and Material 3 components at first. It looked inconsistent. Pick one and use it everywhere.</p><p><strong>The Final Result</strong></p><p>After a few months of learning and building, Cost Jot is now on Google Play:<br>• Works 100% offline (no internet needed)<br>• Completely free (no subscriptions)<br>• Multiple accounts and budgets<br>• Recurring transactions that run automatically<br>• Export your data anytime (JSON or CSV)<br>• Clean, modern UI with Material 3</p><h4>Try it yourself: Cost Jot on Google Play</h4><p><a href="https://play.google.com/store/apps/details?id=com.anteprocess.costjot">https://play.google.com/store/apps/details?id=com.anteprocess.costjot</a></p><p>If you’re starting with Android development:</p><p>1. Start simple — Build something you’d actually use<br>2. Structure matters — Use MVVM even for small apps<br>3. State is key — Learn StateFlow and compose states well<br>4. Test with real data — Don’t just use 3 test items<br>5. Measure performance — Use the Profiler tool<br>6. It’s okay to struggle — Everyone does at first!</p><p>🖥️The tech stack I used:</p><p>• Kotlin (programming language)<br>• Jetpack Compose (UI)<br>• Room Database (data storage)<br>• Hilt (dependency injection)<br>• WorkManager (background tasks)<br>• Material 3 (design system)</p><p>All of these are modern, well-supported, and good to learn.</p><p>Okay, so it&#39;s now Your Turn! Pick a problem you have in your daily life. Build an app to solve it. It doesn’t need to be perfect or revolutionary; it just needs to work.</p><p>💡Here are some ideas:</p><p>• Habit tracker<br>• Grocery list<br>• Study timer<br>• Workout log<br>• Book notes</p><p>The best way to learn is to build something real. Anyway, got questions? Want to share what you’re building? Drop a comment below! I’d love to hear from you.</p><p>If this helped you, give it a clap and follow for more beginner-friendly Android development content! I think that&#39;s about it for now! See you later!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1d1c82931497" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Companies Struggle to Embrace AI?]]></title>
            <link>https://medium.com/@anteprocess/why-companies-struggle-to-embrace-ai-604f353a97e7?source=rss-1682466f6af5------2</link>
            <guid isPermaLink="false">https://medium.com/p/604f353a97e7</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[company-culture]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Michael M.H]]></dc:creator>
            <pubDate>Wed, 08 Oct 2025 03:06:50 GMT</pubDate>
            <atom:updated>2025-10-08T03:06:50.767Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GYv7jWYytyBZ_cG-1ZK3cA.png" /></figure><p>🤖 It’s actually surprising, but many companies are still unsure about using AI. Even though Artificial Intelligence is changing the world, a lot of businesses haven’t started using it seriously. Some lose motivation, some stop halfway, and others don’t even begin. Let’s look at why this happens and how companies can move forward with confidence.</p><h3>1. Company leaders don’t really understand AI</h3><p>Many company leaders think AI is just a complicated tech project. They don’t see how it can actually help their business grow. Because of that, projects often never start.</p><p>⚙️<strong>What to do?</strong></p><ul><li>Hold a simple training session for managers that explains what AI can do in plain terms.</li><li>Share real examples of how other companies use AI successfully.</li><li>Choose one small project to test the idea for about three months.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YWFT19OLhPei2Ir2KbrmDQ.png" /></figure><h3>2. It’s hard to see the return on investment</h3><p>When a company spends money on AI, it can be hard to tell right away if it’s worth it. The results take time, and that makes people hesitate.</p><p>⚙️<strong>What to do?</strong></p><ul><li>Start small with one task, like sales forecasting or customer support.</li><li>Set clear goals, such as saving time or reducing mistakes.</li><li>Track the results and show what changed after using AI.</li></ul><h3>3. Worries about security and privacy</h3><p>Data is valuable, and companies want to protect it. Many are afraid that AI systems might leak or misuse sensitive information.</p><p>⚙️<strong>What to do?</strong></p><ul><li>Use trusted platforms that protect company data.</li><li>Hide or remove personal information before using data.</li><li>Keep clear records of how the data is used.</li></ul><h3>4. People are afraid of change</h3><p>AI can change the way people work, and that can be scary. Some employees worry that it might replace them or make their jobs harder.</p><p>⚙️<strong>What to do?</strong></p><ul><li>Talk openly with employees and ask for their thoughts.</li><li>Explain how AI can make their jobs easier, not replace them.</li><li>Show real examples of improvements and celebrate small wins.</li></ul><h3>5. Teams don’t have enough skills</h3><p>Even if leaders are excited about AI, some teams don’t have the right skills to use it. Without proper training, the project can fail.</p><p>⚙️<strong>What to do?</strong></p><ul><li>Offer simple training sessions about AI tools.</li><li>Work with outside experts if needed.</li><li>Use easy, ready-made AI services that don’t require advanced knowledge.</li></ul><h3>🤖 Turn challenges into progress</h3><p>These problems don’t mean a company should give up. They’re just part of the learning process. Start small. Learn from mistakes. Keep improving.<br> When leaders, teams, and tools work together, AI becomes something that helps everyone do their job better. Anyway, that&#39;s about it!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=604f353a97e7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[⚙️Stateful vs Stateless Composables in Jetpack Compose?]]></title>
            <link>https://medium.com/@anteprocess/%EF%B8%8Fstateful-vs-stateless-composables-in-jetpack-compose-95228e4778de?source=rss-1682466f6af5------2</link>
            <guid isPermaLink="false">https://medium.com/p/95228e4778de</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Michael M.H]]></dc:creator>
            <pubDate>Sun, 27 Jul 2025 17:24:50 GMT</pubDate>
            <atom:updated>2025-07-27T17:24:50.668Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/637/1*UIl8idbrVw8n_xfbtZ9yRQ.png" /><figcaption>Android Composables</figcaption></figure><h3>📝Ok, Here Is A Simple Guide for Beginners</h3><p>Hi, it`s Mike, and today I just wanted to write about the basics of composables. mainly about states because I know it used to be one of the concepts that is essential for mobile development. If you’re new to Jetpack Compose, you’ve probably heard about <strong>“stateful”</strong> and <strong>“stateless”</strong> composables, and maybe you’re a bit confused. Don’t worry. I will try to explain the difference in plain English, with <strong>super simple examples</strong> to help you understand and use them like a pro! So let`s do it!</p><h3>In the first place, what’s a “Composable” again?</h3><p>In Jetpack Compose, a <strong>composable</strong> is just a special function that makes UI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*Tj7hMD16L6X4sACCKLQs1w.png" /><figcaption>For example like this</figcaption></figure><p>Nice and easy, right? But what happens when your UI needs to <strong>change</strong>, like when a button is clicked or a switch is toggled? That’s where the <strong>state</strong> comes in.</p><h3>⚙️ Stateful vs. Stateless: What’s the Difference?</h3><p>When we talk about <strong>stateless</strong> composables in Jetpack Compose, we mean functions that <strong>do not manage their state</strong>. In grammar terms, we can say, “A stateless composable <em>does not manage</em> its state.” It relies on <strong>external data</strong> passed into it, usually through parameters. Because it doesn’t remember anything itself, it’s easy to <strong>reuse</strong> stateless composables in different parts of your app. You <em>can reuse</em> them without worrying about how they work inside. Stateless composables are also <strong>good for ViewModel integration</strong>, because the state is controlled from outside, just like a ViewModel should handle it.</p><p>On the other hand, a <strong>stateful</strong> composable <strong>manages its state</strong> using tools like remember mutableStateOf. We say, “A stateful composable <em>manages</em> its state.” This means the composable remembers user actions (like a toggle or counter) by itself. While that makes it <strong>easy to use</strong> in simple cases, it also makes it <strong>harder to reuse</strong>. You <em>cannot reuse</em> stateful composables as flexibly as stateless ones. Also, they are usually <strong>not ideal for ViewModel integration</strong>, because the logic is trapped inside the UI instead of being shared across the app.</p><p>So in short:</p><ul><li>Stateless composables <strong>don’t manage</strong> state; you pass it in.</li><li>Stateful composables <strong>do manage</strong> state; they hold and update it themselves.</li></ul><h3>📝Stateless Composable: Think “Dumb but Reusable”</h3><p>A <strong>stateless composable</strong> doesn’t remember anything. It just shows whatever you give it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*3_w97ga0ylIUJGfHYHnORw.png" /><figcaption>stateless compose</figcaption></figure><p>This composable doesn’t care about what it checked means. Just shows a Switch. Calls onCheckedChange when the user toggles it. <strong>You&#39;ve got to give a state from the outside.</strong></p><h3>📝 Stateful Composable: Think “Smart but Harder to Reuse”</h3><p>A <strong>stateful composable</strong> <strong>remembers things</strong> using remember and mutableStateOf. Btw, don&#39;t forget to import them!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/504/1*EjalJecLc-XL8zCQ6vMgng.png" /><figcaption>stateful compose</figcaption></figure><p>This composable stores its state (isChecked), handles its updates, is easy to use, but <strong>not reusable</strong> if you need to control it from elsewhere</p><h3>📌 Best of Both Worlds ?? Combine Them!</h3><p>Use a <strong>stateless composable</strong> for flexibility and create a <strong>stateful wrapper</strong> for convenience.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/716/1*JPKwElPWXwgxyLyLwqqvhw.png" /></figure><p>Now you can use SimpleSwitch() In other parts of your app, control the state from a ViewModel or parent composable</p><h3>🧪 Real World Analogy</h3><p>Think of it like a <strong>light switch</strong>:</p><ul><li><strong>Stateless</strong>: You control the switch from the wall panel. The switch doesn’t remember anything; it just flips when you tell it to.</li><li><strong>Stateful</strong>: The switch remembers its position. It decides when to turn on/off by itself.</li></ul><p>In the end, understanding the difference between <strong>stateful</strong> and <strong>stateless</strong> composables will make your Jetpack Compose code cleaner, more reusable, and easier to scale. A good rule of thumb: <strong>keep your UI stateless whenever possible</strong>, and <strong>let your ViewModel or parent composable manage the state</strong>. If you’re just prototyping or building something quick and simple, it’s fine to go stateful, just be mindful of when you need more control. Once you get comfortable switching between the two, you’ll write a more flexible and maintainable UI. Start with the mini challenge above and see the difference for yourself. Happy Composing! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=95228e4778de" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ So What’s New In Android Studio Meerkat Feature Drop (2024.3.2)?]]></title>
            <link>https://medium.com/@anteprocess/so-whats-new-in-android-studio-meerkat-feature-drop-2024-3-2-22d8f31ab01d?source=rss-1682466f6af5------2</link>
            <guid isPermaLink="false">https://medium.com/p/22d8f31ab01d</guid>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-development]]></category>
            <dc:creator><![CDATA[Michael M.H]]></dc:creator>
            <pubDate>Mon, 07 Jul 2025 16:31:52 GMT</pubDate>
            <atom:updated>2025-07-07T16:37:11.235Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/532/1*DoXW6Kie2aWdtK5FLZPefg.png" /><figcaption>Android Studio Meerkat</figcaption></figure><h3>🌟 Introduction</h3><p><strong>Finally, in May 2025, Google released a new version of </strong><a href="https://www.google.com/search?q=download+android+studio&amp;oq=Download+android+s&amp;gs_lcrp=EgZjaHJvbWUqBwgAEAAYgAQyBwgAEAAYgAQyBwgBEAAYgAQyBggCEEUYOTIGCAMQABgeMgYIBBAAGB4yBggFEAAYHjIGCAYQABgeMgYIBxAAGB4yBggIEAAYHjIGCAkQABge0gEINDMxMGowajeoAgiwAgHxBZl_RbBZtRlk&amp;sourceid=chrome&amp;ie=UTF-8"><strong>Android Studio, Meerkat Feature Drop (2024.3.2)</strong></a><strong>! </strong><br> And this update was packed with cool tools that help you build better apps, faster, and with way less stress!</p><p><strong><em>So why get excited?</em></strong><em><br> First of all, this update brings Gemini AI, makes Jetpack Compose easier, and helps you share code across Android and iOS. Let`s see what kind of updates have been added in details!</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UdrbsQqIQkzU207t337fDA.png" /></figure><h3>🤖 Gemini AI: Your New Coding Buddy</h3><h3>1. Crash Reports…. Now With AI!</h3><p>When your app crashes, Gemini reads the error and gives you a simple summary, plus tips and docs to fix it. If you simply let Gemini access your code, it even suggests exactly how to solve your issue!</p><p>Before this update, if your app crashed in the real world, you had to bounce back and forth between tools like <strong>Firebase Crashlytics</strong> or <strong>Android Vitals</strong> and your coding environment (IDE) to figure out what happened. Now, with the new version, you just click the <strong>Insights</strong> tab in the IDE and instantly see the <strong>App Quality Insights (AQI)</strong> report… so no more endless switching!</p><p>If you let Gemini see your local code, it can even give you tailor-made advice! All of this means you spend less time finding and fixing problems and more time building cool stuff.</p><h3>2. Auto-Generated Unit Tests</h3><p>You can right-click any class, choose <strong>Gemini &gt; Generate Unit Test Scenarios</strong>, and Gemini writes suggested test cases for you.<br> No more staring at empty test folders! Everything is just too easy!</p><h3>3. Gemini Prompt Library</h3><p>You can save your favorite AI prompts and reuse them anytime, in your project or the whole IDE. It`s great for teamwork with AI!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*kP7ezxMIBeiqTUHHJDB6gw.png" /></figure><h3>🎨 UI &amp; Jetpack Compose Upgrades</h3><h3>4. Themed Icon Previews</h3><p>You can now see how your app icons look in different Android themes (like Android 13+), right in Android Studio. Also, check for weird colors or broken designs <em>before</em> you ship!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*iwdrYHFjxf-nXYk-NNyIiA.png" /></figure><h3>5. Better Compose Previews</h3><ul><li>Smoother zoom</li><li>Collapse/expand preview groups</li><li>Grid view for easy browsing</li><li>Quick switch to the gallery view</li></ul><p>Designing screens just got way less painful!</p><h3>🔨 Build &amp; Project Improvements</h3><h3>6. Kotlin Multiplatform (KMP) Templates</h3><p>You can now easily build shared modules in <strong>Kotlin Multiplatform</strong> right from Android Studio! This means you can write business logic once and use it on both Android and iOS. No more juggling different codes for different platforms, the build menu is also cleaner and easier to use.</p><h3>7. Better Device Manager</h3><p>Find and add virtual or real devices faster with new filters and recommended settings. Setting up testing devices is now much easier. Just click the <strong>[+]</strong> button at the top of the Device Manager window, and you can quickly make a virtual device or add a remote device with a couple of clicks. No more confusing menus!</p><h3>8. SDK Deprecation Warnings</h3><p>If you’re using any outdated or unsafe SDKs (libraries) that Google Play no longer recommends, Android Studio will warn you. This helps you avoid hidden problems from old or risky libraries and keeps your apps safe and up-to-date!</p><h3>9. Cleaner Build Menu</h3><p>The build menu is now simpler and easier to understand.<br> For example, “Rebuild Project” is now “Clean and Assemble Project with Tests” — so you know exactly what’s happening!</p><p>Here’s a simple, beginner-friendly English translation for your blog (with a bit of fun):</p><h3>⚡️ Powered by IntelliJ 2024.1</h3><p>Meerkat is built on the latest IntelliJ, which means</p><ul><li><strong>Faster code suggestions (Kotlin K2 support)</strong></li><li><strong>Better terminal &amp; debugger</strong></li><li><strong>All-around snappier performance!</strong></li></ul><h3>📝 Summary</h3><p><strong>Android Studio Meerkat Feature Drop</strong> is a must-have for anyone using Jetpack Compose, Kotlin Multiplatform, or just wanting smarter, faster development. Gemini AI makes life easier so you can focus on building awesome stuff, not just fixing bugs. Anyway, that`s about it for today!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=22d8f31ab01d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Python MySQL Database Setup for Local and Lolipop Servers]]></title>
            <link>https://medium.com/@anteprocess/python-mysql-database-setup-for-local-and-lolipop-servers-2b3938de7153?source=rss-1682466f6af5------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b3938de7153</guid>
            <category><![CDATA[database]]></category>
            <category><![CDATA[servers]]></category>
            <category><![CDATA[python3]]></category>
            <category><![CDATA[python-programming]]></category>
            <dc:creator><![CDATA[Michael M.H]]></dc:creator>
            <pubDate>Tue, 06 May 2025 17:49:40 GMT</pubDate>
            <atom:updated>2025-05-06T17:49:40.916Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi! This is Michael, and today, I just wanted to share a little tip about setup for local and production versions. For example, if you’re developing a Python project on your own PC (local environment) and want to upload it to a <strong>Lolipop shared hosting server (In my case, I live in Japan and use this cheap ass server to run my hobby website)</strong>, you’ll need to handle two separate database configurations: one for local use, and one for production (on Lolipop).</p><p>Here’s how to do it <strong>safely and automatically</strong>.</p><h3>✅ Step 1: Structure Your database.py</h3><p>This script detects the environment and switches between your <strong>local MySQL</strong> and the <strong>Lolipop MySQL server</strong> automatically.</p><pre># database.py</pre><pre>import mysql.connector<br>from mysql.connector import Error<br>import socket<br>import platform<br>import os</pre><pre>def is_lolipop_server():<br>    &quot;&quot;&quot;Detect if running on Lolipop shared hosting.&quot;&quot;&quot;<br>    try:<br>        hostname = socket.gethostname().lower()<br>        fqdn = socket.getfqdn()<br>        return (<br>            &#39;lolipop&#39; in hostname or<br>            &#39;.lolipop.jp&#39; in fqdn or<br>            &#39;phy.lolipop.lan&#39; in fqdn<br>        )<br>    except:<br>        return False</pre><pre>def create_connection():<br>    &quot;&quot;&quot;Create and return a MySQL database connection.&quot;&quot;&quot;<br>    try:<br>        if is_lolipop_server():<br>            print(&quot;🟢 Connecting to Lolipop production database...&quot;)<br>            connection = mysql.connector.connect(<br>                host=&#39;your-lolipop-db-host&#39;,          # e.g. mysql000.phy.lolipop.lan<br>                database=&#39;your-production-db-name&#39;,<br>                user=&#39;your-lolipop-username&#39;,<br>                password=&#39;your-production-password&#39;,<br>                port=3306<br>            )<br>        else:<br>            print(&quot;🟡 Connecting to local development database...&quot;)<br>            connection = mysql.connector.connect(<br>                host=&#39;localhost&#39;,<br>                database=&#39;your-local-db-name&#39;,<br>                user=&#39;root&#39;,<br>                password=&#39;&#39;,<br>                port=3306<br>            )</pre><pre>        if connection.is_connected():<br>            print(&quot;✅ Database connection successful!&quot;)<br>            return connection<br>    except Error as e:<br>        print(f&quot;❌ Error: {e}&quot;)<br>        return None</pre><pre>def close_connection(connection):<br>    if connection and connection.is_connected():<br>        connection.close()<br>        print(&quot;🔒 Connection closed.&quot;)</pre><h3>🔐 Step 2: Keep Credentials Out of Your Code (Optional but Recommended)</h3><p>Use .env files and <a href="https://pypi.org/project/python-dotenv/">python-dotenv</a> to avoid writing passwords directly in code.</p><p>Install it:</p><pre>pip install python-dotenv</pre><p>Then modify database.py:</p><pre>from dotenv import load_dotenv<br>load_dotenv()</pre><pre>user = os.getenv(&quot;DB_USER&quot;)<br>password = os.getenv(&quot;DB_PASS&quot;)</pre><p>Create a .env (not uploaded to GitHub!):</p><pre>DB_USER=yourname<br>DB_PASS=yourpassword</pre><h3>📤 Step 3: Upload to Lolipop Server</h3><ol><li><strong>Connect via SSH</strong> or use the Lolipop file manager.</li><li>Upload your project to /home/users/0/your-account/web/your-domain.com/</li><li>Use pip install --user to install modules locally (Lolipop shared hosting doesn’t allow global pip installs).</li><li>Use python3 script.py to test from the server.</li></ol><h3>💡 Tips</h3><ul><li>Lolipop uses mysqlXXX.phy.lolipop.lan as a host.</li><li>Check your DB credentials in the Lolipop Control Panel under “データベース”.</li><li>Make sure your local and production MySQL schemas are compatible.</li></ul><h3>✅ Result</h3><p>You now have a Python project that:</p><ul><li>Connects to <strong>local MySQL</strong> on your PC</li><li>Automatically switches to <strong>Lolipop’s MySQL</strong> on deployment</li><li>Avoids hardcoding secrets when using .env files</li></ul><p>So I think that&#39;s about it! I don`t even know if it was worth writing it down. But at least it will be great to test it out!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b3938de7153" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying Laravel 10 on Lolipop Server: A Simple Step-by-Step Guide]]></title>
            <link>https://medium.com/@anteprocess/deploying-laravel-10-on-lolipop-server-a-simple-step-by-step-guide-005fe1d6c6e2?source=rss-1682466f6af5------2</link>
            <guid isPermaLink="false">https://medium.com/p/005fe1d6c6e2</guid>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[webhosting-service]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[laravel-framework]]></category>
            <dc:creator><![CDATA[Michael M.H]]></dc:creator>
            <pubDate>Tue, 03 Dec 2024 05:05:17 GMT</pubDate>
            <atom:updated>2024-12-03T05:05:17.760Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/493/1*YfZOeXu_PgvquT6u1NwSpQ.png" /><figcaption>Lolipop is one of my favorite Japanese website hosting company</figcaption></figure><p>HI! 👋This is Mike and today, I just wanted to jot down about <strong>Deploying a Laravel 10 application on a Lolipop server</strong>💻. This post is more intended as my memo, but I think it might be helpful to those who want to use the Lolipop server! Well, it might seem challenging, but this guide will simplify the process for you. Let’s walk through each step to get your Laravel project live on Lolipop.</p><h3>📠Step 1: Connect to the Lolipop Server Using SSH</h3><p>First, you’ll need to connect to your Lolipop server via SSH. However, you might encounter an error like this:⛓️‍💥</p><pre>$ ssh sub.jp-***@ssh.lolipop.jp -p 2222  </pre><pre>Unable to negotiate with ***.***.***.*** port 2222: no matching host key type found. Their offer: ssh-rsa,ssh-dss</pre><p>This happens because Lolipop uses an older encryption method that modern SSH clients no longer support. You can resolve this by running the following command:</p><pre>$ ssh -oHostKeyAlgorithms=+ssh-dss sub.jp-***@ssh.lolipop.jp -p 2222</pre><h3>🔧Step 2: Update PHP to Version 8.1</h3><p>Laravel 10 requires PHP 8.1, so update your server’s PHP version. Open or create a .bash_profile file on the server and add the following lines:</p><pre>PATH=/usr/local/php/8.1/bin:$PATH  <br>export PATH</pre><p>Apply the changes by running:</p><pre>$ source ~/.bash_profile</pre><h3>💽Step 3: Clone Your Project from GitHub</h3><p>Next, pull your Laravel project from GitHub. Run the following command:</p><pre>$ git clone git@github.com:your-username/your-project.git</pre><p>Navigate into your project directory:</p><pre>$ cd your-project</pre><h3>📌Step 4: Install Dependencies</h3><p>Laravel requires a vendor directory, which you can create by running:</p><pre>$ composer install</pre><h3>📌Step 5: Set Permissions</h3><p>Ensure the correct permissions are set for the storage and bootstrap/cache directories:</p><pre>$ chmod -R 777 storage  <br>$ chmod -R 775 bootstrap/cache</pre><h3>📌Step 6: Update the .env File</h3><p>Edit the .env file in your project directory to match your Lolipop server’s configuration. Example:</p><pre>APP_NAME=project-name  <br>APP_ENV=production  <br>APP_KEY=  <br>APP_DEBUG=false  <br>APP_URL=https://yourdomain.com  <br><br>DB_CONNECTION=mysql  <br>DB_HOST=mysql***.phy.lolipop.lan  <br>DB_PORT=3306  <br>DB_DATABASE=LAA*******-***  <br>DB_USERNAME=LAA*******  <br>DB_PASSWORD=**********</pre><h3>📌Step 7: Generate the Application Key and Set Up the Database</h3><p>Run the following commands to generate your app key and migrate the database:</p><pre>$ php artisan key:generate  <br>$ php artisan migrate</pre><h3>📌Step 8: Set the Public Directory as the Root Folder</h3><p>Finally, log in to the Lolipop admin panel and set the public folder of your project as the root folder for your application. This ensures that Laravel’s front-facing files are served correctly.</p><h3>That’s It!</h3><p>Your Laravel 10 application should now be successfully deployed on the Lolipop server. If you encounter any issues, double-check each step and ensure your server configuration matches Laravel’s requirements.</p><p>Happy coding! 🌟</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=005fe1d6c6e2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android: NavBackStackEntry’s Lifecycle in Jetpack Compose Navigation ]]></title>
            <link>https://medium.com/@anteprocess/android-navbackstackentrys-lifecycle-in-jetpack-compose-navigation-d596fcc29fc4?source=rss-1682466f6af5------2</link>
            <guid isPermaLink="false">https://medium.com/p/d596fcc29fc4</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[jetpack-compose-tutorial]]></category>
            <category><![CDATA[androiddev]]></category>
            <dc:creator><![CDATA[Michael M.H]]></dc:creator>
            <pubDate>Tue, 05 Nov 2024 03:47:19 GMT</pubDate>
            <atom:updated>2024-11-05T03:47:19.767Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*-nAv3IVQISYmqNSK9Y0KRw.png" /><figcaption>What is NavBackStackEntry’s Lifecycle in Compose Navigation?</figcaption></figure><h4>⚙️Introduction</h4><p>Hi! 👋This is Mike and today, I wanted to share about a concept that I learned a while ago. It`s <strong>NavBackStackEntry! </strong>As you know<strong>, </strong>Jetpack Compose has been rapidly evolving, introducing unique ways to manage UI in Android apps. With the Compose Navigation component, we can switch between screens seamlessly and gain access to each screen’s lifecycle state through <strong>NavBackStackEntry</strong>. If you’ve been working with scenarios like managing video playback, animations, or any other feature that depends on the page’s lifecycle, the <strong>NavBackStackEntry</strong> lifecycle can be a powerful tool. But you might be wondering….. <strong>What is NavBackStackEntry?</strong></p><h4>🔍 So what is NavBackStackEntry?</h4><p>In Compose’s Navigation component, each screen or destination is represented by a <strong>NavBackStackEntry</strong>. This object carries useful information about the current state of the screen, including arguments, saved state, and its lifecycle. You can think of it as a lightweight object that tracks each screen in the navigation stack.</p><h4>📌Why Does the Lifecycle of NavBackStackEntry Matter?</h4><p>Consider a scenario where you’re playing a video on a Compose screen. You’ll want the video to pause when the screen goes out of focus or stop when the user navigates away. Before Compose, managing these lifecycle events would require careful handling of <strong>Fragment</strong> or <strong>Activity</strong> lifecycle states. With Compose’s <strong>NavBackStackEntry</strong> lifecycle, each screen’s lifecycle can be handled more intuitively, enabling you to respond to lifecycle events for each navigation destination without complex workarounds.</p><h4>🛠️Setting Up NavBackStackEntry’s Lifecycle</h4><p>Let’s just see a sample of how the lifecycle works and how you can use it in your Compose navigation setup. First, each <strong>NavBackStackEntry</strong> has a private <strong>LifecycleRegistry</strong> to track its lifecycle state:</p><pre><br>private var lifecycle = LifecycleRegistry(this)<br>public override fun getLifecycle(): Lifecycle {<br> return lifecycle<br>}</pre><p>The lifecycle state is then updated based on two main properties:<br>1. <strong>hostLifecycleState</strong>: This represents the lifecycle state of the hosting component, typically the <strong>Activity</strong> or <strong>Fragment</strong> that manages Compose’s navigation.<br>2. <strong>maxLifecycle</strong>: This is the maximum lifecycle state for each destination or screen.</p><h4>🕹️Controlling the Lifecycle State with <strong>updateState()</strong></h4><p>The `updateState()` function determines the current lifecycle of the `NavBackStackEntry` by comparing `hostLifecycleState` and `maxLifecycle`, using the minimum of the two. Here’s how it works:</p><pre><br>public fun updateState() {<br> lifecycle.currentState = if (hostLifecycleState.ordinal &lt; maxLifecycle.ordinal) {<br>     hostLifecycleState<br> } else {<br>     maxLifecycle<br> }<br>}</pre><p>This ensures that the lifecycle state of each screen aligns with the hosting component and respects the navigation logic for each screen.</p><h4>🔗Lifecycle State Management: Practical Use Cases</h4><p><strong>1. Managing Video Playback</strong><br>Let’s say you’re displaying a video on one of the Compose screens. When a user leaves the screen, you’ll want to pause the video automatically. Thanks to the <strong>NavBackStackEntry</strong> lifecycle, you can monitor when the screen goes from `<strong>RESUMED</strong>` to `<strong>STOPPED</strong>` and pause the video accordingly.</p><p><strong>2. Reducing Resource Usage with Lifecycle-Aware UI Components<br></strong>Many applications include UI components that consume resources, like network connections, timers, and animations. The `NavBackStackEntry` lifecycle can help you manage these components more efficiently by starting them only when the screen is active and pausing them when the screen goes to the background.</p><p><strong>3. Saving User Data on Navigation<br></strong>Another common use case is saving unsaved data when the user navigates away. For instance, if you’re implementing a form or text input, you can use the <strong>onStop</strong> or <strong>onDestroy</strong> lifecycle events to trigger a save function when the user leaves the screen, even if they didn’t explicitly press a save button.</p><p><strong>Understanding Lifecycle Ordinals<br></strong>The <strong>State</strong> enum manages the lifecycle levels. Here’s what they look like:</p><pre><br>public enum State {<br> DESTROYED,<br> INITIALIZED,<br> CREATED,<br> STARTED,<br> RESUMED;<br>}</pre><p>With <strong>DESTROYED</strong> as the minimum and <strong>RESUMED</strong> as the maximum, the lifecycle state is determined by whichever <strong>hostLifecycleState </strong>or <strong>maxLifecycle</strong> is at the lower ordinal (or lifecycle level). This essentially means that the screen lifecycle respects both the host component and its lifecycle constraints.</p><h4>Example: Applying Lifecycle in Compose</h4><p>Imagine you have a navigation setup where you want to manage video playback on one of the screens. In your composable, you can observe <strong>NavBackStackEntry</strong>’s lifecycle and use it to control playback. Here’s a small code snippet that demonstrates how this might work:</p><pre><br>@Composable<br>fun VideoScreen(backStackEntry: NavBackStackEntry) {<br> val lifecycle = backStackEntry.lifecycle<br> val lifecycleOwner = LifecycleOwner { lifecycle }DisposableEffect(lifecycleOwner) {<br> val observer = LifecycleEventObserver { _, event -&gt;<br> <br>if (event == Lifecycle.Event.ON_PAUSE) {<br>   // Pause video playback<br> } else if (event == Lifecycle.Event.ON_RESUME) {<br>   // Resume video playback<br>}<br>}<br>lifecycle.addObserver(observer)<br>  onDispose {<br>     lifecycle.removeObserver(observer)<br>  }<br>}<br>}</pre><p>This code leverages <strong>LifecycleEventObserver</strong> to listen for lifecycle changes, allowing you to respond to lifecycle events and manage video playback smoothly.</p><h4>Conclusion</h4><p>The lifecycle in <strong>NavBackStackEntry </strong>is a subtle but powerful tool within Jetpack Compose Navigation. By allowing each navigation destination to respect both its own and the host’s lifecycle states, you can more efficiently manage UI components like video playback, animations, and data handling. The ability to have these controls at the <strong>NavBackStackEntry</strong> level lets you bring in better performance, resource management, and user experience to your Compose-based Android apps.</p><p>From pausing videos when leaving a screen to optimizing resource-heavy components, understanding how to utilize <strong>NavBackStackEntry</strong>’s lifecycle is essential for developing modern, responsive applications with Jetpack Compose. Anyway, that is about it! Thank you for reading and feel free to follow me for more tips and tricks!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d596fcc29fc4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android Keystore simplified!]]></title>
            <link>https://medium.com/@anteprocess/android-keystore-simplified-3b7b4a0e42a6?source=rss-1682466f6af5------2</link>
            <guid isPermaLink="false">https://medium.com/p/3b7b4a0e42a6</guid>
            <category><![CDATA[android-development]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Michael M.H]]></dc:creator>
            <pubDate>Sun, 22 Sep 2024 02:10:26 GMT</pubDate>
            <atom:updated>2024-09-22T02:13:22.696Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/547/1*1F2CAMcSaxmuRHcoyfEMbw.png" /></figure><h4>🔐The Importance of Security in App Development</h4><p><strong>Hi, </strong>there, it’s Mike the dev! I wanted to take a moment to talk about security, especially when it comes to Android development. As you know, security is more important than ever in today’s app development world. One of Android’s key security features is the **Android Keystore system** — you’ve probably heard of it. While the official Android developer docs cover it in detail, I noticed some sections can be a bit tricky, so I thought I’d break it down in a simpler way.</p><h4>🔎So What is Android Keystore?</h4><p>In short, the Android Keystore is a system that stores encryption keys securely inside your Android device. If you leave encryption keys directly in your app, they could be easily exposed, especially on rooted devices. So, if your app needs to securely store data on the device, consider using Android Keystore.</p><h4>🔐Key Features of Android Keystore:</h4><p>- Encryption keys are stored in a secure part of the device, making them hard to extract.<br>- You can control which encryption modes the keys can be used for.<br>- You can require user authentication before using the keys.</p><h4>🔐How Does Android Keystore Protect Your Encryption Keys?</h4><p>1. Only system processes that handle encryption can access the key material (the data used to generate the encryption key).<br>2. App processes cannot access the key material directly.<br>3. Key material can be tied to the device’s secure hardware, like <strong>Trusted Execution Environment (TEE)</strong> or <strong>Secure Element (SE)</strong>.</p><h4>🛠️Creating Encryption Keys with Android Keystore</h4><p><em>Here’s an example of generating an encryption key using the Android</em> Keystore <em>system with the </em><strong><em>RSA algorithm</em></strong>. For more details on developing other types of keys or setting encryption modes, refer to the <a href="https://developer.android.com/privacy-and-security/keystore?hl=en">official Android documentation</a>. Anyway, let`s take a look step by step. This time, I will leave the comments in the code for better understanding.</p><h4>📦Getting the Keystore Instance:</h4><pre>// Get an instance of the Android Keystore<br>val keyStore: KeyStore = KeyStore.getInstance(“AndroidKeyStore”)<br>// Load the keystore (necessary to initialize the Android Keystore instance)<br>keyStore.load(null)</pre><h4>⚙️Generating a Key Pair:</h4><pre><br>// Get an instance of KeyPairGenerator to create a key pair<br>val kpg: KeyPairGenerator = KeyPairGenerator.getInstance(<br> KeyProperties.KEY_ALGORITHM_RSA,<br> “AndroidKeyStore”<br>)<br><br>// Specify the key’s parameters, like its purpose (e.g., signing) and allowed algorithms<br>val parameterSpec: KeyGenParameterSpec = KeyGenParameterSpec.Builder(<br> “alias_name”, // Alias used to retrieve the key from the Keystore<br> KeyProperties.PURPOSE_SIGN // Purpose: this key can only be used for signing<br>).run {<br> setDigests(KeyProperties.DIGEST_SHA256) // Only allow SHA-256 for signing<br> setSignaturePaddings(KeyProperties.SIGNATURE_PADDING_RSA_PKCS1) // Padding mode<br> build()<br>}</pre><pre>// Initialize the KeyPairGenerator with the parameters<br>kpg.initialize(parameterSpec)<br>// Generate the key pair<br>val kp = kpg.generateKeyPair()</pre><h4>🖌️Signing Data:</h4><pre>// Data to be signed<br>val data = “sign this data”.toByteArray(StandardCharsets.UTF_8)</pre><pre>// Load the keystore and get the key entry using the alias<br>val keyStore = KeyStore.getInstance(“AndroidKeyStore”).apply {<br> load(null)<br>}<br>val entry = keyStore.getEntry(“alias_name”, null) as KeyStore.PrivateKeyEntry</pre><pre>// Get a Signature instance for signing using SHA-256 with RSA<br>val signature = Signature.getInstance(“SHA256withRSA”)<br>// Initialize the Signature instance with the private key<br>signature.initSign(entry.privateKey)<br>// Sign the data<br>signature.update(data)<br>val signedData = signature.sign()</pre><pre>// Encode the signed data as Base64 for easy storage or transmission<br>val result = Base64.encodeToString(signedData, Base64.DEFAULT)</pre><h4>🔎Final Thoughts</h4><p>Using Android Keystore to generate encryption keys can feel a bit complex at first, but it’s a powerful tool to securely handle sensitive data on Android devices. There’s a lot more to explore, especially around <strong>Trusted Execution Environment (TEE)</strong> and <strong>Secure Element (SE)</strong>, but we’ll leave it here for now! See you in the next Post!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3b7b4a0e42a6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Basics of Laravel by making a CRUD for beginners Part 1]]></title>
            <link>https://medium.com/@anteprocess/basics-of-laravel-by-making-a-crud-for-beginners-part-1-a8729606eebd?source=rss-1682466f6af5------2</link>
            <guid isPermaLink="false">https://medium.com/p/a8729606eebd</guid>
            <category><![CDATA[laravel-development]]></category>
            <category><![CDATA[laravel-framework]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[php-developers]]></category>
            <dc:creator><![CDATA[Michael M.H]]></dc:creator>
            <pubDate>Tue, 16 Jul 2024 03:39:17 GMT</pubDate>
            <atom:updated>2024-07-16T03:46:00.498Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/824/1*CDJHHxsbJL7C-VO58jlZpg.png" /></figure><p>Hi! 👋This is Michael, and today we’re going into something different. Instead of Node or Android development, we’ll be exploring Laravel— One of the most powerful PHP frameworks out there! I know some of you might have mixed feelings about it, but I find Laravel incredibly useful for building robust, high-quality projects. In this article, I’ve packed in all the essential information you need to supercharge your Laravel projects!</p><h3>📜<strong>Simplified tutorial</strong></h3><p>I will try to summarize how to use Laravel in a step-by-step simple format. So, we’ll be implementing CRUD operations (Create, Read, Update, Delete) while explaining each step.</p><p>⚙️<strong>Starting by installing Laravel</strong></p><p>There are various ways to install Laravel, but we will use Composer here.</p><p>By using the `<strong>create-project</strong>` command, you can install Laravel and create a project at the same time.</p><pre><br>% composer create-project laravel/laravel my-sample</pre><p>A directory named `sample` will be created, so navigate to this directory.</p><pre><br>% cd my-sample</pre><p>From here on, we’ll work within the `sample` directory.</p><p>📌<strong>Laravel Project Directory Structure</strong></p><p>When you create a Laravel project, the following directory structure is set up:</p><pre><br>─── sample<br> ├── app # Application logic<br> ├── bootstrap # Laravel framework startup code<br> ├── config # Configuration files<br> ├── database # DB-related files like Migration files<br> ├── public # Document root for the web server<br> ├── resources # View files and language translation files<br> ├── routes # Routing files<br> ├── storage # Files used by the framework<br> ├── tests # Test code<br> └── vendor # Libraries installed via Composer</pre><p>The structure may vary depending on the Laravel version.</p><p>You will build your web application according to this structure. Before we start, let’s briefly introduce some important files.</p><p><strong>.env File</strong></p><p>At the root of the &#39;<strong>my-sample</strong>` directory, there is a file named `<strong>.env</strong>`. This file is used to write the environment configuration information for your application. Specifically, it contains the encryption key, database connection information, and more.</p><p>But remember to be careful when using public repositories like GitHub to avoid exposing sensitive information.</p><p>📌<strong>Artisan File</strong></p><p>In the root of the `sample` directory, there’s a file named `artisan`. The artisan file is the executable for Laravel’s command-line tool, Artisan. In Laravel, you use Artisan commands to perform various operations. Here are some of the main ones:</p><p>📌<strong>Serve Command</strong></p><p>This command runs your Laravel project using PHP’s built-in server.</p><pre>% php artisan serve — host=localhost — port=8000</pre><p>Laravel development server started: &lt;<a href="http://localhost:8000/">http://localhost:8000</a>&gt; <br>The ` — host` and ` — port` options can be omitted.</p><p>📌<strong>Route List Command</strong></p><p>This command displays a list of all routing definitions.</p><pre><br>% php artisan route:list<br></pre><pre><br>+ — — — — + — — — — — + — — — — — + — — — + — — — — -+ — — — — — — — +<br>| Domain | Method | URI | Name | Action | Middleware |<br>+ — — — — + — — — — — + — — — — — + — — — + — — — — -+ — — — — — — — +<br>| | GET|HEAD | / | | Closure | web |<br>| | GET|HEAD | api/user | | Closure | api,auth:api |<br>+ — — — — + — — — — — + — — — — — + — — — + — — — — -+ — — — — — — — +<br></pre><p>For example, the first line indicates that a GET request is accepted at the root (`<a href="http://localhost:8000`">http://localhost:8000`</a>). We’ll look into this in more detail as we go along.</p><p>📌<strong>Database Configuration</strong></p><p>After creating a Laravel project, the first thing you need to do is set up the database. Initially, you will need to perform the following tasks:</p><blockquote>- Connection settings<br>- Migration<br>- Model creation<br>- Seeding</blockquote><p>📌<strong>Connection Settings</strong></p><p>The database connection information is written in the `<strong>.env</strong>` file. The default values are as follows. Configure them according to your environment.</p><pre><br>DB_CONNECTION=mysql<br>DB_HOST=127.0.0.1<br>DB_PORT=3306<br>DB_DATABASE=test<br>DB_USERNAME=me<br>DB_PASSWORD=secret</pre><p>In this example, you need to install MySQL locally, create a database named `<strong>test</strong>`, and create a user named `<strong>me</strong>` with the password `<strong>secret</strong>`.</p><h3>🔌<strong>Migration</strong></h3><p>Migration is a system that manages the creation and modification of tables using PHP source code instead of SQL. Follow these steps to perform migrations:</p><p>1. Create a migration file<br>2. Run the migration</p><p><strong>1. Creating a Migration File</strong></p><p>To create a migration file, use Artisan’s `<strong>make:migration</strong>` command. You can name the file anything you like, but it’s good practice to choose a name that indicates what operation the migration performs. Let’s create a migration file for a Books table.</p><pre><br>php artisan make:migration create_books_table<br></pre><p>This command generates a migration file in the `database/migrations` directory with a timestamp in its filename. You can then edit this file to define the structure of the Books table. The migration file will be created in the `database/migrations` directory.</p><pre>% php artisan make:migration create_books_table — create=books</pre><p>In the migration file, you write the information for creating the table in the up method and the information for rolling back the migration in the down method. The current content creates a Books table with an ID column and timestamps, and deletes the Books table when rolled back.</p><p>📍 Let’s say you want to create a table with the following structure:</p><pre>| Column | Type | Constraints |<br>| — — — — — — | — — — — — — — -| — — — — — — — — -|<br>| id | AUTO_INCREMENT| PRIMARY KEY |<br>| name | VARCHAR(50) | NOT NULL |<br>| price | INT | NOT NULL |<br>| author | VARCHAR(50) | |<br>| created_at | timestamp | |<br>| updated_at | timestamp | |</pre><p>In this case, you would modify the `up` method as follows:</p><pre><br>use Illuminate\Database\Migrations\Migration;<br>use Illuminate\Database\Schema\Blueprint;<br>use Illuminate\Support\Facades\Schema;<br><br>class CreateBooksTable extends Migration<br>{<br> /**<br> * Run the migrations.<br> *<br> * @return void<br> */<br> public function up()<br> {<br> Schema::create(‘books’, function (Blueprint $table) {<br> $table-&gt;id(); // AUTO_INCREMENT PRIMARY KEY<br> $table-&gt;string(‘name’, 50)-&gt;nullable(false); // VARCHAR(50) NOT NULL<br> $table-&gt;integer(‘price’)-&gt;nullable(false); // INT NOT NULL<br> $table-&gt;string(‘author’, 50)-&gt;nullable(); // VARCHAR(50)<br> $table-&gt;timestamps(); // created_at and updated_at timestamps<br> });<br> }<br><br>/**<br> * Reverse the migrations.<br> *<br> * @return void<br> */<br> public function down()<br> {<br> Schema::dropIfExists(‘books’);<br> }<br>}<br></pre><p>With this structure 📍: <br>- The `<strong>id</strong>` column is an auto-incrementing primary key.<br>- The `<strong>name</strong>` column is a string with a maximum length of 50 characters and cannot be null.<br>- The `<strong>price</strong>` column is an integer and cannot be null.<br>- The `<strong>author</strong>` column is a string with a maximum length of 50 characters and can be null.<br>- The `<strong>created_at</strong>` and `<strong>updated_at</strong>` columns are timestamps.</p><p>🔍<strong>Running Migrations</strong></p><p>To run migrations, use the Artisan migrate command.</p><pre>% php artisan migrate</pre><p>Let’s check if the `books` table has been created as specified.</p><p><strong>MySQL:</strong></p><pre><br>mysql&gt; desc books;<br>+ — — — — — — + — — — — — — — — — + — — — + — — -+ — — — — -+ — — — — — — — — +<br>| Field | Type | Null | Key | Default | Extra |<br>+ — — — — — — + — — — — — — — — — + — — — + — — -+ — — — — -+ — — — — — — — — +<br>| id | int(10) unsigned | NO | PRI | NULL | auto_increment |<br>| name | varchar(50) | NO | | NULL | |<br>| price | int(11) | NO | | NULL | |<br>| author | varchar(50) | YES | | NULL | |<br>| created_at | timestamp | YES | | NULL | |<br>| updated_at | timestamp | YES | | NULL | |<br>+ — — — — — — + — — — — — — — — — + — — — + — — -+ — — — — -+ — — — — — — — — +</pre><h3>⚒️<strong>Creating Models</strong></h3><p>Models are objects mapped to tables in the database. They serve as classes for performing database operations. For more details, refer to the chapter on “Eloquent ORM.”</p><p>🔍You can create a model using Artisan’s `make:model` command.</p><pre>% php artisan make:model Book</pre><pre>&lt;?php<br><br>namespace App;<br><br>use Illuminate\Database\Eloquent\Model;<br><br>class Book extends Model<br>{<br>    //<br>}</pre><h3>⚒️<strong>Seeding</strong></h3><p>Seeding is the process of inserting test data or master data records that are needed when the application starts. It is done using commands. Follow these steps to perform seeding:</p><p>🔍<strong>Creating a Seeder File</strong></p><p>You can create a seeder file using Artisan’s `make:seeder` command:</p><pre><br> % php artisan make:seeder BooksTableSeeder</pre><p>This command will create a `BooksTableSeeder.php` file in the `database/seeds` directory.</p><pre>&lt;?php<br><br>use Illuminate\Database\Seeder;<br><br>class BooksTableSeeder extends Seeder<br>{<br>    /**<br>     * Run the database seeds.<br>     *<br>     * @return void<br>     */<br>    public function run()<br>    {<br>        //<br>    }<br>}</pre><p>Okay, so now you made the BooksTableSeeder, let’s say you want to insert the following records into the Books table:</p><pre>| ID | NAME | PRICE | AUTHOR | CREATED_AT | UPDATED_AT |<br>| — — | — — — — — — — | — — — -| — — — — -| — — — — — — — | — — — — — — — |<br>| 1 | Book1 | 1000 | Mike| current time | current time |<br>| 2 | Book2 | 2000 | NULL | current time | current time |<br>| 3 | Book3 | 3000 | Doe | current time | current time |</pre><p>In that case, you would modify the `run` method of the seeder file as follows:</p><pre>`database/seeds/BooksTableSeeder.php`<br><br>public function run()<br>{<br> // Clear the table<br> DB::table(‘books’)-&gt;truncate();<br>// Prepare initial data (associative array with column names as keys)<br> $books = [ [ ‘name’ =&gt; ‘Book1’, ‘price’ =&gt; 1000, ‘author’ =&gt; ‘Mike’ ],<br> [ ‘name’ =&gt; ‘Book2’, ‘price’ =&gt; 2000, ‘author’ =&gt; null ],<br> [ ‘name’ =&gt; ‘Book3’, ‘price’ =&gt; 3000, ‘author’ =&gt; ‘Doe’ ]<br> ];<br><br> // Insert records<br> foreach($books as $book) {<br> \App\Book::create($book);<br> }<br>}<br></pre><p>Additionally, modify the `run` method of `DatabaseSeeder.php` so that the class called within the `run` method is executed by the seeding command.</p><pre>database/seeds/DatabaseSeeder.php<br><br>public function run()<br>{<br> // Specify to load BooksTableSeeder<br> $this-&gt;call(BooksTableSeeder::class);<br>}<br></pre><pre>// Run this command to seed <br>% php artisan db:seed</pre><p>You can go to MySQL and check if the Seeding worked or not by hitting the following command.</p><pre>mysql&gt; select * from books;</pre><p>Now, with this, the database-related setup is complete. And It might have seemed like a lot of work, but once it’s done, every user sharing the project can initialize the database with just two commands: `migrate` and `db:seed`.</p><h3>🔍<strong>Routing</strong></h3><p>Once the database setup is complete, we can start building the application. Let’s begin with routing. Routing is the process of accepting client requests and distributing them based on their content. Routing information is written in the `<strong>routes/web.php</strong>` file.</p><pre>#### `routes/web.php`<br><br>&lt;?php<br>Route::get(‘/’, function () {<br> return view(‘welcome’);<br>});<br></pre><p>One route is already defined. This means that when a GET request is received at the root (`/`), it returns the `welcome` view as a response. The `welcome` view is located at `resources/views/welcome.blade.php`.</p><p>When Laravel calls the `view` function, it searches the `resources/views/` directory and returns a file that matches the name (excluding the extension).</p><p>If you start the server using the Artisan command and access `<a href="http://localhost:8000/%60">http://localhost:8000/`</a>, the content of `welcome.blade.php` will be displayed.</p><p>To route through a controller instead of returning a view directly, you can write it as follows:</p><pre>### `routes/web.php`<br><br>&lt;?php<br>Route::get(‘book’, ‘BookController@index’);<br></pre><p>The above code means, “When a GET request is made to `<em>localhost:8000/book</em>`, route the request to the `index` method of `BookController`.” At this stage, since we haven’t created `BookController`, it won’t work properly yet.</p><h3>🔍Route Parameters</h3><p>Before creating a controller, let’s understand route parameters.</p><pre>#### `routes/web.php`<br><br>&lt;?php<br>Route::get(‘book/{id}’, ‘BookController@show’);</pre><p>This code means, “When a GET request is made to `localhost:8000/book/2`, route the request to the `show` method of `BookController`.” In `BookController`, the `show` method should accept an argument.</p><pre>#### `app/Http/Controllers/BookController.php` (not yet created)<br><br>public function show($id)<br>{<br> return view(‘book’, [‘book’ =&gt; Book::findOrFail($id)]);<br>}</pre><p>The number `1` specified in the URI is assigned to the `$id` argument.</p><h3>🔍Restful Resource Controller</h3><p>Using the `Route::resource` method, you can set up Restful routing.</p><pre>#### `routes/web.php`<br><br>&lt;?php<br>Route::resource(‘book’, ‘BookController’);</pre><p>This routes as follows:</p><pre>| Request Method | URI | Controller Action | Main Use for CRUD Screens |<br>| — — — — — — — — | — — — — — — — — — — -| — — — — — — — — — — — — — -| — — — — — — — — — — — — — — — — — |<br>| GET | /book | BookController@index | Display list screen |<br>| GET | /book/{book} | BookController@show | Display detail screen |<br>| GET | /book/create | BookController@create | Display registration screen |<br>| POST | /book | BookController@store | Registration process |<br>| GET | /book/{book}/edit | BookController@edit | Display edit screen |<br>| PUT | /book/{book} | BookController@update | Edit process |<br>| DELETE | /book/{book} | BookController@destroy | Deletion process |</pre><p>From here on, we’ll create the controller assuming that routing is set up using the `resource` method.</p><h3>⚙️Creating a Controller</h3><p>After setting up the routing, the next step is to create the controller. The controller’s role is to receive requests that have been routed and create a response. When returning HTML as a response, the controller delegates processing to the View. To create a controller, use the Artisan `make:controller` command.</p><pre><br>% php artisan make:controller BookController</pre><p>The controller is created in the `<strong>app/Http/Controllers</strong>` directory. Please add the `index` method and `edit` method as shown below. Don’t forget to include `<strong>use App\Book</strong>`.</p><pre>#### `app/Http/Controllers/BookController.php`<br><br>&lt;?php<br>namespace App\Http\Controllers;<br><br>use Illuminate\Http\Request;<br>use App\Http\Controllers\Controller;<br>use App\Book;<br><br>class BookController extends Controller<br>{<br> public function index()<br> {<br> // Retrieve all values from the Book table<br> $books = Book::all();<br><br><br>// Pass the retrieved values to the “book/index” view<br> return view(‘book/index’, compact(‘books’));<br> }<br><br>public function edit($id)<br> {<br> // Retrieve the Book information with the same ID as the URI parameter from the DB<br> $book = Book::findOrFail($id);<br><br>// Pass the retrieved values to the “book/edit” view<br> return view(‘book/edit’, compact(‘book’));<br> }<br>}<br></pre><p>To return a view in a controller method, use the `view` function. The `view` function takes the view name as the first argument and the values to pass to the view as the second argument. The second argument should be passed as an associative array. Using the `compact` function allows you to easily pass associative arrays. For example, `compact(‘book’)` in the `edit` function is equivalent to `[‘book’ =&gt; $book]`.</p><p>For now, we have prepared the `index` and `edit` methods among the routed methods. The value retrieval from the DB is done using a mechanism called Eloquent.</p><p>Okay, I want to keep going but personally, I feel that it might be better to break down this tutorial into 2 parts. So in the next post, let`s resume from “<strong>Creating Views</strong>”, so thank you for reading and see you in the part 2 ! 🔍</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a8729606eebd" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>