scalaJS-playground
- http://www.scala-js-fiddle.com/
- http://lihaoyi.github.io/hands-on-scala-js/
- http://www.scala-js.org/doc/tutorial.html
Local
Run on local
- $
foreman start web
- http://localhost:5000/
Scala.js
$ sbt
> // set scalaJSStage in Global := FastOptStage // has been set in `local.sbt`, run code with Node.js
> run
> last
> reload // reload the build file if sbt is still running
> fastOptJS
> ~fastOptJS // `~` means automatically refreshing the page when recompilation is complete
> fullOptJS // takes tens of seconds, but can compress the compiled code
Scala Tools
Node Modules
- template engine
- Bootstrap layoutit
Heroku
Scalability
Procfile can set background worker process
$ heroku ps --> check how many dynos are running
$ heroku ps:scale web=2 --> can reduce delay but it's expensive
Run on local and remote machines
$ npm install
$ foreman start web --> run app locally, use `curl` to test
git commit and push
$ git push origin master --> push to Github Master branch
$ git push heroku master --> push to Heroku
$ heroku open --> run on heroku
$ heroku restart --> solve Application Error
Modify environment variable
local (Foreman)
$ bin/loadEnv4Foreman.sh --> load `.env` from backup dir (Foreman needs `.env`)
$ vim .env
echo .env >> .gitignore --> sensitive configuration values should not be committed to source-control
$ foreman start
remote (Heroku)
$ heroku config:set TIMES=2
$ heroku config
$ bin/beforeCommit.sh --> backup and delete .env in current folder
git commit and push
$ heroku open
ClearDB MySQL
$ heroku addons:add cleardb:ignite
$ heroku config
$ heroku config:add DATABASE_URL=(the_copied_value_of_CLEARDB_DATABASE_URL)
$ heroku config -s | grep CLEARDB_DATABASE_URL >> .env
$ more .env
$ echo .env >> .gitignore --> sensitive configuration values should not be committed to source-control
$ bin/beforeCommit.sh --> backup `.env`
- Setup Heroku MySQL credentials on node.js
- install mysql on node.js
$ npm install
- credential info are saved to
.env
andheroku config:set
- add new connection on local MySQL with Heroku MySQL credentials -> create table, insert a record to mysql on local machine
- modify
index.js
andpackage.json
- install mysql on node.js
Memcached Cloud
$ heroku addons:add memcachedcloud:25
$ heroku config
set Memcached Cloud credentials both through `.env` and `heroku config:set`
-
https://www.npmjs.com/package/memjs
- include
memjs
intopackage.json
, and then$ npm install
- include
Console
$ heroku run node
$ heroku run bash
AddOn + logs
$ heroku logs --tail
$ heroku addons:add papertrail --> logging add-on
$ heroku addons:open papertrail
$ heroku addons:docs papertrail
$ heroku addons
Neo4j Graph Database
local
$ brew install neo4j
$ neo4j start
philippkueng/node-neo4j: Neo4j REST API wrapper for Node.js