T-7 until assessment00 window closes

  • Unix Basics CodeSchool Screencast, Parts one and two
    • pipe shell contents into a file with the > (left to right)
    • print the contents of a file with the cat command
    • ln outfile infile links two files
      • the consequence of this is that two files will have the same inode number (found via ls -i), and will be references to the same file
    • symbolic/soft link
      • ln -s link_from_me link_to_me
      • reference to a file name rather than file itself, different inode numbers
      • needs to be done between different filesystems, since inode number must be different across file systems
      • symbolic links also must be done between directories on the same filesystem
    • use the .. as the parent directory reference! (cd ../.. means going up two parent directories)
    • cp -r and rm -r recursive for directories
    • wildcards also come in handy with directories: say that you want to find every version of lame.txt in the parent directory: ls */lame*
    • see permissions with an ls -l , rwx (read, write, execute)
      • chmod (changemode) used with flags (changing permissions for user, group, or other) (plus sign for adding permissions)
        • can use digits too(one for user, group, and other) (7 is all, 0 is none, 5 no write access)
  •  More techniques for Shell Productivity (and Part 2 later)
    • find , include what directory, . (a period) for current
      • -name, if you want to find name including some string, just specify the string
      • -type f will only operate on files, -type d on directories
      • -exec will pass a string to some command written between it and a semicolon (escaped with a backslash \;) to be executed
        • grep searches for whatever is after it and before a \;
          • using --with-filename with grep will print the filename that each search result is in
      • -print
        • will make find print the name of the found file/directory
    •  ack (installed with homebrew) a better grep
    • less utility
      • dump less text onto the terminal
      • lookup export LESS=
    • SSH tips
      • ssh config: ~/.ssh/config
      • non interactive ssh so that one-off command history stays on local machine
    • ruby -e comes in handy for shell scripting
      • interpret anything after it in the shell
    • Something to read later: command line crash course
  • Git Immersion 
    • repository –
      • git init
      • git add  (staging, is not a one time thing) , git commit -m "comment here, since -m is a flag for comment", git status
        • without a comment flag you will get channeled into an editor to write your comment (changing your editor)
      • git log (history, to see its options man git-log)
    • edit aliases, in .gitconfig in $HOME
    • previous states and reverting
      • look at a previous state
        • git checkout <hash> , or just move back to the latest, git checkout master
          • you can tag whatever version you are currently on, git tag mysweettag
          • you can refer to mysweettag ‘s parent via mysweettag^ to mysweettag-1
          • view all tags, git tag
      • if you have unstaged changes you wish to revert, just checkout to the master branch
      • if you have staged changes that you wish to revert, clear the staging area with a git reset HEAD filename.ext
        • will reset to whatever the head is – but doesn’t change the working directory, to do so, checkout
      • if you have a regretful commit…
        • New commit that reverses the bad changes – Both the bad commit and the revert are visible
          • git revert HEAD , goes into an editor allowing you to edit the commit message for the newest commit, which will go one commit back, and be labelled as revert
            • HEAD is substitutable for a hash id or a tag id, and the revert command will then rewrite the current branch point to wherever you point it to
              • it can also optionally reset the staging area, and working directory
        • Take-back approach
          • first, you can tag the bad ones for reference
            • without this tag, garbage collection will delete it?
          • git reset --hard taghere (hard updates the working directory)
            • this reset can be undone easily on local repositories, just reset again
          • but a git hist --all  will reveal that bad commits are still there, but not under the master branch
            • to remove them, remove the tag on it, git tag -d tagname  and you’ll notice that git hist --all no longer lists it
    • amending
      • git commit --amend 
    • moving a file
      • The best way, is to use git to move: git mv file.ext destination_folder , if you forgot to do this, you’ll have to notify git later that a file in one place has been added, and removed in another
    • exploring git’s directory structure
      • from a project directory, doing ls -C .git (-C makes output into columns, default in terminal anyway) shows us a few things
      • .git/object – first 2 character names related to the sha1 hash, within each are two 38 character directories (compressed and encoded)
      • .git/config – is the project specific configuration file
      • .git/HEAD – contains the reference to the current HEAD file
      • .git/refs/heads contains branches
      • .git/refs/tags contains tags
    • using hashes
      • git cat-file -t <hash> = git type <hash>
      • git cat-file -p <hash> = git dump <hash>
        • displays a tree hash – on a commit object
          • git dump <treehash> – will show the directory description of the top level files for the commit
          • also displays a tree hash, doing git dump on it will allow you to probe one directory deeper
          • if you end up git dumping a file’s blob hash, you will print out the contents of that file
  • RVM – Codeschool screencast
    • rvm get stable to update (if you’re risky and wanna try the latest, from github, then rvm get head)
    • custom gemset: rvm gemset create <name> :  works for the current version of ruby (otherwise: rvm 1.9.3@<name> --create)
      • rvm gemset use <name>
    • .rvmrc
      • specific gem sets, switching between Rubies, version control, for some app. rvm 1.9.3@myapp --create --rvmrc (outputs to rvmrc file)
    • rvm current shows interpreter, version number, patch, and at which gemset name (rvm info for more)
    • customize what is shown on irb command line –  the PS1 line in the .bash_profile or .bashrc

Rails Tutorial – Michael Hartl

  • Setup
    • installed SublimeERB through package control, Ctrl+Shift+. lets me toggle ERB styles
    • For RubyTest, I edited the /Users/ilyakavalerov/Library/Application\ Support/Sublime\ Text\ 2/Packages/RubyTest/TestConsole.hidden-tmTheme file as this page 
    • I added the snippets for the book, didn’t work in package control, did a git clone, but the snippets don’t appear when I seach for them in sublime text as far as I can tell
  • Trying a first application
    1. rails new app_name
    2. use bundler to install dependent gems, but first edit the Gemfile in the root directory
      • can edit the Gemfile to include specific version numbers of gems. greater than or equal to (>=) signs are used with the version numbers, and so are ~> signs which function just like >= but only perform minor point upgrades (_._.+1 and not _.+1._)
      • and add sq3lite to the development group, specifying that it is only in the development environment, preventing future conflict when deployed to Heroku
      • then use bundle update && bundle install
      • Better Practices with Bundler are in chapter 3
    3. Stopped on rails server

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s