[Google Cloud] IAM – Service Accounts

Google Cloud Service Accounts:

Service accounts are accounts used for the sole purpose of running your application. Some may also refer to this as the application processing identifier. Google uses the term service account. To identify a service account an email identifier is typically used. The email address used for a service account is an Identity & Access Management (IAM) account used as an identifier for reference purposes.

Here we use the command-line to create a new service account called: gdev1sa to represent the first development service account for our project. There is a tight coupling between the command-line console and web interface. Almost instantaneously when the service account is created via command-line it is also reflected in the Web GUI. For example as can be seen below our Services Accounts page only contains the default Compute Engine service account:

Screen Shot 2017-10-01 at 12.20.47 PM.png

Likewise, we see the same output via command-line:

~ gcloud iam service-accounts list

Compute Engine default service account; 637540065038-compute@developer.gserviceaccount.com

Create Service Account via Command-Line

~ gcloud iam service-accounts create gdev1sa --display-name "Primary Development Service Account"

Created service account [gdev1sa].

Likewise, after refreshing the Web Console we see the account creation reflected here as well (2nd row):

Screen Shot 2017-10-01 at 12.49.22 PM.png

By default when created each service account will not have its key pair created.

Service Account Keys

Service account keys are private / public key pairs unique to each service account. By default when a service account is created the service account has its own internal key pair used for service-to-service authentication within GCP that are also managed by GCP. With the default internal keys you do not have to worry about management tasks such as key rotation or misplacing them. The keys are exclusively managed within GCP. However, external keys can be created and downloaded after they are generated within GCP. As of this writing there are two types of external private keys: json and the older p12  format.

Create External Service Account Keys

Via command line… Note you need to specify the internal email identifier we spoke of earlier to reference the service account when create the private key. How will GCP know which private key to create? Good question! By default all private keys are created using the .json format unless .p12 is otherwise specified via the option: –key-file-type=p12

gcloud iam service-accounts keys create gdev1sa.json --iam-account=gdev1sa@project-good.iam.gserviceaccount.com
created key [0821b6693b9c974b466474c51a974a1405f530c5] of type [json] as [gdev1sa.json] for [gdev1sa@project-good.iam.gserviceaccount.com]


Posted in Google | Leave a comment

[Swift] Extra argument ‘completion’ in call

xcodeIn iOS 8 SDK Development, the use of a closure to act on a response from the user when we ask them to use their twitter account produces the following compilation error:

Extra argument 'completion' in call

The error is misleading because there is no “extra argument” in the call to “accountStore.requestAccessToAccountsWithType“. Below the problem is on line #6. See it?

