Tuesday, September 26, 2017

Docker - All the Magic


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!)

Maintenance

When it gets sloooow, and the com.docker.hyperkit takes 20% or 30% of CPU or more, try:
  • consider reducing the # of cpu's enabled
  • prune images not referenced by any container (created
    more than 24h ago):

    docker image prune -a --filter "until=24h"
  • prune containers all stopped containers (older than 24h):
    docker container prune --filter "until=24h"
  • prune networks not used by any container (older than 24h):
    docker network prune --filter "until=24h"
  • and possibly prune volumes not used by currently by any container (make sure you don't need the data on them):
    docker volume prune

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

Friday, August 14, 2015

pgAdmin

Copy just the schema of a database: do Backup, with any format other than Plain (it requires pgsql to import it) and on the Option tab page select Schema Only.  It runs pg_dump behind the scene.  You will need pgAdmin newer than 1.16 which allowed schema-only option with Plain format only.
The problem is, version 1.20, for example, copies the whole database even if I check Schema-Only.

Back to Plain format.  In pgAdmin we choose a plain format and options as above or use comand line in CMD in folder where pgAdmin was installed as below:

pg_dump.exe --host myhost --port 8035 --username "myuser" --format plain --schema-only --no-owner --no-privileges --verbose --file "filename" "mydbname"

After generating it, in CMD run:

psql -d my-db-name -f "c:\aaa\my-exported-schema-file" -U postgres 

It will ask for the password.  The tool psql comes bundled with pgAdmin, at least it does in version 1.20.