Monday, May 15, 2017

Windows 10 Updates

Windows 10 would prefer full control of your PC and updates whenever it wants. There is a limited number of ways to stop this.

When getting this message "Getting Windows ready, Don’t turn off your computer screen", some people have waited from 7 hours to 24 hours - so be patient.

The Software Distribution Folder is responsible for storing Windows Updates stuff. To operate on this folder, first stop the Windows service:
   net stop wuauserv
   net stop bits
Then either delete or rename the folder, then start again.
   net start wuauserv
   net start bits
These operations can solve some Windows Update problems.
For more info see:

To stop Windows 10 from updating automatically, login as a user with Administrator privilege.
Click the Start button, then click the Setting (like a gear icon) button.
A Windows Settings page appears. Then click the "Network & Internet" option.
Click Wifi and then Manage Known Networks.
Click on your wifi network name, then click Properties.
Under Metered Connection, set it to On.

Thursday, April 20, 2017

How to Uninstall Google Drive always shutting down fix

Google Drive app can be installed on PC to sync files to your Google Drive in the cloud. Not sure about others, but I never get it right in the first install. That means I need to uninstall and re-install.

For example, this time, I chose the right directory to sync on my local PC, but sign in with the wrong google account. So after uninstall and reinstall, the Google Drive folder was on the desktop, but the service itself was not working at all. There was no icon in the taskbar.

On the taskbar, click Customize, and among the list of icons, is Google Drive with the writing saying "Shutting down...." After many uninstall/reinstall - it is always the same.

Others have reported similar problems but no solution:!topic/drive/rKsXF3ZZWA8!topic/drive/nKPuY8dcn34!topic/drive/IvoOGUNafpo

The solution is to:
1) Uninstall Google Drive from the "Programs and Features" window.
2) Then go to File Explorer and DELETE the following:
The AppData is hidden usually, so you need to go to Control Panels -> Folder Options, to choose not to hide files option.
3) Then Reinstall Google Drive - of course with lots of PC Restart between the processes.


How To Escape MS blocking MS Win7 from Security Updates

MS is forcing people who buy new systems, ie with new CPUs such as AMD Ryzen or Intel Kaby Lake, to use Win10. If they use Win7 or Win 8.1, they will be blocked from receiving Windows Updates.

What to do?
1. Stop receiving Win updates - actually I have switched off Win updates for over a year, after hearing news that updates can stuff up the PC sometimes. So this not being able to get Windows Update can be a good thing, provided your PC is secured via other means.

2. Someone in the internet has already developed a way to bypass the MS shenanigans.

Apparently a set of Win updates are responsible for checking the CPUs. These updates are listed below, perhaps if we avoid them, then it would not check for CPUs.
KB4012218, KB4012219, KB4015546, KB4015547, KB4015549, KB4015550, KB4015552 and KB4015553.

Saturday, January 07, 2017

How to setup IP cameras

This is Work-In-Progress

What is my RTSP or HTTP stream?
IP cameras broadcast, or more technically stream, the images from the camera to a specific IP URL. There are default URLs given in the instructions, but these may not work.
Here are a few sites to check which model is your camera, and what is their URLs:

Another thing is to find out who the manufacturer is. The manufacturer of IP cameras are not obvious from the brand name because there are many brand names, but the manufacturer may be different. First find out the first 6 Hex number of the MAC ID of the IP camera.
Secondly, go to this website, using the first 6 Hex numbers, to find the manufacturer name.
Having the manufacturer name may be helpful, when trying to find information, such as documentations, drivers or software for the IP camera.

Some Cloud storage for IP cameras:

Saturday, April 09, 2016

How to Post to Blogger - Blogspot using Google API in Python automatically

This blog explains the end-to-end of the steps needed to write a Python program that will write a "post" to a blog on Google's
Why? This is part of a step to automate writing blog posts. For example, you want to post a blog every minute to say:
    Today - at this exact minute 12:05:00, the temperature is 27'C
In this example the time and temperature data are obtained somewhere and you can programmatically construct the sentence above.
However, it will be very tedious to login to blogger, click on many buttons, write the content and publish the post every minute.
A program can be setup to login automatically and post the sentence above to the blog automatically - that is the goal here.

To write a Python program that will automatically publish blogger/blogspot post

The combination of the following technologies are used:
- Python programming language
- Blogger/Blogspot blog providers
- Google API for Python
- OAuth 2.0 Google Authorization

1. Python v2.x - assume you have this installed - instructions on how to install and use python is beyond the scope of this post.
2. / account - These two names are the same free Blog site owned by Google. It is assumed you already have an account and know how to post blogs by logging in and posting a blog manually. Instructions on how to setup and use a blog the normal ways are not covered here.


1. On a CMD prompt / terminal, do:
pip install --upgrade oauth2client
pip install --upgrade google-api-python-client

2. Go to website below to get 'api_name', 'api_version'
Supported Google APIs:
api_name=blogger    api_version=v3
api_name=drive      api_version=v3


These two websites are good to get a reasonable understanding, but ultimately does not provide direct instructions.

The three main types of Credentials are:
1. API Keys
2. OAuth 2.0 client IDs
3. Service account keys

Go to
The interface is not very good at directing what to do next.
On the left panel are: Overview,  Credentials
On the top right horizontal menu of items, there is a Drop-Down icon
--- Click on the Drop-Down icon to "Manage all projects" or "Create Project"
--- If new here, then choose Create Project,
--- Note that you can enter quite different values for Project Name and Project ID.

