After deving on a Mac for a few weeks, I really started loving the cached credentials that were set to on by default in Bash. Especially when working with remote repositories like Bitbucket that I needed to log into. I did not want to hardcode my username/password in however… just wanted to be able to cache for an hour or so to make push/pull/merges less painful (because we are all using 500 character random passwords right ?!?).
I pieced this together over several StackOverflow posts to get the quickest and most efficient way to do this. (You will need to be using git version 1.8.1 or later)
git config –global credential.helper cache
git config –global credential.helper “cache –timeout=3600″
git config –global credential.helper wincred
Use those 3 commands and you will have your credentials cached for an hour after using them. NOTE: 3600 is time in seconds to cache… you can change that to whatever value you find works best for your situation
Before going any further… make sure that you are using a source code repository. Even if (and maybe especially) if it is just you. I cannot recommend git enough. I usually bitbucket for my business and personal use because I can do free private repos. Github is another option, especially good for open source projects. Whenever I am about to make major changes, I make a branch so that I can easily start over again if I mess up along the way and commit incrementally as I get things working. Trust me, this will save you hours and hours of work once you get used to it.
Okay… back to the main part of this post.
There are quite a few ways to get Angular JS into your app… but the easiest I found is to start with the Angular Seed base project. You can download that here: https://github.com/angular/angular-seed. However for some reason… this project, the download did not work well for me. I am not sure why, but I found myself with a lot of extra and misplaced files. I instead used the instructions in the ReadMe.md file. I cloned the repo and used NPM install. For now, I did this all in a temporary directory so that I had all of the files I needed identified.
Once this is done, I copied the files into the app folder. The files you already had in there for the GoApp should not be replaced and your base bootstrap site should still be working. Your directory should look something like below:
To allow Angular to work correctly with all of the right folders, we need to add some more routing to our app.yaml file.
Here is what mine looked like when I was done:
– url: /
- url: /asset/img
- url: /asset/pho
- url: /asset/vid
- url: /css
- url: /fonts
- url: /js
- url: /lib
- url: /partials
- url: /.*
I took my homepage and separated the content from the header/nav and footer. I put the content html into a partial file (this one called home.html. In the place of the content in the index.html file I put the code for the ng-view there:
<!– CONTENT GOES HERE –>
That is really all there is for the initial AngularJS changes needed for the application. Now you can follow most Angular examples on the web. This one I found the easiest to get the multiple pages loading on the single page app, if you are not able to follow along with the Angular Seed examples: http://fdietz.github.io/recipes-with-angular-js/urls-routing-and-partials/client-side-routing-with-hashbang-urls.html
Please let me know if you have any questions thus far. Currently I was able to get a few more “pages” added to my site and a simple “Coming Soon” placeholder for a default link for all of the pages not yet implemented.
Where did I start?
Following up on my last post, I wanted to detail more about how I started getting the GoApp/AngularJS site going. (BTW… is there a good acronym for this stack yet?).
I started with the GoApp hello world example, since I only knew GoLang and was not particularly versed on GoApp. (You can find it here: https://developers.google.com/appengine/docs/go/gettingstarted/helloworld). I found it very straightforward and only took a few minutes after making sure I had GoApp and Python 2.7 installed (current prerequisites) it took only a few minutes to get it stood up. Currently I have been using the IntelliJ IDE (community version) with a Go plug-in for my Go needs. I am not 100% that it is the right choice… so I am open for suggestions if anyone has ones that work better (especially with the GoApp instead of just GoLang).
Once that was installed and running locally, I added in my startbootstrap.com bootstrap template. The biggest hurdle is to add in the additional folders for the Go routing so that all of the various includes and files were properly linked. It is not hard to do (but easy to forget).
That should get you all started if you are looking to do this yourself. The next thing I will be touching upon (and working on) is separating the template into a better single-page application and add in AngularJS routing.
It is not often that I get to align a side project directly with items that I am interested in. This is one of those exceptions that I love.
I have been helping (leader, committee member) for my son’s Cub Scout pack for over a year now and was thinking about the future of scouting (compared to when I was a kid) and how technology would play a part of. It was then that I realized that our Pack did not even have an actual web presence other than a few posts on Facebook.
At the same time I have been really diving into AngularJS and GoLang out of interest and trying to get my web chops up to date since most of my development has been in back-end processes (search algorithms, machine learning, data analytics) and mobile. I did some quick research and found a great post about using Go with Angular for websites (https://www.youtube.com/watch?v=CBwOuK9x5VQ), and then I was set. I would do a full website for the scouts while having fun with some new(-ish) languages (and proven!).
I found a few good BootStrap templates (http://startbootstrap.com/template-categories/all/) and started designing and building the site. Had the site stood up in no time and found it to be very responsive. So far I am loving my choice and hoping to really get going.
If you have any specific questions or thoughts, please reach out to me here or twitter (@matt_ridley). I will be posting more in the future.
If you are curious where the project is at… some of it is pushed live to: http://csapack3151.appspot.com/
Development can get frustrating, and at those times I look for ways to get renewed and find the passion again.
This weekend I stumbled across the “Hello World Podcast”. It interviews various developers, writers and speakers in the tech world and talks to them about their 1st computer, 1st program and 1st job. The interview usually extends beyond that… but those 3 things are fun to listen to. Listening to others talk about why they started programming reminds me why I did. And this week I have already found myself writing extra code at night and thinking about programming than I was just last week.
So, if you have not found this podcast yet, I highly recommend that you give it a try. Make it a priority if you are finding yourself non-motivated.
Last post I talked about that horrible feeling when you are completely stuck and cannot figure out what to do.
Luckily I am not at one of the best feelings a developer can have… getting unstuck again. I think it is proportional to the length and depth you were stuck… so needless to say I am on cloud-nine right now.
Here is what I was stuck on and how I finally solved it.
For the past few months I have been working with some friends on a new kid’s game for the Android system. The last piece on my plate was to add in Google Play Services so that I could add achievements and leaderboards. Tons of games have already done it and there seemed to be a ton of documentation from Google on the topic, so I figured it would be an easy win.
Unfortunately after a lot of effort to prep everything, when I fired up the app and tried to sign in, I got the error “Invalid Application” stating that my project Id or SHA1 cert was incorrect. I looked at over and over and found the client id tags in the Google Developer Console (remember this), and made sure the entry was added to match. Still no change. I then found myself going to Stack Overflow, blogs and using troublshooting guides on Google to try and find the answer. All to no avail.
The application stated that it might be because my account was not listed as a tester. Not being a stranger to weird things that happen with the project account being my own account… I had the other dev on the project try on his phone after ensuring he was registered as a tester. Same result.
So then I started to try everything I could think of…
– Add a new testing Google+ testing account, change my phone to that
– Manually install the APK with the ADB commands
– Publishing the apps and game services
– Turning on all of the Google APIs
– Deleting all the client Ids and re-entering them
– Release mode, debug mode, new mode…
Nothing. The same error message continued to mock me on every app start.
The only thing that I saw in the back of my mind was that the project id had the old project name in it, rather than the new one. I had changed the files I thought I needed to do in Android Studio… but maybe something was still wrong. So I spent a couple of days creating the app from scratch, copying over the code that was needed, making sure everything was set up as the new application, swapping over the git repo. When it was done, I fired up the app and…. same error screen.
This was about the time I started to question my skills and I got annoyed just to open other apps on my phone that had Google Play enabled because I was upset others were able to do it, but somehow I had failed.
Also I was annoyed, not only that I had wasted nearly 2 months of time, but now the developer console was a mess with remnants of both app versions. So I reached out to Google support finally to ask if they could assist in cleaning one (or both up). Email was slow and painful… and then I found that during the day Monday-Friday they had online chat (which I love… all sites should offer this if possible). After talking with a Jeff J for 30 minutes, my console was as clean as it was going to get and I was ready to try again.
I entered the minimum information that was needed, re-installed the application and… BOOM. Same error message. It was not looking good for our favorite developer my friends. Might Matt had struck out.
Okay… back to the drawing board. WHAT WAS I DOING WRONG?
I reread EVERY line of the Google Play Services troubleshooting page, and followed every step to the letter. I found that my APK signing key was having issues with the space in the name, so I recreated it from scratch with no spaces in the key name. Still got the error, but something told me to keep following the steps. A few more steps down I found a small line of text that I had missed before… “You must create the new client ID in the Google Play Developer Console, not in the Google Developers Console.”
I stared at that line for minutes in disbelief and started to check that I had indeed been adding the matching SHA1 certs in the “wrong” console… even though they both link to the same place. I cleared out the ones I had entered, and re-entered them in the correct console.
I pushed out the changed application and waited for it to start…
That was the best debug message I had seen in a long time.
I want to blame Google for allowing me to enter something in the “wrong” place. With all the recent changes, the instructions and troubleshooting are off slightly from what is actually there… but that was there the whole time, I just never read it closely enough.
And THAT is why you need to read all troubleshooting steps carefully, even when we think we already tried it.
Hope you all got some joy out of this, I am too happy to feel silly at this point (and I am sure it will happen to me many times in the future).
Have you ever come up against a coding issue that you have no idea how to solve? Every been truly stuck? I do not find that it happens a lot, thanks go Google and Stack Overflow… but it does happen. Right now I am stuck on Google Play Services. I have tried every troubleshooting tip I can find, changed every setting, entered and re-entered everything only to come up blank. It is frustrating and definitely takes the joy out of that night of hacking… and the longer it goes on the harder it gets.
What do you try when you are stuck in a situation like this?