├── README.md ├── tutorials ├── cloudFoundry.md ├── blueChatter.md └── ember-cli-auth.md ├── LICENSE └── links └── README.md /README.md: -------------------------------------------------------------------------------- 1 | # Teach Me How to Bluemix 2 | 3 | This repository will contain [tutorials](tutorials/) demonstrated at SMUCSM's event in preparation for the IBM Bluemix Hackathon. It also contains a collection of [useful links](links/) relating to Bluemix 4 | -------------------------------------------------------------------------------- /tutorials/cloudFoundry.md: -------------------------------------------------------------------------------- 1 | # Cloud Foundry CLI tutorial 2 | 3 | After you set up an account on [IBM Bluemix](https://console.ng.bluemix.net/) this is the first tutorial you should follow. While you aren't forced to use the `cf` CLI it will definitely speed up your workflow and the amount of tutorials you can follow. 4 | 5 | 1. [Download](https://github.com/cloudfoundry/cli/releases) the CLI for your system 6 | 2. Setup cf to default to bluemix with this command: `cf api https://api.ng.bluemix.net` 7 | 3. Login to bluemix, your email is the one you registered with above. `dev` is the default space 8 | ```bash 9 | cf login -u yourEmail@domain.com -o yourEmail@domain.com -s dev 10 | ``` 11 | 12 | You are now setup to use the Cloud Foundry CLI! Why not check out some of its [documentation?](https://www.ng.bluemix.net/docs/#cli/cli.html#cfcommands) 13 | -------------------------------------------------------------------------------- /tutorials/blueChatter.md: -------------------------------------------------------------------------------- 1 | # Blue Chatter 2 | 3 | This tutorial assumes you have `git` and the Cloud Foundry CLI `cf`. It will show an existing [example](https://github.com/IBM-Bluemix/bluechatter) and how to get it running quickly. 4 | 5 | 1. Setup a Redis service `cf create-service rediscloud 25mb redis-chatter` 6 | 2. Change to your prefered directory `cd ~/Develop` 7 | 3. Clone the repository `git clone https://github.com/CodenameBlueMix/bluechatter.git` 8 | 4. Change to that directory `cd ~/Develop/bluechatter` 9 | 5. Deploy to bluemix `cf push my-unique-chat-app-name` the app name must be unique accross JazzHub or it will fail, if so try again with a different name 10 | 6. View the application at `http://my-unique-chat-app-name.mybluemix.net` 11 | 12 | ## Bonus 13 | 14 | You can scale your application right from the command line. The following command will make it run on 5 instances. While this can be done using the [Web Dashboard](https://console.ng.bluemix.net), CLI is more fun :smile: 15 | ```bash 16 | cf scale my-unique-chat-app-name -i 5 17 | ``` 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | 26 | -------------------------------------------------------------------------------- /links/README.md: -------------------------------------------------------------------------------- 1 | # Useful links relating to Bluemix 2 | 3 | ## Cloud Foundry 4 | - [Download](https://github.com/cloudfoundry/cli/releases) 5 | - [Custom Buildpacks](https://github.com/cloudfoundry-community/cf-docs-contrib/wiki/Buildpacks) 6 | 7 | ## Official 8 | - [Documentation](https://www.ng.bluemix.net/docs/#) 9 | - [Git integration & Autodeploy](https://hub.jazz.net/tutorials/jazzeditor/#git_integration_and_autodeployment) 10 | - [GitHub integration](https://hub.jazz.net/gitHook/) 11 | - [CLI](https://www.ng.bluemix.net/docs/#cli/cli.html#cli) 12 | - [Autoscaling](https://www.ng.bluemix.net/docs/#services/Auto-Scaling/index.html#autoscaling) 13 | - [REST API](http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/apis/) 14 | - [Alchemy API & Node.js](http://www.alchemyapi.com/developers/getting-started-guide/using-alchemyapi-with-nodejs) 15 | - [Watson Develop Cloud](https://github.com/watson-developer-cloud) 16 | 17 | ## Examples & Demos 18 | - [Doctor Watson](http://doctor-watson.mybluemix.net/) 19 | - [Tradeoff Analytics](http://tradeoff-analytics-demo.mybluemix.net/) 20 | - [Alchemy API](http://www.alchemyapi.com/products/demo) 21 | - [Text to Speech](http://text-to-speech-demo.mybluemix.net/) 22 | - [Speech to Text](https://speech-to-text-demo.mybluemix.net/) 23 | - [Twitter influencers](https://github.com/ibmjstart/bluemix-python-sample-twitter-influence-app) 24 | 25 | ## Tutorials 26 | - [natural language question answering system](http://www.ibm.com/developerworks/cloud/library/cl-watson-films-bluemix-app/) 27 | - [Question and Answer Sample](http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/doc/qaapi/#sampleApp) 28 | - [Top 15 tutorials of 2014](http://www.ibm.com/developerworks/cloud/library/cl-bestoflbluemix2014/) 29 | - [iOS App](http://www.ibm.com/developerworks/library/mo-ios-mobiledata-app/) 30 | - [Java Apps](http://www.ibm.com/developerworks/library/d-bluemix-javadevops/index.html) 31 | - [Rails Blog](http://www.ibm.com/developerworks/cloud/library/cl-blograils-app/) 32 | 33 | ## NPM Packages 34 | - [Alchemy API](https://www.npmjs.com/package/alchemy-api) 35 | - [Bluemix Search](https://www.npmjs.com/search?q=bluemix) 36 | - [Ask Watson](https://www.npmjs.com/package/askwatson) 37 | - [Bluemix helper](https://www.npmjs.com/package/bluemix) 38 | -------------------------------------------------------------------------------- /tutorials/ember-cli-auth.md: -------------------------------------------------------------------------------- 1 | # Ember-CLI Authenticated app 2 | 3 | Lets show a bit more complicated of an app that uses Ember-CLI and github authentication. A lot of this tutorial may not make sense at first, but if I've sold you on Ember I'm sure you'll read more into [Ember.js](http://emberjs.com/) and [Ember-CLI](http://www.ember-cli.com/). Much of the authentication comes from a previous tutorial I've written which you can view [here](http://www.asciifarm.com/EmberAuthTutorial/) 4 | 5 | ## Prerequisites 6 | - [Git](http://git-scm.com/downloads) 7 | - [Node.js](https://nodejs.org/) 8 | - [Bower](http://bower.io/) `npm install -g bower` 9 | - [Ember-CLI](http://www.ember-cli.com/) `npm install -g ember-cli` 10 | 11 | ## Tutorial 12 | - Change directory to your development folder, ex `cd ~/Develop` 13 | - Initialize a new app `ember new myWebApp` 14 | - Change directory to your new app `cd myWebApp` 15 | - Fix package.json (will be fixed with ember-cli 0.2.1) 16 | ```javascript 17 | //--- /package.json 18 | "ember-cli": "ember-cli/ember-cli", 19 | ``` 20 | - Now run `npm install` this will take a while 21 | - Get some dependencies, Note we are using a specific version of torii because of [this bug](https://github.com/Vestorly/torii/issues/156) 22 | ``` 23 | ember install:addon ember-cli-simple-auth 24 | ember install:addon ember-cli-simple-auth-torii 25 | npm install --save-dev torii@0.2.3 26 | ``` 27 | - Setup our basic app structure 28 | ``` 29 | ember g route application 30 | ember g route protected 31 | ember g route login 32 | ember g controller login 33 | ``` 34 | - Add the mixins for logging in and blocking unauthenticated users 35 | ```javascript 36 | //--- /app/routes/application.js 37 | import Ember from 'ember'; 38 | import ApplicationRouteMixin from 'simple-auth/mixins/application-route-mixin'; 39 | 40 | export default Ember.Route.extend(ApplicationRouteMixin, {}); 41 | ``` 42 | ```javascript 43 | //--- /app/routes/protected.js 44 | import Ember from 'ember'; 45 | import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin'; 46 | 47 | export default Ember.Route.extend(AuthenticatedRouteMixin, {}); 48 | ``` 49 | - Add login actions and setup the controller 50 | ```javascript 51 | //--- /app/controllers/login.js 52 | import Ember from 'ember'; 53 | import LoginControllerMixin from 'simple-auth/mixins/login-controller-mixin'; 54 | 55 | export default Ember.Controller.extend(LoginControllerMixin, { 56 | authenticator: 'authenticator:torii' 57 | }); 58 | ``` 59 | ```javascript 60 | //--- /app/routes/login.js 61 | import Ember from 'ember'; 62 | 63 | export default Ember.Route.extend({ 64 | actions: { 65 | githubLogin: function() { 66 | this.get('session').authenticate('simple-auth-authenticator:torii', 'github-oauth2'); 67 | return; 68 | } 69 | } 70 | }); 71 | ``` 72 | - Update the templates 73 | ```html 74 | 75 |

