Learning to Code With Load Shedding and Unstable Power in Kenya
You can learn to code effectively in Kenya despite unstable power by combining hardware solutions (UPS, power banks, a laptop with good battery life) with software habits (auto-save, Git version control, offline tools). Planning your study schedule around power availability and using co-working spaces with backup generators also helps. Power is a constraint, not a blocker.
The Power Situation in Kenya: Being Honest About the Problem
Let us skip the part where we pretend this is not a real issue. Power reliability in Kenya varies enormously depending on where you live. Some neighborhoods in Nairobi go weeks without an outage. Others experience multiple cuts per week. Outside the major cities, the situation can be significantly worse. And even in areas with generally reliable supply, KPLC scheduled maintenance, transformer failures, or heavy rains can knock out power for hours at a time.
For someone trying to learn to code, power outages are particularly frustrating. Coding requires sustained focus. You need to hold complex logic in your head while building something. A power cut does not just interrupt your electricity. It interrupts your thinking. Getting back into the same mental state after a 30-minute outage can take another 20 minutes. Over weeks and months, those interruptions add up to a significant drag on your progress.
There is also the anxiety factor. If you are worried that the power might go out any minute, it is harder to get into a flow state. You find yourself saving compulsively, rushing through exercises, and feeling stressed rather than engaged. That is no way to learn anything well.
The strategies in this guide will not fix Kenya's power grid. But they will make power outages a minor inconvenience rather than a major obstacle to your learning. Many working developers in Kenya deal with these same challenges every day. They have figured out what works.
Hardware Solutions: UPS, Power Banks, and Battery Life
Your first line of defense against power outages is hardware. A few smart purchases can dramatically reduce the impact of outages on your study time.
A laptop with good battery life. This is the most important single factor. If your laptop gets 4 to 6 hours of real battery life (not the manufacturer's optimistic estimate, but actual usage while coding), a typical outage will not even interrupt your work. You just keep going on battery. When shopping for a laptop, battery life should be a top priority alongside RAM and processor speed. Chromebooks and MacBook Airs tend to have excellent battery life. Some Windows laptops are good too, but check real-world reviews, not spec sheets. If your current laptop barely lasts an hour, consider whether a battery replacement (often KES 3,000 to 8,000) would extend its life significantly.
A UPS (Uninterruptible Power Supply). A UPS is a battery backup that sits between the wall outlet and your devices. When power cuts, it switches to battery instantly, giving you time to save work or continue working during short outages. For coding purposes, you do not need an expensive enterprise UPS. A basic 650VA to 1000VA unit (KES 5,000 to 15,000 from local electronics shops) is enough to keep your router running for 30 to 60 minutes during an outage. Keep your internet alive and your laptop on battery, and a short outage becomes a non-event. Plug your router and phone charger into the UPS. Your laptop has its own battery, so it does not need the UPS directly.
A laptop power bank. These are larger than phone power banks and can charge laptops via USB-C. Models in the 20,000 to 30,000 mAh range (KES 5,000 to 15,000) can give you one to two extra charge cycles. If your laptop charges via USB-C, this is a game-changer for extended outages. Not all laptops support USB-C charging, so check your model before buying. Brands like Anker and Baseus are available in Kenya and generally reliable.
A solar panel (for rural or peri-urban areas). If you live in an area with very unreliable grid power but good sunshine, a small solar panel setup (enough to charge your laptop and phone) can provide genuine independence from the grid. The upfront cost is higher, but in areas with frequent multi-hour outages, the return on investment can be surprisingly fast.
Software Strategies: Never Lose Your Work
Hardware keeps you powered. Software strategies ensure that when power does go out unexpectedly, you do not lose anything important.
Enable auto-save in VS Code. Go to Settings and search for "Auto Save." Set it to "afterDelay" with a delay of 1000 milliseconds (1 second). This means VS Code saves your file automatically every time you pause typing. If the power goes out mid-keystroke, you lose at most the last second of work. This is enabled by default in newer VS Code versions, but verify it is on. It is the single most impactful setting for dealing with unstable power.
Use Git religiously. Git is a version control system, and learning it early is essential for your coding career anyway. But in the context of power outages, Git serves as your work insurance. Every time you complete a small, working piece of code, commit it. Use descriptive commit messages. Push to GitHub when you have internet. If something catastrophic happens (laptop dies, hard drive corrupts, you accidentally delete a file), your code is safe on GitHub. Get into the habit of committing every 15 to 30 minutes of productive work. It takes seconds and it protects everything.
Use cloud-synced tools where possible. VS Code Settings Sync backs up your editor configuration to your GitHub or Microsoft account. If you need to switch to a different machine (say, at a co-working space when your home power is out), you can get your exact setup on any computer in minutes. Google Docs or Notion for your study notes means they are always accessible from any device.
Keep offline copies of critical resources. Download the documentation you use most frequently. Save tutorial pages locally. Have your course materials available offline. When the power comes back but the internet is still down (which happens, routers take time to reconnect), you can keep learning from your offline resources.
Know your laptop's shutdown behavior. Configure your laptop to hibernate (not just sleep) when the battery gets critically low. Hibernation saves your entire working state to disk, so when you power back on, everything is exactly where you left it. Sleep mode still uses battery and can drain to zero, causing a hard shutdown. On Windows, go to Power Options and set "Critical battery action" to "Hibernate." On Linux, most distributions handle this automatically.
Scheduling Your Study Around Power Availability
If your area has a predictable pattern of outages (many KPLC areas do, especially during scheduled maintenance), you can plan your study schedule around power availability. This sounds obvious, but most learners do not do it deliberately.
Track the pattern. For two weeks, note when power goes out and when it comes back. Many areas have recognizable patterns, whether it is maintenance days, time-of-day tendencies, or weather-related outages. KPLC sometimes posts scheduled outage notices on their website and social media. Follow them. Once you know the pattern, you can plan around it.
Do your heavy work when power is reliable. Activities that require internet (watching tutorials, downloading packages, pushing to GitHub, researching on Stack Overflow) should happen when you have both power and connectivity. Activities that work offline (writing code, reading downloaded docs, practicing logic problems) can happen during outages if your laptop has battery.
Front-load your downloads. When power and internet are both stable, download everything you might need for the next few days. Video tutorials, documentation, npm packages, course materials. Treat stable connectivity as a resource to be collected, not a constant you can rely on.
Have a "no power" study plan. Keep a notebook (yes, paper) with coding problems, algorithm exercises, or pseudocode planning for your projects. When the power goes out and your laptop is dead, you can still study. Drawing flowcharts, planning database schemas on paper, or working through logic problems with pen and paper are all productive uses of time that require zero electricity. Some developers find that stepping away from the screen and thinking through problems on paper actually helps them code better when they get back to the keyboard.
Use early mornings. In many parts of Kenya, power is most reliable in the early morning hours. If you can shift your study time to 5 AM or 6 AM, you often get 2 to 3 uninterrupted hours before the day's outages begin. This is also when your mind is freshest, which is a bonus.
Backup Study Locations With Reliable Power
Sometimes the best strategy is simply going somewhere else. Having two or three backup locations where you can study when your home power is unreliable gives you flexibility that no amount of battery life can match.
Co-working spaces. Nairobi has dozens of co-working spaces, and they are spreading to other towns like Kisumu, Mombasa, Nakuru, and Eldoret. Most have backup generators or solar power that keeps them running during grid outages. Some offer daily passes that are affordable enough to use a few times a month when your home power is particularly bad. The added benefit is being around other people who are working, which can help with motivation and focus.
University and college libraries. If you are near a university campus, their libraries and computer labs often have more reliable power (backup generators for the whole campus). Some allow community access or have public areas. Even if you are not a student, it is worth checking what is available.
Cafes and restaurants with power outlets. Java House, Artcaffe, and various independent cafes across Nairobi and other cities are known for being laptop-friendly. Buy a coffee, plug in, and work. The cost of a drink is often less than the productivity you gain from 3 to 4 hours of uninterrupted work. Look for places with backup power, not just wall outlets.
Friends and family. If you know someone in a neighborhood with more reliable power (or someone with a generator or solar setup), see if you can study there occasionally. Studying with a friend who is also learning to code doubles as both a power solution and an accountability partnership.
Community innovation hubs. Organizations like iHub, Nailab, and various county-level innovation hubs sometimes offer free or low-cost workspace with reliable power and internet. These are especially useful if you are outside Nairobi, where commercial co-working options are fewer.
Protecting Your Equipment From Power Surges
Unstable power does not just mean outages. It also means voltage fluctuations and power surges that can damage your equipment. This is an often-overlooked risk for Kenyan developers.
Use a surge protector. A basic surge protector power strip (KES 500 to 2,000) is cheap insurance for your laptop charger, monitor, and other electronics. It absorbs voltage spikes that happen when power comes back on after an outage. Never plug your laptop charger directly into a wall outlet in an area with unreliable power. Always go through a surge protector.
Unplug during storms. Lightning-induced surges can bypass basic surge protectors. If there is a serious thunderstorm, unplug your equipment entirely. This feels overcautious until the one time it saves your laptop from being fried. Kenya's rainy seasons bring plenty of electrical storms, especially in the highlands and around Lake Victoria.
A UPS doubles as surge protection. Most UPS units include built-in surge protection, which is another reason they are worth the investment. If you have a UPS, your connected devices are protected from both outages and surges.
Check your charger and cable. Cheap, counterfeit laptop chargers are common in Kenya and can be dangerous with unstable power. They lack proper surge protection circuitry. If your charger came from a roadside stall for suspiciously cheap, consider investing in an original or quality third-party replacement. Your laptop is worth much more than the savings on a fake charger.
Battery health maintenance. Frequently cycling between full charge and complete drain (which happens naturally with frequent outages) degrades laptop batteries faster. If you can, try to keep your battery between 20% and 80% for daily use. Some laptops have a "battery health" or "conservation" mode in their power settings that automatically limits charging to 80% when plugged in. This extends battery lifespan, which matters when your battery is your primary power backup.
The Mindset: Power Problems Are Not an Excuse to Stop
Here is the uncomfortable truth: many people who cite power outages as the reason they stopped learning to code were already looking for a reason to stop. Power problems are real, but they are also solvable. The developers who make it through are the ones who treat outages as logistical problems to work around, not insurmountable barriers.
Every working developer in Kenya has dealt with power issues. They did not have magical solutions. They had the same UPS devices, the same power banks, the same cafe backup plans that you have access to. The difference is that they decided the goal was worth the inconvenience and adapted accordingly.
That said, be honest with yourself about your specific situation. If your area has 8-hour daily outages and you have no laptop battery and no backup location, that is a genuinely difficult constraint. In that case, the priority might be solving the power problem first (even if it means studying at a cyber cafe for a while) before investing in courses or bootcamps. There is no shame in sequencing things practically.
For most Kenyan learners, though, power is a solvable inconvenience. A decent laptop battery, a UPS for your router, auto-save and Git habits, and one backup study location cover the vast majority of scenarios. Once you have those basics in place, power outages become a minor frustration rather than a learning blocker. The code you write during an outage (on battery power, with offline docs) is exactly as valid as the code you write with stable grid electricity.
Key Takeaways
- ✓A laptop with at least 4 to 6 hours of real battery life is your first line of defense. When the lights go out, your laptop keeps you coding.
- ✓A basic UPS (uninterruptible power supply) for your router and charging station costs KES 5,000 to 15,000 and pays for itself quickly by keeping your internet alive during short outages.
- ✓Git is not just a developer tool. It is your insurance policy against lost work. Commit early, commit often, and you will never lose more than a few minutes of progress to a sudden outage.
- ✓Auto-save in VS Code (enabled by default) and cloud-synced settings mean a power cut rarely costs you more than the time it takes to reboot.
- ✓Co-working spaces, university libraries, and cafes with backup power are reliable fallback locations when home power is too unreliable for focused study.
Frequently Asked Questions
- What is the best UPS for learning to code in Kenya?
- A basic 650VA to 1000VA UPS is sufficient for keeping your router and phone charger running during outages. Brands like APC and Eaton are available in Kenya through electronics shops and online retailers. Expect to spend KES 5,000 to 15,000. You do not need an expensive model since your laptop has its own battery. The UPS is mainly for keeping your internet alive during short outages.
- Can I use a power bank to charge my laptop during outages?
- Yes, if your laptop supports USB-C charging. Many modern laptops (especially ultrabooks and MacBooks) charge via USB-C. A 20,000 to 30,000 mAh power bank can provide one to two extra charge cycles. Check your laptop model before buying. Laptops that only charge through a proprietary barrel connector cannot use standard power banks.
- How do I avoid losing my code during a power outage?
- Enable auto-save in VS Code (Settings, search "Auto Save," set to "afterDelay"). Use Git and commit your work every 15 to 30 minutes. Push to GitHub when you have internet. Configure your laptop to hibernate (not sleep) on low battery. With these habits, the worst case is losing a few seconds of typing.
- Is it worth buying a generator for learning to code?
- For most individual learners, a generator is overkill. A UPS, a laptop with good battery life, and a power bank cover most scenarios at a fraction of the cost. Generators make more sense for households or small offices where multiple devices need sustained power. If your outages are very long and frequent, a small solar panel setup might be more cost-effective than a generator in the long run.
- How do I check KPLC scheduled power outages in my area?
- KPLC (Kenya Power) posts scheduled maintenance outages on their website (kplc.co.ke), their social media accounts (Twitter/X and Facebook), and sometimes in daily newspapers. You can also call their customer service line. Following their social media accounts is the easiest way to get advance notice. Some third-party apps and Telegram groups also aggregate outage information.
- What coding activities can I do with no power at all?
- You can plan projects on paper (flowcharts, wireframes, database schemas), solve logic and algorithm problems with pen and paper, review printed or handwritten notes, and practice pseudocode. If your phone has battery, you can read documentation or short tutorials on mobile. Many developers find that planning on paper before coding leads to cleaner, more intentional code.
Ready to build real-world apps?
Join the McTaba Labs full-stack marathon (4 months full-time · 6 months part-time). Learn M-Pesa, USSD, and WhatsApp engineering while shipping 8 production apps.
Apply to the McTaba Marathon