Coming back to the main page, click Overview
--- Now the main area has: "Google APIs" and "Enabled APIs"
--- Click on the "Google APIs" to show a list of popular APIs.
--- If Blogger API is not listed, type Blogger on the search text field.
--- Then click Blogger and click Enable (if not enabled already)
--- Going back some pages, now click "Enabled APIs". On this page, check that "Blogger API v3" is listed.

Coming back to the main page, click Credentials (just below Overview)
--- The top submenu has: "Credentials", "OAuth consent Screen", "Domain Verification"
--- Click on Credentials.
--- for OAuth 2.0 client IDs
------ To create manually, click on "Create Credentials", choose OAuth Client ID, choose Other as Application type.
------ To create automatically, click on "Create Credentials", choose "Help Me Choose".
--------- Then in the drop down, choose Blogger API, choose calling the API from "Other UI(Windows)", choose "User Data"
------ At the end, the credentials is downloaded, eg client_secret_<client_id>.json, and the content is like:
--- for Service Account Keys
------ To create manually, click on "Service Account Keys", choose a service account (create one if needed), choose JSON, click Create.
------ To create automatically, click on "Create Credentials", choose "Help Me Choose".
--------- Then in the drop down, choose Blogger API, choose calling the API from "Other UI(Windows)", choose "Application Data"
------ At the end, the credentials is downloaded, eg <project>-<keyID>.json, and the content is like:
  "type": "service_account",
  "project_id": ".......",
  "private_key_id": "..................",
  "private_key": "-----BEGIN PRIVATE

Since this project is about automated program that writes to the blog, the credentials should not involve any interaction - in this case, create and use the "Service account keys"
The "OAuth 2.0 client IDs" also works but requires clicking a button and copying a "code" to the python program. This is shown to work - but this is less suitable for our goals.

Before the actual coding to use the APIs, the authorization process also need to know the scopes of your program.
Here are some scopes for the Blogger API and the Google Drive API:

Blogger API, v3 Manage your Blogger account View your Blogger account
Drive API, v3 View and manage the files in your Google Drive View and manage its own configuration data in your Google Drive View and manage Google Drive files and folders that you have opened or created with this app View and manage metadata of files in your Google Drive View metadata for files in your Google Drive View the photos, videos and albums in your Google Photos View the files in your Google Drive Modify your Google Apps Script scripts' behavior

*** A Complete list of scopes for all Google APIs (not just Blogger and Drive), can be found in:
- title "OAuth 2.0 Scopes for Google APIs"

CODE in Python:
1. The code below is complete end to end. When run, it will handle the authorization, then send some text, to be posted to a blogger site and the json response is captured.
2. There may be more import statements than necessary.
3. The code will NOT work as is because the __blogID__ is not real and the <blah>.json files is not the real filenames. If these values are replaced with proper values, the code should work.
4. The code also shows to options of OAuth. The first uses "OAuth 2.0 for Server to Server Applications" which does not need interaction. The second, which is commented out, uses "Client Secrets", which pops-up a browser, then the operator needs to copy the code and paste it on the terminal where the python code is running.

import os
# OAuth 2.0 for Installed Applications
from oauth2client.client import flow_from_clientsecrets
# OAuth 2.0 for Server to Server Applications
from oauth2client.service_account import ServiceAccountCredentials
from httplib2 import Http
from oauth2client.client import flow_from_clientsecrets
import json
import webbrowser
import httplib2

from apiclient import discovery
from oauth2client import client
from apiclient.discovery import build
from googleapiclient import sample_tools


# Using OAuth 2.0 for Server to Server Applications

scopes = ['']
credentials = ServiceAccountCredentials.from_json_keyfile_name('<project>-<keyID>.json', scopes)
http_auth = credentials.authorize(Http())
# THis returns no errors - so what's next????

# Client Secrets
flow = flow_from_clientsecrets('client_secret_<client_ID>.json',
# This section copied from
auth_uri = flow.step1_get_authorize_url()
auth_code = raw_input('Enter the auth code: ')
credentials = flow.step2_exchange(auth_code)
http_auth = credentials.authorize(httplib2.Http())
# THis returns no errors - so what's next????

service = build('blogger', 'v3', http=http_auth)   # (api_name, api_version)

text = \
'{ \
    "kind": "blogger#post", \
    "blog": { \
        "id": "999999999999999" \
    }, \
    "title": "A new post", \
    "content": "With <b>new</b> content..." \

parsed = json.loads(text)
print json.dumps(parsed , indent=4, separators=(',', ': '))

request = service.posts().insert(blogId=__blogID__, body=parsed )
response = request.execute()
print json.dumps(response , indent=4, separators=(',', ': '))

There is a lot of information on this subject, to the extent that it has become confusing and difficult to understand.
The instructions in this blog post just give the minimum steps without too much explanations with the aim of reducing the confusion.
However, to gain an understanding after the fact, the list of websites is given here as a reference:
- EXCELLENT page - title "OAuth 2.0" - part of "API Client Library for Python"
- examples of Python code to use OAuth 2.0 to connect to Google APIs.
- talks about "redirect_uri" in the code. The main page is called "Using OAuth 2.0 for Installed Applications"
- not that useful
- title "Using OAuth 2.0 for Server to Server Applications", part of the "API Client Library for Python"
- OAuth 2.0 can be for "Web Server Application", "Installed Applications", "Server to Server Applications".
- For this goal of automatically posting to Blogger, the "Server to Server Applications" is the most relevant.
- Intro to the Blogger API
- Blogger API reference

About accessing Google APIs for Blogger