Welcome to Bluemix Ember-CLI Authentication Demo!

76 | 77 | 87 | 88 | {{outlet}} 89 | ``` 90 | ```html 91 | 92 |

Login Route

93 | 94 | ``` 95 | ```html 96 | 97 |

Protected Route

98 | 99 | Hello Authenticated user! 100 | 101 |

102 | 103 | You shouldn't see this unless logged in 104 | ``` 105 | - Setup Github OAuth. Go [here](https://github.com/settings/applications) and `Register new application`, for now use a Homepage URL and Authorization callback URL of `http://localhost:4200` 106 | - Update config/environment.js 107 | ```js 108 | //--- config/environment.js 109 | ENV['torii'] = { 110 | providers: { 111 | 'github-oauth2': { 112 | apiKey: 'Client ID from Github', 113 | scope: 'user', 114 | redirectUri: 'http://localhost:4200' 115 | } 116 | } 117 | }; 118 | ``` 119 | - Test by running `ember server` 120 | 121 | ## Deploy to bluemix 122 | - In the bluemix web interface create a new Node.js application 123 | - Don't initialize the app with starter code, but rather download the starter code from the CF command line interface tab. 124 | - Copy app.js and manifest.yml to the root directory of your ember project 125 | - Modify package.json to include express 126 | ```json 127 | "dependencies": { 128 | "express": "3.4.7", 129 | "torii": "^0.2.3" 130 | } 131 | ``` 132 | - Modify app.js to get rid of jade and use ember-cli's build directory 133 | ```javascript 134 | // setup middleware 135 | var app = express(); 136 | app.use(app.router); 137 | app.use(express.errorHandler()); 138 | app.use(express.static(__dirname + '/dist')); //This changes to /dist where ember-cli builds to 139 | 140 | // YOU CAN REMOVE THE BELOW LINES, left in to show difference 141 | 142 | // app.set('view engine', 'jade'); 143 | // app.set('views', __dirname + '/views'); //optional since express defaults to CWD/views 144 | 145 | // render index page 146 | // app.get('/', function(req, res){ 147 | // res.render('index'); 148 | // }); 149 | ``` 150 | - We now have to change our `Authorization callback URL` on our [Github app page](https://github.com/settings/applications/) to match the bluemix url 151 | - We also have to update `redirectUri` to match in config/environment.js. Don't forget to add `http://` at the beginning! 152 | - Build the project `ember build` 153 | - Push to bluemix (you can also get the command from the CF tab in the bluemix interface) 154 | ```bash 155 | cf push ember-cli-auth-test 156 | ``` 157 | 158 | ## Notes 159 | - Don't `ADD GIT` in the bluemix web interface, it won't work and may give you unintended results 160 | --------------------------------------------------------------------------------