<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Musings In The Clouds - Medium]]></title>
        <description><![CDATA[Mostly cloud and tech based rants and other ramblings - Medium]]></description>
        <link>https://medium.com/musings-in-the-clouds?source=rss----cd9deb0789fe---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Musings In The Clouds - Medium</title>
            <link>https://medium.com/musings-in-the-clouds?source=rss----cd9deb0789fe---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 11:04:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/musings-in-the-clouds" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Source and Sink for Kafka and PubSub]]></title>
            <link>https://medium.com/musings-in-the-clouds/source-and-sink-for-kafka-and-pubsub-2a3565ce9578?source=rss----cd9deb0789fe---4</link>
            <guid isPermaLink="false">https://medium.com/p/2a3565ce9578</guid>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[pub-sub]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <dc:creator><![CDATA[Justin Grayston]]></dc:creator>
            <pubDate>Mon, 02 Jul 2018 11:17:01 GMT</pubDate>
            <atom:updated>2018-09-05T14:54:38.819Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*D0Xk8hmBB3zuyhGl1TDu3A.png" /></figure><p>With the <a href="https://cloud.google.com/blog/big-data/2018/05/google-cloud-platform-and-confluent-partner-to-deliver-a-managed-apache-kafka-service">announcement of the Google Cloud Confluent managed Kafka offering</a>, it has never been easier to utilise Google Cloud’s great data tools with Kafka. You may choose to use the Apache Beam Kafka.io connector to go straight into Dataflow, but this may not always be the right solution. Whether your Kafka is in the Cloud or on premise, you may just want to push to a sub set of PubSub topics. Why? Well you may the flexibility of having PubSub be your GCP event notifier. Then, you could not only choreograph Dataflow jobs, but also trigger Cloud Functions off of the topics.</p><p>So how do you get messages from Kafka to PubSub? This is where the <a href="https://github.com/GoogleCloudPlatform/pubsub/tree/master/kafka-connector">PubSub Kafka Connector</a> comes in handy. In this article I’ll walk through the basic steps to get this working on Google Cloud.</p><p>The connector itself allows two way event traffic, Kafka to PubSub and PubSub to Kafka. This could be really handy if you have Kafka and want to connect with applications and data running in the cloud or even with devices via <a href="https://cloud.google.com/iot-core/">IoT Core</a>.</p><p>To run the example I’ll use Cloud Launcher to launch a single instance of Kafka, the go through the steps so we have event messages flying between the two. It is likely that you will be running a cluster, but for this I am going to keep things simple (and cheaper).</p><h4>Before we begin</h4><p>You will need a Google Cloud project with either the trial allowance or billing set up. Running this example shouldn’t cost too much (hourly rate in the launcher currently states around $0.043 at time of writing), but you will need to remember to tear it down afterwards!</p><h4>Spin up your Kafka Instance</h4><p>Go to <a href="https://console.cloud.google.com/launcher/browse?q=Kafka">Cloud Launcher</a> and search for Kafka. In this example I just use the Google provided Kafka, but feel free to us Bitnami if you wish.</p><p>Click on the tile with Kafka on, then the blue Launch On Compute Engine button.</p><p>You should see something like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*urJf-6_Zei_KSDMh5zP6fw.png" /><figcaption>Cloud Launcher — Kafka Deployment</figcaption></figure><p>I just changed the region so it was closer to me. When ready, simply click “Deploy” button. This will then take you to Deployment Manager as it spins and configures the VM. It shouldn’t take long. When done you can click SSH to connect to the VM. When you come back to the console, the VM can be found under Deployment Manager and under Compute Engine.</p><p>You will find all the Kafka scripts in /opt/kafka/bin and you will also notice the config directory /opt/kafka/config this is where all your config properties are set.</p><p>First off, lets create a directory for us to place connect plugins.</p><pre>sudo mkdir connectors</pre><h4>Compile the connector</h4><p>Now you could do this on the VM if you want to add a bunch of dependencies, but I wouldn’t do that. Let’s keep our Kafka clean. I did this on my Mac, but you could easily do this in cloud shell. You can start a cloud shell session by clicking on the cmd prompt icon at the top of the Google Cloud Console UI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/287/1*NM_59iLn-Ls5vEb6MqF3bA.png" /></figure><p>Clone the Github repo <a href="https://github.com/GoogleCloudPlatform/pubsub.git">https://github.com/GoogleCloudPlatform/pubsub.git</a></p><p>Then navigate into the kafka-connector directory.</p><p>Note that if working on a Mac you will need to update the io.netty classifier from ${os.detected.classifier}in pom.xml tolinux-x86_64. This is only required if you are compiling the connector on a different OS than the target host. In this case, compiling on macOS and running on a Linux VM.</p><pre>mvn package</pre><p>In the target directory you should now have cps-kafka-counnector.jar, this now needs copying to the VM. You can easily do this with the gcloud command.</p><pre>gcloud compute scp ./target/cps-kafka-connector.jar  kafka-1-vm:~/ --zone europe-west3-c</pre><p>Obviously change the zone to the one your are using. Then in the SSH session window, simply move that to /opt/kafka/connectors</p><pre>sudo mv ./cps-kafka-connector.jar /opt/kafka/connectors/</pre><h4>Adding the connector configs</h4><p>Before we start the connect service, lets get our config files in place. In the PubSub repo kafka-connector directory you will see draft configs. We are going to place this in the config directory of our Kafka VM and edit them so they know which topics to connect too. You can find pre-created configs with the topics we are going to use later <a href="https://gist.github.com/justingrayston/805d6f900ab6930569b94c657fd3b704">here</a>.</p><p>On the VM make sure you are in /opt/kafka/config/ then create the sink config.</p><pre>sudo vi cps-sink-connector.properties</pre><p>Then paste the config, either the vanilla version or the pre-completed one from the gist.</p><p>The name property must be unique, this can allow you to to set up multiple bindings to many PubSub topics. The rest of the configs are nicely explained in the <a href="https://github.com/GoogleCloudPlatform/pubsub/tree/master/kafka-connector#cloudpubsubconnector-configs">docs</a>. For this sink we are going to set topics=to-pubsub and cps.topic=from-kafka and of course set your Google Cloud project you are using in cps.project</p><p>Now we can do the same for the source connector.</p><pre>sudo vi cps-source-connector.properties</pre><p>As with sink, set the cps.project to your Google Cloud project. Then we will set csp.subscription=to-kafka-sub this tells the connector which PubSub subscription to subscribe to and then push into the Kafka topic set by kafka.topic=from-pubsub</p><p>We are nearly there, but first we need to set up the topics and subscriptions.</p><h4>Set up Topics and Subscriptions in PubSub</h4><p>For this we will use gcloud command line tool, but you can do all this via the console UI too.</p><p>Create the pubsub topics.</p><pre>gcloud pubsub topics create to-kafka from-kafka</pre><p>You can verify they are set up.</p><pre>gcloud pubsub topics list</pre><p>Now we need to create the subscription for the to-kafka topic.</p><pre>gcloud pubsub subscriptions create to-kafka-sub --topic=to-kafka --topic-project=[CHANGE TO YOUR PROJECT]</pre><p>Again, you can verify it is set up.</p><pre>gcloud pubsub subscriptions list</pre><h4>Create the Kafka topics</h4><p>Create the topic that will send to PubSub</p><pre>kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic to-pubsub</pre><p>Create the topic that will receive from PubSub</p><pre>kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic from-pubsub</pre><h4>Created the Service Count and Provide credentials</h4><pre>gcloud iam service-accounts create kafka-pubsub</pre><p>You have now created a service account. Now we need to set the role of that account so it can use PubSub.</p><p>You can now simply find this user in the Cloud Console IAM UI and assign PubSub admin role or do the following.</p><pre>gcloud projects get-iam-policy [CHANGE TO YOUR PROJECTID]  --format json &gt; iam.json</pre><p>Then in the the bindings array add your service account with the role of PubSub admin to the iam.json</p><pre>{<br>  &quot;members&quot;: &quot;serviceAccount:kafka-pubsub@[YOUR SERVICE ACCOUNT ADDRESS]&quot;,<br>  &quot;role&quot;: &quot;roles/pubsub.admin&quot;<br>},</pre><p>Then you can use the following to set the role for the service account.</p><pre>gcloud projects set-iam-policy [CHANGE TO YOUR PROJECTID] iam.json</pre><p><strong><em>Note: The following is for example purposes only and is simulating a VM outside of Google Cloud. Do not use for production. Also, don’t forget that if you are running on Google Cloud, you can </em></strong><a href="https://cloud.google.com/docs/authentication/production#obtaining_credentials_on_compute_engine_kubernetes_engine_app_engine_flexible_environment_and_cloud_functions"><strong><em>use the VM’s service account</em></strong></a><strong><em> which means no download of secrets.</em></strong></p><p>Our Kafka VM now needs to have the credentials so it can connect to PubSub.</p><pre>gcloud iam service-accounts keys create google-pubsub-key.json --iam-account=[SERVICE ACCOUNT EMAIL]</pre><p>Then copy these credentials to the VM</p><pre>gcloud compute scp ./google-pubsub-key.json kafka-1-vm:~/google-pubsub-key.json --zone=europe-west3-c</pre><p>This will now be in your home director. I just then created a bash script to start the connect service. This is in the <a href="https://gist.github.com/justingrayston/805d6f900ab6930569b94c657fd3b704">gist</a> as the run-connect.sh file.</p><p>Just place that in the home directory.</p><pre>sudo vi run-connect.sh</pre><p>Paste the contents from the gist and edit the path to the credentials file.</p><p>Allow the file to be executed.</p><pre>sudo chmod +X run-connect.sh</pre><h4>Start the connect service</h4><p>On the Kafka VM, the Kafka service itself should already be running as part of the start script.</p><p>For this test we are going to just start a standalone service. Basically you pass it the properties files for the service to use. It will then look for the correct connector to use.</p><p>This is what we are doing with the run-connect.sh script.</p><p>Before we can kick of the service we need to tell Kafka Connect where to find plugins. To do that we can simply edit the `<strong>/opt/kafka/config/connect-standalone.properties` </strong>file.</p><p>Just uncomment the plugin path, close to the bottom of the file and set it to the following.</p><pre>plugin.path=/opt/kafka/connectors</pre><p>Also in that file, disable the key value converter for schema enforcement.</p><pre>key.converter.schemas.enable=false<br>value.converter.schemas.enable=false</pre><p>This disables the schema enforcement, which is fine for this example as it keeps things simple, but you will may well want to have this enabled in production. You can do this on a per connector worker basis.</p><h4>More about converters</h4><pre>key.converter=org.apache.kafka.connect.storage.StringConverter<br>value.converter=org.apache.kafka.connect.json.JsonConverter</pre><p>The key.converter.schemas.enable and value.converter.schemas.enable are relevant for the JSON converter, but may not be relevant for other converters.</p><p>The converter used needs to match the type of data you want to transmit. This could well be different for each sink and source. The data is either inbound or outbound from Kafka. If it is inbound it is important that the converter matches the inbound format, if outbound it should match the format for the destination. The simplest converter (and often the right one to use) is org.apache.kafka.connect.converters.ByteArrayConverter. This just takes the raw data from one and moves those bytes to the other.</p><pre>key.converter=org.apache.kafka.connect.converters.ByteArrayConverter<br>value.converter=org.apache.kafka.connect.converters.ByteArrayConverter</pre><p>For this though we will stick with the JSON and String converters.</p><p>Now if you run ./run-connector.sh it will fire up the connect service and be ready to test. If you get errors, make sure you have the full path to the credentials specified.</p><h3>Testing it out</h3><p>Now we are going to do a quick manual test. Open up a new SSH connection to the Kafka VM. We’ll use that to quickly create a producer to post data into the kafka topic destined for pubsub, and then check with gcloud it has landed. Then we will swap the process, sending data from pubsub to Kafka.</p><p>With your second SSH session started, start a Kafka producer and add some messages to the topic.</p><pre>kafka-console-producer.sh --broker-list localhost:9092 --topic to-pubsub</pre><p>Then just type the messages at the cursor in json format.</p><pre>&gt; {&quot;message&quot;: &quot;hello&quot;}<br>&gt; {&quot;message&quot;: &quot;big world&quot;}</pre><p>Now we’ll just use gcloud to pull those messages.</p><p>Create a subscription.</p><pre>gcloud pubsub subscriptions create from-kafka --topic=from-kafka</pre><p>Then pull the messages that should be in there from Kafka.</p><pre>gcloud pubsub subscriptions pull from-kafka --auto-ack --limit=10</pre><p>You should see a table with the data, message_id and attributes with to items in it.</p><p>Now lets test the other way.</p><p>CTRL +c to exist the producer. Then let’s start a consumer to test data coming the other way.</p><pre>kafka-console-consumer.sh --bootstrap-server=localhost:9092 --value-deserializer=org.apache.kafka.common.serialization.StringDeserializer --topic from-pubsub</pre><p>Then using gcloud publish a message. Here we are using attributes to create a JSON data.</p><pre>gcloud pubsub topics publish to-kafka  --attribute=data=hello</pre><p>Should result in the below showing up in the consumer.</p><pre>{&quot;message&quot;:&quot;&quot;,&quot;data&quot;:&quot;hello&quot;}</pre><p>So there we have it, data is now travelling in both directions. As noted above, this <strong>is just an example</strong>, but should help you figure step through the basics to get going. Armed with this knowledge and experience, if you want to set this up on a Kafka cluster then <a href="https://powerspace.tech/how-to-stream-data-from-google-pubsub-to-kafka-with-kafka-connect-dbef1c340a76">check out this article</a>, which also has shows you how to set up a GUI for Kafka Connect.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2a3565ce9578" width="1" height="1" alt=""><hr><p><a href="https://medium.com/musings-in-the-clouds/source-and-sink-for-kafka-and-pubsub-2a3565ce9578">Source and Sink for Kafka and PubSub</a> was originally published in <a href="https://medium.com/musings-in-the-clouds">Musings In The Clouds</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting up and running with Firebase + Angular + Material]]></title>
            <link>https://medium.com/musings-in-the-clouds/getting-up-and-running-with-firebase-angular-material-eaeacc7832dc?source=rss----cd9deb0789fe---4</link>
            <guid isPermaLink="false">https://medium.com/p/eaeacc7832dc</guid>
            <category><![CDATA[angularfire2]]></category>
            <category><![CDATA[angular-material]]></category>
            <category><![CDATA[angular2]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[firebase]]></category>
            <dc:creator><![CDATA[Justin Grayston]]></dc:creator>
            <pubDate>Thu, 31 May 2018 10:15:55 GMT</pubDate>
            <atom:updated>2018-05-29T21:36:36.326Z</atom:updated>
            <content:encoded><![CDATA[<h3>~tldr~</h3><p>Fastest way to get up and running just clone this repo <a href="https://github.com/justingrayston/angular-firebase-material-quickstart">https://github.com/justingrayston/angular-firebase-material-quickstart</a> then run npm install, providing you have node and npm installed. If not see below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_p-xSamqef71sErIbqhJlA.png" /></figure><p>The object here is to give a quick manual set up to get up and running with a Firebase backend Angular web app using Material components.</p><p>Before starting go to either <a href="https://firebase.google.com/">Firebase</a> or <a href="https://console.cloud.google.com/">Google Cloud</a> and create a project.</p><p>Then, you need to have <a href="https://nodejs.org/en/">Node</a> installed on your machine. I personally do most of my dev on a Mac, and consequently use <a href="https://brew.sh/">Homebrew</a>. I appreciate that is a love / hate thing. I have historically had no issues with it (most of the time).</p><p>Once you have Node and npm available on the cmd line, we are good to get going.</p><p>First install the angular cli.</p><pre>npm i -g @angular/cli</pre><p>Here the i stands for install -g instructs npm to install it globally. This is equivalent to,</p><pre>npm install -g @angular/cli</pre><p>Now install the firebase tools cli.</p><pre>npm i -g firebase-tools </pre><p>You can also combine that into one call.</p><pre>npm i -g @angular/cli firebase-tools</pre><p>You can now verify that you have those installed ok. Open a new terminal window. which ng and which firebase should result in a file path to the executable.</p><p>Create the Angular app using the Angular cli.</p><p>In the directory where you want your app and repo folder to be created run the following. So if you you have a /Users/justin/development/ directory and you want your app to be created in there you must be in the development directory, don’t pre-create the folder.</p><p>Run the following.</p><pre>ng new angular-firebase-material-quickstart</pre><p>This will create the angular-firebase-material-quickstart directory and build out a scaffold app.</p><p>Initialise firebase.</p><pre>firebase init</pre><p>This will run through the set up points. For this example we are going to select Firestore, Hosting and Storage. Feel free to choose what you like. If it was a production app, I often like to have a separate repo for the security rules and functions. Just to separate concerns and make review and change clearer.</p><p>Then you will be prompted to pick the default project. Choose the one you created at the start.</p><p>Then it will prompt you for the config files. Accept the default if you like for the security rules and indexes, but for the hosting use dist not public. This is because angular cli builds to the dist directory. This is what firebase will serve from once deployed.</p><p>Choose Yes for “Configure as a single-page app”. This creates the rewrite rules to index.html.</p><p>Choose default for storage rules and you are done.</p><p>You should have file structure something like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*VT1sLWxTjCdslETG-qvOgw.png" /></figure><p>Before we start changing code you can change to use <em>scss </em>instead of <em>css</em>. This is totally optional though, but my preference.</p><p>Open <em>angular.json</em>, this is the config file for angular-cli. Change all references to <em>css</em> to <em>scss.</em></p><pre>// change all (including in test) from</pre><pre>&quot;styles&quot;: [</pre><pre>&quot;src/styles.css&quot;</pre><pre>],</pre><pre>// to</pre><pre>&quot;styles&quot;: [</pre><pre>&quot;src/styles.scss&quot;</pre><pre>]</pre><p>Then rename <em>src/styles.css </em>and <em>src/app/app.component.css </em>to use the <em>.scss </em>file extension. In <em>src/app/app.component.ts</em> now fix the reference from the old css file to the new one. It should now look like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*dZZvoSiy9PjN4tNgu5j4zw.png" /></figure><p>You should be able to run the app locally with ng serve . The angular app will now be compiled and run on a server. It will refresh if you make code changes. By default this is now running on <a href="http://localhost:4200/">http://localhost:4200</a></p><p>As at time of writing, this looks something like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/648/1*KwyOUe1HJdE_aFS39b063Q.png" /></figure><p>OK, we are part way there. Easiest way to work with Angular and Firebase is use <a href="https://github.com/angular/angularfire2">AngularFire2</a>.</p><pre>npm i firebase angularfire2 --save</pre><p>The save flag here means that it will be saved to <em>package.json</em> as dependency. This also installed the firebase package at the same time.</p><p>Now to get all the set up out the way, let’s go ahead and and install <a href="https://material.angular.io/">Angular Material</a>.</p><pre>npm i --save @angular/material @angular/cdk @angular/animations</pre><p>Now if you used AngularJS with the original Angular Material, then you most likely used the flex layout directives. This has now been broken out into its own module. Install it with,</p><pre>npm i --save @angular/flex-layout</pre><p>Operationally it work very similar to the old Angular Material flex attributes.</p><pre>&lt;section class=&quot;c-posts&quot; fxLayout=&quot;column&quot; fxLayoutAlign=&quot;center center&quot;&gt;<br>...<br>&lt;/section&gt;</pre><p>However you should take a dive through the <a href="https://github.com/angular/flex-layout/wiki/API-Documentation">API docs here</a>.</p><h4>Configuring Firebase with AngularFire</h4><p>Instructions are in the documentation, but here is a abbreviated version.</p><p>You go to <a href="https://console.firebase.google.com/">https://console.firebase.google.com/</a> and into the project you created. Then click on project settings in the cog icon.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NRce6qBTRhop1AcmSeeF3A.png" /></figure><p>Then click on the red web app circle to get your config JSON.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bvuKksT9KoeS5fLrZqa5Qw.png" /></figure><p>Copy the config JSON. Open up src/environments/environment.ts and create a firebase property to the object, paste the config JSON here. Remove the semi-colon and change the double quotes to singles.</p><p>It should look along the lines of this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*XTxObnNUkxmcRtyIIr4arw.png" /></figure><p>Copy the firebase property to <em>environment.prod.ts </em>too.</p><p>Now open src/app/app.module.ts , this is where we are going to initialise the firebase app. Pulling straight from the AngularFire docs. Copy the code below and replace the contents of <em>app.module.ts</em>.</p><pre>import { BrowserModule } from &#39;@angular/platform-browser&#39;;<br>import { NgModule } from &#39;@angular/core&#39;;<br>import { AppComponent } from &#39;./app.component&#39;;<br>import { AngularFireModule } from &#39;angularfire2&#39;;<br>import { environment } from &#39;../environments/environment&#39;;<br><br>@NgModule({<br>  imports: [<br>    BrowserModule,<br>    AngularFireModule.initializeApp(environment.firebase)<br>  ],<br>  declarations: [ AppComponent ],<br>  bootstrap: [ AppComponent ]<br>})<br>export class AppModule {}</pre><p>Test your app with ng serve , the app should still load and show the page we saw before.</p><h3>Use a Material component</h3><p>We are going to add a <a href="https://material.angular.io/components/toolbar/overview">toolbar</a> to the top of the main template.</p><p>First up add a prebuilt theme to the main <em>stlyes.scss.</em></p><p>Add the following to the top of the file. (I also reset the margin on the body here).</p><pre>@import &quot;~@angular/material/prebuilt-themes/indigo-pink.css&quot;;</pre><pre>body {<br>  margin: 0;<br>}</pre><p>Now in src/app/app.module.ts import MatToolbarModule.</p><pre>import { BrowserModule } from &#39;<a href="http://twitter.com/angular/platform-browser">@angular/platform-browser</a>&#39;;<br>import { NgModule } from &#39;<a href="http://twitter.com/angular/core">@angular/core</a>&#39;;<br>import { AppComponent } from &#39;./app.component&#39;;<br>import { AngularFireModule } from &#39;angularfire2&#39;;<br>import { MatToolbarModule } from &#39;<a href="http://twitter.com/angular/material">@angular/material</a>/toolbar&#39;;<br>import { environment } from &#39;../environments/environment&#39;;</pre><pre><a href="http://twitter.com/NgModule">@NgModule</a>({<br>  imports: [<br>    BrowserModule,<br>    AngularFireModule.initializeApp(environment.firebase),<br>    MatToolbarModule<br>  ],<br>  declarations: [AppComponent],<br>  bootstrap: [AppComponent]<br>})<br>export class AppModule { }</pre><p>Then in the template for AppComponent, src/app/app.component.html add the selector and some content like so.</p><pre>&lt;mat-toolbar color=&quot;primary&quot;&gt;<br>    &lt;span&gt;Super Funky App&lt;/span&gt;<br>&lt;/mat-toolbar&gt;</pre><p>If you are still running the server your web page should have refreshed, if not restart it with ng serve.</p><p>You should be seeing something like this…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*76Ww71Uk-0g6ed7tFXvoTw.png" /></figure><h3>Deploy the App</h3><p>In <em>package.json</em> under scripts add “deploy”: “ng buid — prod &amp;&amp; firebase deploy”</p><p>So scripts should now look like</p><pre>&quot;scripts&quot;: {<br>    &quot;ng&quot;: &quot;ng&quot;,<br>    &quot;start&quot;: &quot;ng serve&quot;,<br>    &quot;build&quot;: &quot;ng build&quot;,<br>    &quot;test&quot;: &quot;ng test&quot;,<br>    &quot;lint&quot;: &quot;ng lint&quot;,<br>    &quot;e2e&quot;: &quot;ng e2e&quot;,<br>    &quot;deploy&quot;: &quot;ng build --prod &amp;&amp; firebase deploy&quot;<br>  },</pre><p>Now you can just deploy simply with npm run deploy, your app will build for production and then deploy to firebase hosting.</p><p>Thats it for now. Time to get stuck into the <a href="https://github.com/angular/angularfire2/tree/master/docs">AngularFire</a> and <a href="https://material.angular.io/components/categories">AngularMaterial</a> docs and start building!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eaeacc7832dc" width="1" height="1" alt=""><hr><p><a href="https://medium.com/musings-in-the-clouds/getting-up-and-running-with-firebase-angular-material-eaeacc7832dc">Getting up and running with Firebase + Angular + Material</a> was originally published in <a href="https://medium.com/musings-in-the-clouds">Musings In The Clouds</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From sw-precache to workbox]]></title>
            <link>https://medium.com/musings-in-the-clouds/from-sw-precache-to-workbox-23c9079d14de?source=rss----cd9deb0789fe---4</link>
            <guid isPermaLink="false">https://medium.com/p/23c9079d14de</guid>
            <category><![CDATA[service-worker]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Justin Grayston]]></dc:creator>
            <pubDate>Wed, 07 Jun 2017 21:13:13 GMT</pubDate>
            <atom:updated>2017-06-07T21:30:52.919Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JVP9rFAJ1sGeo56GgXHgNA.png" /><figcaption><a href="https://pixabay.com/en/close-up-code-coding-computer-2178341/">https://pixabay.com/en/close-up-code-coding-computer-2178341/</a></figcaption></figure><p>Recently Google announced <a href="https://workboxjs.org/">workbox</a>, which was formerly sw-helpers. It is a second pass at providing tools for service workers required for creating PWAs (progressive web apps). It is modular approach so you can pick and choose what you want to use or include the whole shebang if you want.</p><p>I have a few Angular PWAs where I had just used <a href="https://github.com/GoogleChrome/sw-precache">sw-precache</a> (one of the original tools) to create an App Shell so the apps work offline.</p><p>The simplest implementation is to have a config file that sw-precache uses to scan the built app and build a manifest that can be cached.</p><pre>module.exports = {<br>  navigateFallbackWhitelist: [ /^\/bio/,/^\/posts/ ],<br>  navigateFallback: &#39;/index.html’,<br>  stripPrefix: &#39;dist’,<br>  root: &#39;dist/’,<br>  staticFileGlobs: [<br>    &#39;dist/index.html’,<br>    &#39;dist/**.js’,’dist/**.css’,<br>    &#39;dist/assets/images/**/*’,<br>    &#39;dist/assets/fonts/**/*&#39;<br>  ]<br>};</pre><p>This works really nicely, and the CD build runs sw-precache before deploying. One thing to note is the “navigateFallbackWhitelist” property, which is required to route requests to the index.html (in this example <em>/bio</em> and <em>/posts</em> will serve index.html), this is obviously required for for a single page web app.</p><p>So now let’s rework this using workbox.</p><p>With workbox they’ve made it more modular, with workbox-sw being the Swiss Army knife in the tool box. So here is the workbox version of sw.js</p><pre>importScripts(&#39;/node_modules/workbox-sw/build/workbox-sw.prod.v1.0.0.js&#39;);</pre><pre>const workboxSW = new WorkboxSW();</pre><pre>workboxSW.precache([]);</pre><pre>workboxSW.router.registerNavigationRoute(&#39;index.html&#39;, {<br>  whitelist: [/^\/bio/,/^\/post/ ]<br>});</pre><pre>workboxSW.router.registerRoute(<br>  &#39;/api/recent/&#39;, workboxSW.strategies.networkFirst()<br>);</pre><p>Let’s step through.</p><p>Initialise a new WorkboxSW instance.</p><pre>const workboxSW = new WorkboxSW();</pre><p>Then comes the app shell pre-cache. Note how this is an empty array. We’ll use workbox-build a little later to dynamically build the manifest. You shouldn’t hard code this.</p><pre>workboxSW.precache([]);</pre><p>Next is the replacement for the navigation whitelist. You register a navigationRoute which is basically, “given this regex match, alias it to this known route”. So here a refresh on the <em>/bio</em> and <em>/post</em> routes will load index.html.</p><pre>workboxSW.router.registerNavigationRoute(&#39;index.html&#39;, {<br>  whitelist: [/^\/bio/,/^\/post/ ]<br>});</pre><p>The next bit is an addition to the original sw-precache example. This sets a cache policy for a given url or regex match.</p><p>Here were are registering the route <em>/api/recent</em> to serve from the network first, if the browser is offline then serve from cache if exists.</p><pre>workboxSW.router.registerRoute(<br>  &#39;/api/recent/&#39;, workboxSW.strategies.networkFirst()<br>);</pre><p>Note you can use registerRoute to cache CDN or cross origin requests.</p><pre>workboxSW.router.registerRoute(<br>  new RegExp(&#39;^https://my.cdn/bucket/images/&#39;),<br>  workboxSW.strategies.networkFirst()<br>);</pre><p>For basic caching, thats it. Now there is a <a href="https://workboxjs.org/get-started/webpack">webpack</a> plugin and a simple guild to adding it to <a href="https://workboxjs.org/get-started/gulp">Gulp</a> if that’s your thing. However, I just have file that is run as part of my package.json script by the CI/CD runner build job.</p><p>This is the step I mentioned earlier that creates the manifest for the App Shell. Obviously this should happen after you have built and bundled your app. This uses the workbox-build module. Then use the injectManifest method which will replace the empty precache manifest array.</p><pre>workboxSW.precache([]);// &lt;- This is replaced with the manifest.</pre><p>…to a manifest based on the glob patters passed to injectManifest. These reads the swSrc and writes it to the swDest path.</p><pre>const swBuild = require(&#39;workbox-build&#39;);</pre><pre>swBuild.injectManifest({</pre><pre>globDirectory: &#39;./dist/&#39;,</pre><pre>globPatterns: [<br>  &#39;index.html&#39;,<br>  &#39;favicon.ico&#39;,<br>  &#39;**/*.js&#39;,<br>  &#39;*.bundle.css&#39;,<br>  &#39;**.webapp&#39;,<br>  &#39;assets/images/**/*&#39;,<br>  &#39;assets/styles/**/*&#39;<br>],<br>  swSrc: &#39;./src/sw.js&#39;,<br>  swDest: &#39;./dist/sw.js&#39;,<br>}).then(() =&gt; {<br>  console.log(&#39;Build manifest generated&#39;);<br>}).catch((err) =&gt; {<br>  console.error(err);<br>});</pre><p>Note that the generated manifest creates revisions, used in the cache store, so only if the files are changed will it cause them to be downloaded.</p><p>I am currently experimenting with other features of workbox and I’ll aim to add a few more posts about it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=23c9079d14de" width="1" height="1" alt=""><hr><p><a href="https://medium.com/musings-in-the-clouds/from-sw-precache-to-workbox-23c9079d14de">From sw-precache to workbox</a> was originally published in <a href="https://medium.com/musings-in-the-clouds">Musings In The Clouds</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why last week’s Firebase hosting announcement matters]]></title>
            <link>https://medium.com/musings-in-the-clouds/why-last-weeks-firebase-hosting-announcement-matters-64da69d4a369?source=rss----cd9deb0789fe---4</link>
            <guid isPermaLink="false">https://medium.com/p/64da69d4a369</guid>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Justin Grayston]]></dc:creator>
            <pubDate>Tue, 23 May 2017 12:36:19 GMT</pubDate>
            <atom:updated>2017-05-23T08:10:42.807Z</atom:updated>
            <content:encoded><![CDATA[<p>This week at Google I/O, Firebase announced that Firebase hosting could now not only serve your static content, but also proxy to a <a href="https://firebase.google.com/docs/hosting/functions">cloud function</a>.</p><p>For example, this means you could have <em>https://my-example.firebaseapp.com/api/* </em>route through to a cloud function which then handled those requests. This cloud function will scale automatically based on load. It will shrink back again when there is no load. You only pay for what you use. Almost zero config.</p><p>This enables you to be able to create an app and abstract away all infrastructure concerns. OK, depending on how you grow and what your requirements are you may end up having other services running somewhere else on GCP, but from zero to a product in user’s hands, <strong><em>this really makes things simple</em></strong>.</p><p>I’ve been using Firebase for a while now, and often there is a need for some server side logic that you don’t want in the client. I’ve been using Google App Engine Flex with the NodeJS runtime for creating these services. One thing that I’ve noticed is the cost. While still being very affordable, it is noticeably more than GAE standard and always has an instance kicking around even when there is no traffic. So a staging version of the service costs, when everyone is asleep. Now I can move that across to a Firebase Cloud Function and it will be only on demand.</p><p>The other thing to mention, is that to operate on the Firebase Real Time Database form my Flex service I need to use the Admin SDK and a service account, from a cloud function all the credentials and hooks into authentication are provided for you.</p><p>Your functions can be as complicated or simple as you like. Note that the firebase-functions client is already set up to handle requests.</p><pre>const functions = require(&#39;firebase-functions&#39;);<br><br>exports.bigben = functions.https.onRequest((req, res) =&gt; {<br>  const hours = (new Date().getHours() % 12) + 1 // london is UTC + 1hr;<br>  res.status(200).send(`&lt;!doctype html&gt;<br>    &lt;head&gt;<br>      &lt;title&gt;Time&lt;/title&gt;<br>    &lt;/head&gt;<br>    &lt;body&gt;<br>      ${&#39;BONG &#39;.repeat(hours)}<br>    &lt;/body&gt;<br>  &lt;/html&gt;`);<br>});</pre><p>Or you could set up an ExpressJs server if you wanted to, here is an example from the <a href="https://github.com/firebase/functions-samples/tree/master/authorized-https-endpoint">Github repo</a>.</p><p>Whilst you could respond to requests before this announcement you would have to hit the function directly. Now you can set up your Firebase hosting on your custom domain and serve your api right from there.</p><p>You can find out more about Cloud Functions for Firebase <a href="https://firebase.google.com/docs/functions/">here</a>.</p><p>Configuration for hosting is found <a href="https://firebase.google.com/docs/hosting/functions">here</a>.</p><p>I am not the only one that thinks that Firebase is a pretty sweet platform. Checkout these <a href="https://medium.com/@jthegedus/exploring-cloud-functions-for-firebase-cdf62297349e">posts</a> by <a href="https://medium.com/u/ebcc51f1e782">James Hegedus</a>. I found <a href="https://medium.com/@jthegedus/graphql-server-on-cloud-functions-for-firebase-ae97441399c0">this one about GraphQL Server</a> as a function pretty interesting.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=64da69d4a369" width="1" height="1" alt=""><hr><p><a href="https://medium.com/musings-in-the-clouds/why-last-weeks-firebase-hosting-announcement-matters-64da69d4a369">Why last week’s Firebase hosting announcement matters</a> was originally published in <a href="https://medium.com/musings-in-the-clouds">Musings In The Clouds</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Developing your application with Kubernetes]]></title>
            <link>https://medium.com/musings-in-the-clouds/developing-your-application-with-kubernetes-3864381926be?source=rss----cd9deb0789fe---4</link>
            <guid isPermaLink="false">https://medium.com/p/3864381926be</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <dc:creator><![CDATA[Justin Grayston]]></dc:creator>
            <pubDate>Wed, 10 May 2017 22:40:00 GMT</pubDate>
            <atom:updated>2017-05-10T22:40:39.961Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently I have been experimenting with <a href="http://kubernetes.io/">Kubernetes</a>, and preparing to move some current and new applications over to <a href="https://cloud.google.com/container-engine/">Google Container Engine</a>, which is the managed version of Kubernetes running on Google Cloud Platform.</p><p>One of the first things I wanted to do was make sure that the dev environment was the same as the application was getting deployed into. Here lay the problem. The entire team use Macs. I wanted it to be easy and quick to install with as little faff as possible.</p><p>So I followed the instructions to get Kubernetes running on Docker. This was pretty straightforward, but after a while I noticed that the ability to call services by name and be able to access them wasn’t working, because there wasn’t the addon DNS working.</p><p>So, much tinkering later: <a href="https://github.com/justingrayston/kubernetes-docker-dns">https://github.com/justingrayston/kubernetes-docker-dns</a></p><p>Still a little bit of a work in progress but a few people, including myself are starting to use it, maybe others might find it useful too. Feel free to fork and make pull requests, contributions are more than welcome.</p><p><em>Originally published at </em><a href="https://www.justingrayston.com/2016/01/11/developing-application-kubernetes/"><em>www.justingrayston.com</em></a><em> on January 11, 2016.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3864381926be" width="1" height="1" alt=""><hr><p><a href="https://medium.com/musings-in-the-clouds/developing-your-application-with-kubernetes-3864381926be">Developing your application with Kubernetes</a> was originally published in <a href="https://medium.com/musings-in-the-clouds">Musings In The Clouds</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Wordpress — Click to deploy on Google Compute Engine]]></title>
            <link>https://medium.com/musings-in-the-clouds/wordpress-click-to-deploy-on-google-compute-engine-fc6ab4b744d2?source=rss----cd9deb0789fe---4</link>
            <guid isPermaLink="false">https://medium.com/p/fc6ab4b744d2</guid>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Justin Grayston]]></dc:creator>
            <pubDate>Wed, 10 May 2017 22:36:40 GMT</pubDate>
            <atom:updated>2017-05-10T22:37:23.908Z</atom:updated>
            <content:encoded><![CDATA[<p>At the time of writing, instructions to deploy Wordpress on Google Cloud can be found here: <a href="https://cloud.google.com/solutions/wordpress/deployment-details.">https://cloud.google.com/solutions/wordpress/deployment-details.</a></p><p>However, although, this will get you WordPress working on Google Compute Engine accessible over an IP address, it isn’t actually a usable WordPress site. So here I intend to add a few meat to those rather bare bones.</p><p>Firstly, I’d recommend (or insist really, but you don’t have to listen) that you have a domain set up somewhere, and you have purchased a certificate so you can connect to your site via https once up and running. Otherwise, you will be setting up your site and accessing wp-admin over http.</p><p>Create a cloud project at <a href="https://console.developers.google.com/project">https://console.developers.google.com/project</a> for your site. Then, go to the deploy and manage section in your project and continue to the<strong> Click to deploy</strong> section. Find WordPress hit go, and follow the instructions. While it does the install, if you haven’t already, install the gcloud command line tools.</p><p>Now to set up your wordpress site, ssh to the VM either using the ssh button in the console or using gcloud compute ssh &lt;instance&gt;. You want to set apache up so it can listen on port 443 as well as 80 and it can handle the certificate.</p><p>Firstly, make sure that you copy wordpress and default-ssl files from <strong>/etc/apache2/sites-available/</strong> to <strong>/etc/apache2/sites-enabled/</strong> and copy <strong>ssl.conf</strong> and <strong>ssl.load</strong> from <strong>/etc/apache2/mods-available</strong> to <strong>/etc/apache2/mods-enabled.</strong> At the time of writing, this wasn’t set up as part of the deploy.</p><p>Upload via gcloud your certificate (crt) file here <strong>/etc/ssl/certs/</strong> and your private key to <strong>/etc/ssl/private/</strong>. You may have a bundle file for intermediates, upload this to <strong>/etc/ssl/certs/</strong>. Once you have done that, in <strong>sites-enabled/default-ssl</strong> file, update the <strong>SSLCertificateFile</strong> with the path to the .crt, <strong>SSLCertificateKeyFile</strong> with the path to the .key and <strong>SSLCertificateChainFile</strong> to the path to the <strong>bundle.crt</strong> file. Make sure you uncomment if you find they are commented out (have # in front of them). How you will need to set up your certificate may very, most certificate providers offer instructions and you should be able to Google debian set up if what worked for me, doesn’t work for you. Then you just need to make one change to the file. Near the top of the file you will see something like:</p><pre>&lt;Directory /var/www/&gt; Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all &lt;/Directory&gt;</pre><p>Change the AllowOverride to All (this will mean that your posts on https can be routed to the WordPress index.php file. So it should end up:</p><pre>&lt;Directory /var/www/&gt; Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all</pre><pre>&lt;/Directory&gt;</pre><p>Alternatively you could just combine the wordpress and default-ssl files, but I am happy with leaving the 2 port configs separate.</p><p>I am no sys-admin (and have spent much of my professional life avoiding it), so if I can get it running so should you!</p><p>OK, now that is all done, you need to get apache to reload the configs. Type the folllowing in the terminal to reload.</p><pre>sudo /etc/init.d/apache2 reload</pre><p>You can now check that it is listening ok to both ports with:</p><pre>netstat -ln | grep -E &#39;:80|443&#39;</pre><p>You should see output like:</p><pre>tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN</pre><pre>tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN</pre><p>If so, you are nearly there, but hang on, you can only access your new Wordpress site on an IP still. So you need to do a few things. By default, your VM is accessed via an ephemeral IP address. Essentially, your VM could get moved to another machine/data center etc, and you may find that the routing changes means you are now on another IP. So back in the Google developers console, go to compute-&gt;Compute Engine -&gt;Networks and set up a static IP. You can bind this IP to your VM by navigating to the VM and click edit on external IP. You can now use this IP address in your domain DNS zone file to direct the domain to your VM. You may need to wait for the DNS to propagate. I did try and play around with the Cloud DNS but it didn’t seem to work first time, and because of the ttl and the lateness of the hour, I didn’t finish figuring it out. It may be the subject of a future post.</p><p>You are nearly there, but before you set up wordpress don’t forget to set your secret phrases up in /var/www/wp-config.php. Once that is done, you are good to set up WordPress, find and install a theme and off you go.</p><h3>Thoughts so far…</h3><p>I chose the n1-standard instance to test. The whole set up, with storage seems to be just under $1 a day to run. So, it isn’t cheap, but not expensive either. One thing though, it is quick. Compared to running WordPress on a cheap shared hosting the response times are great and the site is fast. Once it has been running for a while, I’ll activate wp-super-cache to see how that changes running costs.</p><p>It certainly is a very easy way to get a WordPress site up and running, using one of the best, if not the best infrastructure in the world. If you need more capacity you could always buy it, however, for the super busy site, you probably want to think about more complex set up, with load balancers, separate SQL vm etc. So at some point in the future, I will see how easy it is to migrate this site to using containers for each of the component parts.</p><p><em>Originally published at </em><a href="https://www.justingrayston.com/2015/05/21/wordpress-click-to-deploy-on-google-compute-engine/"><em>www.justingrayston.com</em></a><em> on May 21, 2015.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc6ab4b744d2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/musings-in-the-clouds/wordpress-click-to-deploy-on-google-compute-engine-fc6ab4b744d2">Wordpress — Click to deploy on Google Compute Engine</a> was originally published in <a href="https://medium.com/musings-in-the-clouds">Musings In The Clouds</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Do’s and don’ts for a Junior Developer]]></title>
            <link>https://medium.com/musings-in-the-clouds/dos-and-don-ts-for-a-junior-developer-b3212fd56512?source=rss----cd9deb0789fe---4</link>
            <guid isPermaLink="false">https://medium.com/p/b3212fd56512</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Justin Grayston]]></dc:creator>
            <pubDate>Wed, 10 May 2017 22:29:14 GMT</pubDate>
            <atom:updated>2017-05-06T15:40:59.576Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dmFyESBUHmoxyPOxDA5IlQ.jpeg" /><figcaption><a href="https://pixabay.com/en/office-home-office-creative-apple-581131/">https://pixabay.com/en/office-home-office-creative-apple-581131/</a></figcaption></figure><p>Joining a new a team as a junior developer can be a daunting moment. There are a lot of unknowns for you, your new team mates and managers. I’ve had the benefit of bringing junior developers both graduates and non graduates into the teams I work with. I actually think I’ve been very lucky and privileged with the people I’ve worked with. There are certain qualities and ways of working as a junior, that are not only desirable to your managers, but essential should you want to raise your status quickly in the team. There are also some things you should definitely avoid doing too.</p><p>The following is just my opinion, but hopefully it may prove useful to someone.</p><h3>Expose yourself to real world code as early as you can</h3><p>Many new starters, even if they are a CS graduate, don’t understand test driven principles, or even how to properly document their code. However, the good junior developer will normally pick this up and embrace it. You could get a head start before you even start your new job. Do open source, but not just any open source. Open source doesn’t mean quality, it can mean a free for all. Take a look at how some popular repo’s are put together. Look for things that interest you, or you use often and look for issues looking for contributions. Maybe your Pull Request will get rejected, but you will learn from it, and you will bring this to your team from day one.</p><h3>Leave your ego at the door (but not your character).</h3><p>Even if you have been a busy bee, contributing to several open source projects, even have a side project of your own, don’t assume you know it all. Some of the challenges you’ll face could be quite specialised. They could even seem counter intuitive or just plain wrong, but if you think that, it probably means you need to ask why. I recall many times explaining why you may write data in one way for non-relation databases compared to you more common SQL. It is only when a dev realises that the little effort on write and data models could yield massive dividends if you have 1 million users hitting your app over an hour requiring a specific read. There are many ways of saying “Why should we do that?”, and the one that is gilded with arrogance won’t win you any favours within the team and your managers. It isn’t the question that is the problem, but the way you ask it.</p><p>That doesn’t mean be passive, be yourself, just be mindful of how you maybe coming across.</p><h3>Don’t be afraid to speak your mind and share your thoughts.</h3><p>This may fly in the face of the first section, but there is a subtle but important difference about the situation, timing and tone. You are a member of a team. Each member has an equal right to contribute, and that is the important word, <strong><em>contribute</em></strong>. In fact, I’d say each member has a duty to contribute. You may have a good point, or raise a side effect that no one else has considered, or maybe what you say may lead another team member to take your point further, or counter it. It doesn’t matter if it your point gets discounted, or is even technically incorrect, as long as it is relevant. The fact you are taking part, the fact that you are contributing means you earn your place on the team and the respect of your colleagues. Just don’t forget the section above.</p><h3>Be mindful of deadlines and how hard your team mates are working</h3><p>If you know there is a deadline coming and you see the rest of your team still working away at the end of the day, don’t leave on the dot. Now, I am not saying you should be working late into the night. You need your life outside of work as much as anyone else. However, walking out like your are clock watching will look odd to the rest of the team and your managers. Now you may have finished everything that you were working on, it may be just luck, which is fine, but if it is everyday, it will be noticed. It won’t feel like your are acting within the team. When a dev has got to the end of the day and comes to me and asks if there is anything they can help with as they can see everyone is still hard at it, it has always been appreciated, and nearly always, I thank them and send them home. The fact they asked means they are aware. They are acting in the teams interest. In most cases we’d all be finished up shortly anyway.</p><h3>Ask. If your stuck, just ask!</h3><p>When you get stuck, don’t spend the next 3 hours trying to solve it on your own. This can get really frustrating for both you and your team. Try giving your self a time limit. Give yourself say 10 minutes to make headway. This often has the benefit of focusing your debugging. At the end of the 10 minutes ask yourself, “have I made progress?”. If so, give it another 10 minutes, you may crack it. Otherwise ask someone. Quite often it can be as simple as explaining the problem to someone else that makes you solve it for yourself. It could be that you wouldn’t have known how to solve it, but it could take someone else minutes to put you on the right path.</p><p>It can feel like you are admitting a failure by not sorting it yourself, but you are not. Burning through time fruitlessly is worse.</p><h3>Don’t say you understand something just so you don’t look bad</h3><p>This has an overlap with the section above, but its worth separating. Sometimes you may get briefed on something, or assigned an issue, perhaps in a meeting where the team is discussing the next sprint. You <em>think</em> you understand it, but you aren’t sure. To save face, you reassure yourself that you’ve got it covered, but inside you can feel the doubt, perhaps even panic. Now is the time to speak up. Not when you start working on the issue. That will lead to the section above, and perhaps hours of fruitless labour. It will just compound the problem. Just clarifying you understand what is being asked and how you are going to go about the task will take a minute or two and will save hours. It shows that you are able to listen and clarify back. Qualities that are vital when you start working with clients directly.</p><h3>If tests fail because of changes you make, don’t comment them all out</h3><p>If you notice test are failing, then well done. It means that:</p><ul><li>You are working with code that has tests. This is good.</li><li>That you have the tests running as you code. This is also good.</li><li>You might possibly be writing tests ready for you to implement code. Again, this is good.</li></ul><p>You get the picture. However, sometimes you make a change, add a module or something and test armageddon ensues. Don’t what ever you do disable the tests so your own pass. This may sound daft, but I have seen it happen a few times. You’d hope that it gets picked up by a code review, but if it doesn’t or where you work don’t have a code review process (hmmm…) this could hide a multitude of broken sins. Especially if others working on the project don’t realise those tests are disabled. Worst case scenario is that the first time anyone finds out is when users or the client report to say something that used to work, no longer does. Commit history will lead the story back to you. Don’t let this happen.</p><p>If tests break, hopefully you notice quickly. If you have, start to step back through the changes to see at what point you broke the code. Hopefully it will be easy to unpick. It may mean reconsidering what you were doing or how you were going about it, but you know what to do next don’t you. Yup, speak up.</p><h3>So, in summary…</h3><p>It is likely that even with best efforts maybe one or two of these scenarios will happen. I know they did with me, and I learnt from them. I’ve also learned from the developers I’ve worked with who fell into those predicaments.</p><p>It may all seem like common sense, and you are right it is, but I don’t think it is the way humans work really. I think we all want to prove ourselves and for some reason admitting you need help is a sign of weakness, but rest assured, in my opinion at least, it isn’t.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b3212fd56512" width="1" height="1" alt=""><hr><p><a href="https://medium.com/musings-in-the-clouds/dos-and-don-ts-for-a-junior-developer-b3212fd56512">Do’s and don’ts for a Junior Developer</a> was originally published in <a href="https://medium.com/musings-in-the-clouds">Musings In The Clouds</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>