syntax.us Let the syntax do the talking
Blog Contact Posts Questions Tags Hire Me

Question:
What is 2015_1108 Code Challenge?

The 2015_1108 Code Challenge is a learning exercise for students attending Dan's Linux JavaScript Class at 3pm on 2015-11-08 at Hacker Dojo:

http://www.meetup.com/Dans-Linux-JavaScript-Class/events/226495833/

We start with three tasks: Install Ubuntu, enhance it, and create account named ann: Next, we learn some Emacs:
  • emacs ~ann/.emacs
  • Experiment with the controls at the top of the emacs window
  • Add this syntax to file: ~ann/.emacs
    ;;
    ;; ~ann/.emacs
    ;;
    (global-set-key "\C-xs" 'shell)
    (global-set-key "\em"   'buffer-menu-other-window)
    (global-set-key "\eR"   'rename-buffer)
    ;; end of .emacs
    
  • Figure out how to save and exit
  • Verify your work:
    cat ~ann/.emacs
  • Start 'bare' emacs:
    emacs
  • Start a shell in emacs with ctrl-x then letter 's'.
  • I should see something like this:
  • Rename the shell to SHELL1 with esc-key, then letter 'R'
  • I should see something like this:
  • List all buffers in my emacs with esc-key, then letter 'm'
  • I should see something like this:

I see the buffer-menu as similar to the Mac-Dock, Ubuntu-Launcher or the Windows-Taskbar.

The buffer-menu is my favorite emacs feature; it allows my mind to QUICKLY switch focus among three types of objects:
  • different shells
  • different files
  • different folders

The buffer-menu floats 'hot' shells, files and folders to the top.

This is useful behavior.

I mostly do 4 types of tasks on a laptop:
  • Interact with file
  • Interact with folder
  • Interact with shell
  • Interact with browser

I can do the first three types inside of emacs.

When I coordinate tasks with emacs rather than a Dock, I work much faster (because of the buffer-menu).

That sequence of creating a shell, and renaming it is the most difficult task I need to know.

All other emacs tasks can be done using mouse and arrow keys.

If I am an emacs power-user, I know two ways to use emacs to interact with folders.

The GUI-way is to click on the file-cabinet at the top.

Another way, which is quicker, is to type command ctrl-x then letter 'f'.

I should see something like this:


  • After I learn some Emacs or some other editor, I Install Node.js in this folder: ~ann/node/
  • cd ~ann
    wget https://nodejs.org/dist/v5.0.0/node-v5.0.0-linux-x64.tar.gz
    tar zxf node-v5.0.0-linux-x64.tar.gz
    rm -rf node
    mv node-v5.0.0-linux-x64 node
  • Then, I add Node.js to PATH:
    export       PATH="/home/ann/node/bin:${PATH}"
    echo 'export PATH="/home/ann/node/bin:${PATH}"' >> ~ann/.bashrc
  • Run a test:
    which node
    node -e 'console.log("hello world")'
  • Install CoffeScript to test npm:
    which npm
    npm install -g coffee-script
    ls -la /home/ann/node/lib/node_modules/
    which coffee
    coffee -e 'console.log "hello coffee!"'
  • Start work on an app:
    cd ~ann
    echo 'gem: --no-ri --no-rdoc' >> ~ann/.gemrc
    rm -rf app26r
    git clone https://github.com/danbikle/app26r.git
    cd ~ann/app26r
    .  ~ann/app26r/app26r.bash
    rm -rf   $GEM_HOME
    mkdir -p $GEM_HOME
    /usr/bin/gem install bundler
    $GEM_HOME/bin/bundle install
    ~ann/app26r/bin/rails s -p 3326
    /usr/bin/curl localhost:3326|head


If you want to deploy this repository to Heroku, follow this recipe:
  • Create an account at heroku.com website
  • Download/Install Heroku client
    cd ~ann
    wget https://s3.amazonaws.com/assets.heroku.com/heroku-client/heroku-client.tgz
    tar zxf heroku-client.tgz
    echo 'export PATH=/home/ann/heroku-client/bin:${PATH}' >> ~ann/.bashrc
    echo  export PATH=/home/ann/heroku-client/bin:${PATH}
  • I created ssh-key for ann account (assuming ann has none yet):
    ann@dev06:~$ 
    ann@dev06:~$ ssh-keygen -t rsa
    Generating public/private rsa key pair.
    Enter file in which to save the key (/home/ann/.ssh/id_rsa): 
    Created directory '/home/ann/.ssh'.
    Enter passphrase (empty for no passphrase): 
    Enter same passphrase again: 
    Your identification has been saved in /home/ann/.ssh/id_rsa.
    Your public key has been saved in /home/ann/.ssh/id_rsa.pub.
    The key fingerprint is:
    7c:73:e0:26:8b:62:f6:a4:1d:78:22:e5:cd:3a:5c:eb ann@dev06
    The key randomart image is:
    +--[ RSA 2048]----+
    |                 |
    |                 |
    |          .      |
    |       . . .     |
    |    .   S = .    |
    |   o +.. = o     |
    |  ..B.B..        |
    |   +oX..         |
    |    ooE          |
    +-----------------+
    ann@dev06:~$ 
    ann@dev06:~$ 
    ann@dev06:~$ 
    
  • I used heroku-client to "login" my shell. I gave a copy of ann public ssh-key to heroku:
    heroku status
    heroku auth:login
    heroku auth:whoami
    heroku keys:add
  • I used heroku-client to create a blank app named d1d2 at herokuapp.com
    cd ~ann/app26r
    ~ann/heroku-client/bin/heroku create d1d2
  • git-push ~ann/app26r to heroku
    cd ~ann/app26r
    git add .
    git commit -am rails
    git push heroku master
  • I saw ~ann/app26r deployed at https://d1d2.herokuapp.com

Questions

  • Look at https://d1d2.herokuapp.com and answer what is a histogram?
  • What kind of questions can a histogram answer?
  • The blue histogram describes a collection of observations, how are the observations collected?
  • The blue histogram can show the number of observations where day1 gained between +3% and +4%. How many of those observations can you count?
  • If day1 gains -2.0% would you expect day2 to gain more than the median?
  • If I use view-source in my browser I can see the JavaScript which builds the charts, where do I find that JavaScript in the Rails app?
  • Bostock shows how create a histogram here: http://bl.ocks.org/mbostock/3048450 Does app26r do it the same way or does app26r do something fundamentally different?
  • D3.js has this API call d3.layout.histogram(). What does it create exactly? Does it create data? Does it create a chart? Does it create data and a chart?
  • About this API call d3.layout.histogram(), What does it take as an input?
  • Compare and contrast app25r and app26r.

That could be considered an adequate code challenge for a two hour Meetup.

If you have questions, e-me:

bikle101@gmail.com


syntax.us Let the syntax do the talking
Blog Contact Posts Questions Tags Hire Me