Tuesday, November 26, 2013

Github


Initial repository setup:
Log into Github and setup a new repository.





Leave blank the box in front of "Initialize this repository with a README"

Populate the repository with your local copy:
$ git remote add origin https://github.com/<username>/MyNewRepository.git 

$ git push -u origin master


Update Github with current files:
$ git push


Git basics

Typical process:

Make changes
git add .
git commit -a -m "What I am changing"
git push

Add the files in your new Rails project to Git and then commit the results:
$ git add .
$ git commit -m "Initialize repository"

Identify changed files:
$ git status

View commit messages:
$ git log


Start a new branch:
$ git checkout -b my-new-branch

List branches:
$ git branch

Commit all the new changes since last commit:
$ git commit -a -m "Describe what these changes do"

Merge my new branch back into master:
$ git checkout master 

$ git merge my-new-branch

Delete the branch that is no longer needed
$ git branch -d my-new-branch



Undo screwups:
This rolls back to the last commit in the current branch.

The -f flag forces Git to overwrite changes since the last commit.
$ git checkout -f 


Undo a major screwup: 
This rolls back to a different branch and deletes the messed up branch
$ git checkout -b my-new-branch 
$ [do some stuff to really mess up the branch] 
$ git add . 
$ git commit -a -m "Major screw up" 
$ git checkout master 
$ git branch -D my-new-branch


[Notes taken from Ruby on Rails Tutorial]

Git initial config

One-time system setup:
$ git config --global user.name "Your Name" 

$ git config --global user.email your.email@example.com
$ git config --global core.editor "gvim -f"

First-time repository setup:
Change into the directory that houses your repository (project).  Then:

$ git init

Edit .gitignore to tell Git to ignore certain files:

----- 

# Ignore bundler config.
/.bundle

# Ignore the default SQLite database.
/db/*.sqlite3
/db/*.sqlite3-journal

# Ignore all logfiles and tempfiles.
/log/*.log
/tmp

# Ignore other unneeded files.
database.yml
doc/
*.swp
*~
.project
.DS_Store
.idea
.secret

-----


[Notes taken from Ruby on Rails Tutorial]

Change dark blue comments in vim to a brighter color

Can't see comments and other dark blue text in a vim window? Try this:

:set background=dark


If you like it, you can make it permanent by adding this line to your ~/.vimrc file:


set background=dark

 
 

Monday, November 18, 2013

How to install Ruby 2.0.0p247 and Rails 4.0 on Amazon Ubuntu instance

How I installed Rails

First install Ruby:

I tried to avoid using sudo.  I don't remember exactly when I used sudo in the steps below.  When you see "sudo", that's a post-install guess that I probably used it there.

sudo apt-get -y update
sudo apt-get -y install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev
cd /tmp
wget http://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p247.tar.gz
tar -xvzf ruby-2.0.0-p247.tar.gz
cd ruby-2.0.0-p247/
./configure --prefix=/usr/local
make
sudo make install

----------------------

I installed Rails by following this web page:

https://www.digitalocean.com/community/articles/how-to-install-ruby-on-rails-on-ubuntu-12-04-lts-precise-pangolin-with-rvm

Noting the relevant bits here in case that page goes down/changes:

sudo apt-get update
sudo apt-get upgrades
sudo apt-get install curl

This installs RVM.  RVM is a Ruby version manager.  I want this in case I need to use different versions of Ruby (maybe later).
\curl -L https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
rvm requirements

I don't know if this next part might be redundant.  I wonder if I should have installed RVM first, before installing Ruby.

rvm install ruby
rvm use ruby --default

This installs rubygems.  Not sure what gems are.  Wikipdedia says:

RubyGems is a package manager for the Ruby programming language that provides a standard format for distributing Ruby programs and libraries (in a self-contained format called a "gem"), a tool designed to easily manage the installation of gems, and a server for distributing them.

rvm rubygems current

This installs rails:
gem install rails



----------------------

Currently trying to follow this introductory Rails guide:

http://guides.rubyonrails.org/getting_started.html

The guide assumes I have SQLite3 installed.  I think this installed sqlite3:

sudo apt-get install sqlite3 libsqlite3-dev
sudo gem install sqlite3-ruby

I don't recall if I had to configure stuff for sqlite3.  There may have been on-screen instructions I had to follow.

Tuesday, September 27, 2011

MySQL Maintenance

My main focus is Microsoft SQL on Windows.  I was playing with MySQL and want to share MySQL equivalents to common functions in MS SQL.

Back up all MySQL databases:
$ mysqldump --user=root --password=whatever --result-file=backup_file.sql --all-databases

Look into the "lock-tables" option.
Also look into mysqlhotcopy
Also look into the log-bin option to get something like transaction logs.

For data integrity checks, look into mysqlcheck and myisamchk (is there something similar for Innodb?)

For optimization:
Index defrag - mysqlcheck --optimize -A -u username -ppassword

Tuesday, September 13, 2011

Mouse Without Borders

I used Synergy for several years to run multiple computers & monitors with a single keyboard and mouse.  I stopped because it had trouble with beta (unreleased) Windows products.  Here's one from Microsoft that seems to work better in a Microsoft-only (not cross platform) environment:

http://www.physorg.com/news/2011-09-no-borders-mouse-screens.html