Windows Powershell automated CPU monitoring and services restart

Today I was having some trouble with a windows server. For some reason it was using a lot of CPU and then froze. I had to restart mysql, apache and sql server everytime and that only when I could logon with remote desktop. I decided to have a script check every now and then if the cpu was increased and came up with the following powershell script:

$cpuutil=(get-counter -Counter "\Processor(_Total)\% Processor Time" -SampleInterval 1 -MaxSamples 5 | select -ExpandProperty countersamples | select -ExpandProperty cookedvalue | Measure-Object -Average).average
Write-Host "CPU: $cpuutil"

If ($cpuutil -ge 90){
	Write-Host "Restarting MySQL, Apache, SQL-Server..."
	Restart-Service httpd, mysqld, sqlservr

I then went and made a scheduled task fire this script every hour and everything seems to be working fine now.

Toast messages and spinners in iOS

I found this code while looking for an iOS notification similar to Android Toast.
The code is available in a Github project found here:
It was just what I needed!

P.S. You can also make great loaders with this code 😉

To install:

  1. Add a pod entry to your Podfile pod
    pod 'Toast', '~> 3.0'
  2. Install the pod(s) by running
    pod install
  3. Include MBProgressHUD wherever you need it with:
    #import "Toast/UIView+Toast.h"



Put the following code wherever you want to invoke the toast.

[self.view makeToast:@"This is a piece of toast with a specific duration." duration:3.0];

For displaying a loader with the activityspinner use

[self.view makeToastActivity:CSToastPositionCenter];

And to hide it:

[self.view hideToastActivity];

‘Hello world’ in 20+1 different programming languages

Hello! Since it is my first blog post I decided to write a ‘hello world’ post with examples from different programming languages.

A hello world program is used to give the reader a quick overview of the programming language syntax and also get the code for the bare minimum program to run.

Le’ts not waste another minute and get to it.

  1. PHP
    <?php echo "hello world!";?>
  2. Javascript
    alert("hello world!");
  3. Python
    print("hello world")
  4. C
    int main(void)
    puts("Hello, world!");
  5. C++
    #include <iostream.h>
        cout << "Hello World!" << endl;
        return 0;
  6. C#
    using System;
    class Program
        public static void Main(string[] args)
            Console.WriteLine("Hello, world!");
  7. Objective C
    int main(void)
    &nbsp; &nbsp; NSLog(@"Hello, world!");
    &nbsp; &nbsp; return 0;
  8. HTML
    Hello World!
  9. Matlab
    disp('Hello, world!')
  10. Java
    class HelloWorld {
      static public void main( String args[] ) {
        System.out.println( "Hello World!" );
  11. MS DOS
    ECHO Hello World!
  12. Linux Bash
    echo "Hello World!";
  13. Node.js
    var sys = require('sys');
    sys.puts('Hello World');
  14. Ruby
    puts "Hello World!"
  15. BASIC
    10 PRINT "Hello World!"
  16. Visual Basic 6
    Private Sub Form_Load()
    Print "Hello World"
    End Sub
  17. Visual Basic .NET
    Imports System.Console
    Class HelloWorld
        Public Shared Sub Main()
            WriteLine("Hello, world!")
        End Sub
    End Class
  18. Pascal
    program HelloWorld(output);
      WriteLn('Hello World!');
  19. ASP.NET
    <%= "Hello World!" %>
  20. Fortran 77
    PRINT*, 'Hello World!'
  21. Arduino
    void setup()
      Serial.println("Hello, world!");
    void loop()


When I started writing this post I was sure I would write each hello world on my own. But as the list was growing I got a bit tired and googled some of the programs. Doing that I stumpled upon a website with 533 ‘hello world’ programs