func reloadTweets() {
  let accountStore = ACAccountStore()
  let twitterAccountType = accountStore.accountTypeWithAccountTypeIdentifier(ACAccountTypeIdentifierTwitter)
  accountStore.requestAccessToAccountsWithType(twitterAccountType, options: nil, completion:
    { (granted: Bool, error: NSError) -> Void in
      if (!granted) {
        println("account access not granted")
      } else {
        println("account access granted")

It does not stand out and I only figured it out because I recognized the closure for ‘completion:‘ is a type-alias to ‘ACAccountStoreRequestAccessCompletionHandler‘, which is documented as:

typealias ACAccountStoreRequestAccessCompletionHandler = (Bool, NSError!) -> Void

Adding the exclamation mark (!) after NSError to force unwrap solve the error. The confusing part to me is NSError is not an optional type (at least it is not clear in the definition of NSError and I am not too familiar with Objective-C). Why does it need to be forced unwrapped? Would appreciate any further explanation on this from anyone watching. 🙂

Posted in Programming, Swift | Leave a comment

[Swift] How to Pass By Reference via The Use of ‘inout’

xcode  When defining a function the keyword ‘inout‘ is used in front of the variable name to denote an in-out parameter, which sets up the function as a kind of “pass-by-reference” function. Note, this is not real pass-by-reference as the variable is still copied within the function, manipulated and the passed back out. 

What is an in-out parameter?
An in-out parameter is a parameter that has the keyword ‘inout‘ at the start of its definition. This parameter is like an alias or reference to the variable in the calling function. Changes made to the inout variable inside the function are retained when the function call completes. For example, we define our function as such:

Look at this function that swaps the values of two variables: swapCEO

func swapCEO(inout person: String, inout withPerson: String) {...}

Where the keyword ‘inout‘ denotes the parameter ‘person‘ and parameter withPerson of type ‘String‘ will have a value passed in and then passed out. The value passed out may or may not be changed, but should it be changed this will be perfectly acceptable.

When the swapCEO function is called, each of its two arguments must have prefixed an ampersand (&), like so:

swapCEO(&appleCEO, &microsoftCEO)

By prefixing an ampersand (&) to our arguments we are indicating the variables passed in may be modified.

Note: It is an error to use the keyword ‘inout‘ in a function definition but not prefix an ampersand(&) to an argument when that function is called.

Let’s See This in Action

We declare two variables to serve as place holders for the names of well known CEO’s. Time Cook the current CEO of Apple is stored in the variable appleCEO and Satya Nadella the current CEO of Microsoft is stored in the variable microsoftCEO.

var appleCEO = "Tim Cook"
var microsoftCEO = "Satya Nadella"

As previously mentioned, to swap the values of our two variables we simple call swapCEO and prefix the ampersand (&) to each of variables.

swapCEO(&appleCEO, &microsoftCEO)

We can now print the variables and see if this worked.

See the full execution from a Playground Session Below



This same concept may be used on any type, not just String, when you need a function to modify its variable parameters.

Posted in Devel | Leave a comment

[Swift] expressions require OS X 10.10 / iOS 8 SDKs or later

xcodeThe successor to Objective-C, Swift was announced by Apple in 2014. Instead of waiting I decided to start learning this language in order to add it to my “bag of tricks” as one of my professors would say. Considering I do not always have a laptop with OSX nearby, my work laptop is Windows, I scoured the internet for a way to have a command-line interface to swift. Something similar to tclsh for TCL or irb for Ruby. What I found was this, but it left me a bit hopeless:

`--> sudo xcode-select -switch /Applications/Xcode.app

``--> lldb --repl

Welcome to Swift!  Type :help for assistance.
println("Hello There!")

error: Swift expressions require OS X 10.10 / iOS 8 SDKs or later.

I guess the above may work in a later version of OS X. But, apparently I need OS X 10.10 or iOS 8 SDKs or later to run swift for the command-line. As of now OS X 10.9 is the latest out and it is what I have, see:

`--> sw_vers 
ProductName:	Mac OS X
ProductVersion:	10.9.5
BuildVersion:	13F34

And, I also have Xcode 6.0.1, see:

`--> xcodebuild -version
Xcode 6.0.1
Build version 6A317

However, it was not until I stumbled upon @swiftLDN twitters page that I learned out how to run swift from the command line. All I needed to do was:

“–> xcrun swift -sdk ios8
<unknown>:0: warning: no such SDK: ‘ios8’
Welcome to Swift! Type :help for assistance.
1> println("Hello There!")
Hello There!

The message about “no such SDK” can be ignored. Apparently, anything can serve as a placeholder after “-sdk”.

Do not get me wrong. Swift works fine in Xcode from the GUI front-end for the current version of OSX and Xcode I have. However, just issuing xcrun swift from the command-line will not cut it just yet.

I hope that help anyone out there.


Posted in General-Tech | Leave a comment

[Futaba] 14SG Transmitter Programming Tips

14SGI came across this very useful video the other day, Futaba 14SG Radio Programming Tips. It is extremely useful for anyone with a Futaba 8FG [Super] or 14SG transmitter. I initially thought the two dials (LD and RD) were useful for pitch and throttle curves, but it just got in the way if they were not properly centered. I find it best to disable them both:




Other useful tips include:

  • Disabling Pitch and Throttle Curve Points
  • Disabling Trims
  • Simplifying Exponential Setup



Posted in General-Tech, Rc | 2 Comments

[Panasonic] Another Television For the Holidays? I Think Not!

panasonic-coverOn October 5th 2011 we purchased our very first flat screen television. After weeks of researching and speaking with colleagues I decided to go with Panasonic. We purchased from the Electronics Expo a Viera 50″ G25 Plasma (TC-P50G25). The whole family was impressed. It was jammed packed with features like an SD Card slot, DLNA for streaming multimedia from our NAS w/ built-in Ethernet to handle all that “Jazz” w/ stunning picture quality. We could not have it any better, but as luck would have it – four months later we had a hairline fracture due to our kids toy hitting the set. Our four year additional warranty – void! To save your eyes on further reading, customer service was the worst!


Called Panasonic and the store we purchased from (Electronics Expo) – no one would help!

A few months later, I figured – eh, why not? It was accidental damage, let’s just stick with Panasonic. But this time I decided to purchase from Amazon. We went with what was essentially a newer version of our previous set, a Viera TC-P50GT30. It was a bit thinner and I figured, eh why not get a screen proctor? So I did and purchased a TV Armor TV Screen Protector plexiglass. A good year went by and I felt really good about the purchase. A little less than two years and the darn thing would not turn on! However, we were greeted with the friendly “seven blinks of death”. Go figure! And this time I did not purchase the extended warranty – _all_types_of_expletives_here_ !! They don’t make televisions like they used to, eh? The older CRTs lasted decades.

This time around I am not in the mood to purchase another television and if it ends up happening it definitely will not be Panasonic.But, I think I may be able to save the day. Why? I picked up the Panasonic Plasma Technical Guide and Troubleshooting Flowchart and I am feeling lucky. On slide 48 of the pdf is the start of troubleshooting the 7 blinks failure. In short, the problem is either from a faulty SC, SU – SD (these are a pair) or SS board from what I have read and saw on you tube. I could be wrong.7-blinks


I did open up the set and located the boards that I think may be the problem as can be seen below:



The next step is to locate and purchase the necessary spare parts. Fingers crossed and I will post my findings good or bad. Say tuned!

Posted in General-Tech | 2 Comments

[RC Heli] How I got hooked on RC Helicopters

Devo 12S w/ case

Devo 12S w/ case

Devo 12S?, Mini-cp? Well, if you have been reading my blog for some time this is definitely a post out-of-the-norm, but I think you should no longer be surprised to see posts about rc helicopters here. I caught the “heli mania flu” while I had free time on paternity leave last month (thanks to my wife and grandparents!). The darn sickness will not go away – all I think about is developing the skills necessary to fly like this guy! It all started when my wife bought our five year old a 20$ cheap ccoaxial toy helicopter from the local store. After setting it up, testing it out and quickly mastering how to fly without crashing within a day or two I started reading about rc helicopters all over the net and watching all the YouTube video I could until I decided to buy one for myself.

This my friends is how I ended up with the “heli mania flu” and it will not go away! Well, not yet at least. 🙂 Since my addiction I have purchased:

It all added up to a pretty penny, but I will not complain – not all the money you spend will be for a good cause! I would not have bought the phoenix simulator with the dx5e, but it was said it would not work with the DEVO 12S without a special adapter which I also ordered. Well, my son how has in own 5-channel transmitter to practice. However, to my surprise the DEVO 12S worked fine with the Phoenix Simulator software without a single hiccup and without the special adapter I ordered. I was able to fly all model helicopters and planes.

I look forward to more posts on the DEVO12S since I am completely fascinated with it. I plan to post the setup up configuring Phoenix simulator with the DEVO 12S and how to update the firmware so it can fly with non-Walkera helicopters. I am still a noob at flying rc helicopters, but below are some really useful information that helped increase my knowledge about the hobby, though I still have much, much more to learn!

For now I will stick with the simulator until I master my orientations, circuits, lazy-8s and all the other basic maneuvers. Let’s just say the mini cp will now be used for dissection. Either the mini cp is just too fragile or I crashed it way too many times! 🙂

Check out this 11 year old, Tal Roglit, fly the Raptor G4 E720.

Posted in General-Tech | 1 Comment