Friday, October 13, 2017

Git - Basic Commands

Understanding

The Git repository is a tree of commits each of which keeps a pointer to its parent (for merge commits: two parents) and all of the files modified in this commit.  HEAD, tags and branches are all labels to a node of that tree.

Branches

  • git branch NAME   --- create a branch of the current branch
  • git branch --all  --- list all branches local and remote
  • git checkout -b release-4.16.0 origin/develop   --- create branch release-4.16.0 from the current branch and set tracking to origin/develop
  • git branch -u origin/develop  --- set tracking on an existing branch
  • git branch -d NAME  - delete a branch but only if it's safe (i.e. we won't loose access to any commit)
  • git branch -D NAME  - force delete a branch (requires extra permissions; commits to which we may loose access will be available through its ID for next N days (default is 30 days) and it will be garbage-collected after that)

Commit

  • git commit  --- committing the changes to local git repo
  • git commit --amend  --- allows to edit the last commit, to edit its message and correct the files you committed

Pushing and Pull

  • git add  --- staging files for commit
  • git pull  --- if the current branch is behind the branch it tracks, this command will update it
  • git push origin local-branch:remote-branch  --- push local branch to remote repository origin

Rebase

  •  git rebase origin/develop  --- rebases, which means if the current branch is behind on some commits from origin/develop branch, it will incorporate all of them and place as if they were made earlier than those commits that the current branch is ahead of the origin/develop.
  • git rebase -i HEAD~2  --- interactive rebase, that is a tool to modify commit history.  In most common scenario it is used to squash two or more recent commits into one (though commit --amend can do it, too) but it can also remove commits from the history as well as change their order.  The tool can do lasting damage if you make mistake - use with caution!

Tags

  • git tag v4.23.0  --- adds a tag v4.23.0 to the current node (there is also another, lighter type of tag - I haven't been using it)
  • git push origin v4.23.0  --- pushing a tag to the remote repo

Other

  • git fetch  --- updates the local git repo from the remote repos
  • git status  --- shows the commits that the current branch is ahead and behind with respect to the branch it tracks as well as unversioned and modified files that aren't added to the change set.
  • git log  --- shows a paged list of commits with the most recent first
  • cherrypicking  --- allows to copy a commit from into another branch (important: it's a copy)

Tuesday, September 26, 2017

Docker - Understanding it

 
  • docker is a history recorded of what changed from the original image that the container started off
  • restart (or stop and start) reverts the container to what the image was, so the container is transient by default
  • it may be also possible to revert by tagging the image (yes!)

Wednesday, April 6, 2016

AWK Scripts - Examples

Example 1:

{
  if (match($0,/stat\.X[0-9][0-9][0-9]/)) tab = substr($0,RSTART+6,RLENGTH-6);
  if (tab + 0 >= 70 && tab + 0 <= 120) { print tab; }
}

Script does:
  • For every line like statA.X023, sets the variable 'tab' to the number, here 023
  • outputs the number if it is between 70 and 120

Friday, January 1, 2016

Playing an Audio ISO and Burning it into a CD

Tools that worked nicely for me:


  • To install the ISO on Windows to platy and copy MP3 of it: VirtualCloneDriver 5.4.9.0 (downloaded from SkySoft Download)
  • To burn: CyberLink Power2Go v. 5
What didn't work:
  • MicroSoft Virtual CD-ROM Control Panel v. 2.0.1.1
    Problem: driver installation; it's a tricky piece of software, doesn't see the driver file even it was placed where told to - file was there but the software filtered it out, somehow, even when run an admin
Environment: Windows 7

Thursday, November 12, 2015

Update in PostgresSQL Using the Command Line Tool - PSQL

The command:

psql -h hostname -d database -U username -W --echo-queries -f script-file-name.sql

where:

-W - to request psql to ask for password (rather then assume no-password)-h  - PostgreSql server host name or ip
-f  - file with the SQL script to execute on the database
 --echo-querries - shows the currently executed query for easier debugging of the script

Wednesday, October 28, 2015

Install Puppy Linux on my Old ThinkPad R60

Version: Slacko Puppy 5.7

  • Problem: Wi-Fi not working. Solution:
  • First: rfkill list
  • if it says softblock yes, try Fn F5. If it doesn't help do: sudo rfkill unblock wifi; sudo rfkill unblock all
  • Then:

# cd /lib/firmware/
# cp iwlwifi-3945-2.ucode iwlwifi-3945-1.ucode
# ifconfig wlan0 up

And try to connect.

Monday, September 21, 2015

IntelliJ IDEA - Keyboard Shortcuts And More for An Ex-Eclipse User

Since, couple years ago, JetBrains made available its IntelliJ IDEA to users for free (yes, only its Community Edition), it became an interesting alternative to Eclipse IDE.  While Eclipse is a great IDE, people looking for something more (even if just a little more), may be tempted to switch to IDEA, so here's something for them from another developer tempted to switch as well.

I have bolded out the actions I tend to use all the time in Eclipse.


Basic Shortcuts:

  • C-N - open class
  • C-S-N - open any file
  • A-F7 - find all usages of the object in the workspace
  • C-Q - quick doco (info) about the object under cursor
  • C-click - go to definition/implementation
  • C-F12 - show quick outline of the class
  • C-Space - auto complete
  • C-S-Space - power auto complete (Tan and Enter - both select, but differently)
  • A-Insert - code generate
  • C-/ - comments with //
  • C-S-/ - comments with /*...*/
  • C-D - duplicates the selection
  • C-S-BckSpc - move back in change-history locations
  • C-S-F7 - highlight an identifier; F3 and S-F3 move to next/prev usage; Esc - de-highlight
  • Code | Optimize Imports - from menu
  • C-E - recent files list
  • call tree of the current method: C-A-H
  • locate the current file in the project tree: there is an icon in the project viewer
  • move selected statements up or down the file: C-S-up and down
  • go to declaration of the object: C-B 
  • go back in the browsing history (as opposed to change history):
    C-A-left and right or C-[
  • synchronize a file or a project against the SVN repo: see Version Control tool
Legend: C means Control, S - Shift and A - Alt

Advanced Shortcuts:

  • S-F6 - refactor: rename
  • Esc - in a tool window - moves focus to editor (S-Esc - also hides the tool window)
  • F12 - opposite to Esc
  • C-A-T - surround it
  • C-W - extend the selection
  • C-A-V - refactor: extract variable
  • Tab - live templates (np. itar Tab)
  • Local History | Show History - from file or directory shows and lets  revert to any version all changes in this file or directory

Create a New Project from Sources in IntelliJ: 

  • Open from sources or from SVN/GIT
  • Open Project Structure dialog (Ctrl+Shift+Alt+S) and specify which are source folders using the Module item from the left-hand panel