Passive income for programmers

This post describes options for creating passive income with explanation of basic steps you need to execute to be successfull and earn some money.

What is passive income?

First you need to understand difference between active income and passive income. Active income is dependent on the quantity of hours you work. For example when you work 100 hours and your hour tax is $30 per hour you will earn $3000. Passive income is not dependent on the quantity of hours you work. You create something at the beginning and it makes money for you for a long period. You spent only minimal amount of time to maintain this income. Benefits of passive income:

  • You earn money even if you sleep or you are on holidays
  • You get more time for you, your family and friends
  • You can spent more time with your hobbies
  • You spent more time on your project which can shift you to your targets in the future and you don’t have to spent time on projects of your employeer

What changed internet

In the past passive income was related to especially real estate business. Typically you own some house or flat and rent if for money. Internet revolution created new options and opportunities for creating passive income streams.

Passive income options for programmers

Programmers can establish passive income this ways:

1. Tematic website

You create website with some interesting content. Content is a king when you want to attract people to your web site. Setup Google Analytics to analyse traffic to your website and then setup Google AdSense‎ to earn money on ads.

2. Blog

This passive income idea is very similar to tematic website. Choose topic you want to write about and then create blog using some blogging platform, for example WordPress‎. Setup Google Analytics to analyse traffic to your website and then setup Google AdSense‎ to earn money on ads.

3. Mobile app

At the beginning choose the mobile platform: Android, iOS, Windows Phone. Then choose monetization model: free app with ads, paid app, in-app purchase (IAP). Create mobile app and publish it to store. Setup Google Analytics and integrate it into mobile app to analyse usage of your app.

4. Udemy course

Udemy‎ is modern e-learning platform with big potencial for students and also for instructors. At the beginning choose the topic, you can inspire from Udemy website, Udemy hot topics or Google Trends. Then create the video course. Course creation process in not easy.
It takes me 30 hours of work when creating my first Udemy course with duration of 30 minutes. After publishing of course you should promote your course to build audience of students.

5. Kindle ebook

Choose ebook topic, you can inspire by Amazon‎ website or by Google Trends. Then publish and promote it.

6. Custom library

In the past you probably create some piece of code or library for solving some specific problem and you and your colleagues used it on many projects. If you think that this library can help also other people, you can earn some money on it. Setup website for selling this library, choose license and setup payment method for example PayPal‎.

If you are interested about more detailed step by step instructions, take my Udemy course Passive income for programmers. This course describes all aspects of creating passive income as programmer.

Restore Microsoft SQL Server database using PowerShell

In previous post I wrote about the backup of Microsoft SQL Server database using PowerShell. Opposed operation to backup is restore, which can be executed using following PowerShell script:

param
(
    [string] $backupFile = $(throw "Backup file is required"),
    [string] $databaseName = $(throw "Database name is required")
)

$server = "."

Import-Module SQLPS

Invoke-Sqlcmd -ServerInstance $server -Query "ALTER DATABASE $databaseName SET SINGLE_USER WITH ROLLBACK IMMEDIATE"
Invoke-Sqlcmd -ServerInstance $server -Query "RESTORE DATABASE $databaseName FROM DISK='$backupFile' WITH REPLACE"
Invoke-Sqlcmd -ServerInstance $server -Query "ALTER DATABASE $databaseName SET MULTI_USER WITH ROLLBACK IMMEDIATE"


Udemy course: Improve your productivity with PowerShell

At the first step database is set to single user mode. Next the restore of database is executed. After restore the database is set back to multi user mode.

If you are interested in PowerShell automation, take my Udemy course Improve your productivity with PowerShell.

Backup Microsoft SQL Server database using PowerShell

During development we need often create backup of Microsoft SQL Server database. Performing this task using SSMS UI dialog is slow and time consuming activity. This task can be automatized by following PowerShell script:

param
(
    [string] $databaseName = $(throw "Database name is required"),
    [string] $backupToDir = ".",
    [bool] $shrinkLogFile = $true
)

Import-Module SQLPS

if ($backupToDir -eq ".")
{
    $backupToDir = (Get-Item .).FullName + "\Backups\"

    if (-not (Test-Path $backupToDir))
    {
        New-Item -Path $backupToDir -ItemType Directory | Out-Null
    }
}

if ($shrinkLogFile)
{
    $shrinkCommand = "DBCC SHRINKFILE (" + $databaseName + "_log, 0)"
    Invoke-Sqlcmd -ServerInstance . -Database $databaseName -Query $shrinkCommand | Out-Null
}

$now = (Get-date).ToString("yyyyMMddHHmmss")
$backupCommand = "BACKUP DATABASE " + $databaseName + " TO DISK='" + $backupToDir + $databaseName + "_" + $now + ".bak' WITH COMPRESSION"

Invoke-Sqlcmd -ServerInstance . -Query $backupCommand


Udemy course: Improve your productivity with PowerShell

The script shrinks database log file and backup is created with compression to decrease the size of backup file.

If you are interested in PowerShell automation, take my Udemy course Improve your productivity with PowerShell.

Analyse log files using PowerShell

PowerShell is great tool for analysing log files. Using few PowerShell cmdlets pipelined together we can find errors:

Get-Content *.log | Select-String error | Sort-Object | Get-Unique | Out-File error.log -Width 1000 -Encoding UTF8


Udemy course: Improve your productivity with PowerShell

Purpose of cmdlets is following:

This simple, but powerfull one line code snippet can help find specific items in log files fast and effectively.

If you are interested in PowerShell automation, take my Udemy course Improve your productivity with PowerShell.

What is new in C# 6

My first Udemy course https://www.udemy.com/what-is-new-in-csharp-6 covers new features of C# 6. Taking this course you learn:

  • Auto-property initializers
  • Getter-only auto-properties
  • Expression-bodied members
  • Using static
  • Null-conditional operators
  • String interpolation
  • nameof expressions
  • Index initializers
  • Exception filters
  • Await in catch and finally blocks