Friday, January 30, 2015

Mac: moving large amount of files off to external drive

I have tried to clean up my hard drive in preparation to upgrade to SSD. Moving files using Finder FAILS all the time an in the end you don't know what was copied and what was not.

I used rsynch tool because it it smart enough to copy ONLY new and changed files, so I can run it multiple times and transfer only the differences (delta).

$ sudo rsync -varpog --progress ~/Documents/SourceDir/ /Volumes/1TB_BU/DestinationDir/  Password:building file list ... 8943 files to consider.DS_Store      159748 100%  121.10MB/s    0:00:00 (xfer#1, to-check=8941/8943)2013-08-15 09.35.24.mp4    87290465 100%   22.57MB/s    0:00:03 (xfer#2, to-check=7445/8943)2013-08-15 11.51.18.jpg

...sent 26005122366 bytes  received 163790 bytes  20565667.19 bytes/sec
total size is 35588964732  speedup is 1.37

Consecutive runs:

$ sudo rsync -varhpog --progress ~/Documents/SourceDir/ /Volumes/1TB_BU/DestinationDir/  

building file list ... 8943 files to consider
sent 173.28K bytes  received 20 bytes  346.61K bytes/sectotal size is 35.59G  speedup is 205355.70



Options:

-h show full help

-v verbose
--progress show progress while transfer
-h unman readable
-q quiet for non-error
-r recursive
-a archive
-b backup
-p preserve permissions
-o preserve owner
-g preserve group
-z compress data during the transfer


Tuesday, January 27, 2015

Mac OS X: Yosemite: increase responsiveness

In this tutorial we will perform steps to increase responsiveness of the Mac.

Java: interest rate calculator

In this tutorial we will write a simple command line Java program that calculates compound interest rate.

Monday, January 26, 2015

Java: Hello World

In this tutorial we will create the simplest of Java applications, an app that prints customary "Hello World" to the console.

IntelliJ IDEA: Create new Project (whole class) and new Modules (applications)

In this tutorial we will create a new Project (for the whole class) and new Modules (applications).


JavaFx: Hello World

In this tutorial we will print the customary "Hello World" to console and the the GUI using JavaFX.

Tuesday, January 20, 2015

IntelliJ IDEA: installation

In this tutorial we will install IntelliJ IDEA

Java: classes & methods

https://sites.google.com/site/chicagoandroid/050/java-class

Java: syntax

https://sites.google.com/site/chicagoandroid/050/java-syntax

Java: OOP

https://sites.google.com/site/chicagoandroid/050/050a

Windows: command line emulator for Unix

Cygwin:


https://cygwin.com/install.html

Java: installation



Find out if you have Java


$ which java

/usr/bin/java

$ whereis java
/usr/bin/java

$ ls -al /usr/bin/java | grep java
lrwxr-xr-x  1 root  wheel  74 Nov 17 08:13 /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java

Verify that you have Java version 1.8


$ java -version
java version "1.8.0_20-ea"
Java(TM) SE Runtime Environment (build 1.8.0_20-ea-b05)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b05, mixed mode)

uki@ CNH_PROD $ 


Install Java if you need it


Windows:
https://www.java.com/en/download/help/windows_manual_download.xml


Mac:
https://www.java.com/en/download/faq/java_mac.xml


Linux:
https://www.java.com/en/download/help/linux_x64_install.xml

Friday, January 16, 2015

UNIX: import public key


On Server:

cd .ssh
ls
cat ../id_rsa.pub >> authorized_keys 
cat authorized_keys 
cd

rm -fr id_rsa.pub 

Java: find jar

When you are looking for a given Java class, you can use this online database to locate jars:

Example, looking for log4j

http://www.findjar.com/index.x?query=log4j

Among others I get response:

[JAR] log4j-1.1.3.jar in log4j/log4j/1.1.3
[JAR] log4j-1.2.11.jar in log4j/log4j/1.2.11
[JAR] log4j-1.2.12.jar in log4j/log4j/1.2.12



Maven: installing apk, or arr, or jar in .m2

Sometimes you get a built artifact (apk, arr, jar) and instead of keeping it in your Downloads, or com up with a nice folder structure, you can simply put it in your Maven .m2 repository, that what it is designed for.


$ mvn install:install-file -Dpackaging=apk -DgroupId=com. mycompany.android -DartifactId= SomeApp -Dversion=1.4.42.0 -Dfile=/Users/uki/Downloads/SomeApp-1.4.42.0.apk

[INFO] Scanning for projects...

[INFO]                                                                         

[INFO] ------------------------------------------------------------------------

[INFO] Building Maven Stub Project (No POM) 1

[INFO] ------------------------------------------------------------------------

[INFO] 

[INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ standalone-pom ---

[INFO] Installing /Users/uki/Downloads/SomeApp-1.4.42.0.apk to /Users/uki/.m2/repository/com/mycompany/android/SomeApp/1.4.42.0/SomeApp-1.4.42.0.apk

[INFO] Installing .../Users/uki/.m2/repository/com/mycompany/android/SomeApp/1.4.42.0/SomeApp-1.4.42.0.pom

[INFO] ------------------------------------------------------------------------

[INFO] BUILD SUCCESS

[INFO] ------------------------------------------------------------------------

Thursday, January 15, 2015

Linux: set date manually

If you have a linux board that has no access to Internet, you might have to set the date manually.

root@imx6qsabrelite:~# date -s "15 JAN 2015 13:50:00"Thu Jan 15 13:50:00 CST 2015root@imx6qsabrelite:~# dateThu Jan 15 13:50:02 CST 2015

Tuesday, January 13, 2015

TextWrangler: formatting XML file

Go to directory where TextWrangle keeps all the scripts:

$ cd ~/Library/Application\ Support/TextWrangler/Text\ Filters 

Create a new file for XML formatting:

Text Filters $ touch FormatXML.sh 


This will open the new file in TextWrangler (or whatever editor you have set).
Text Filters $ edit FormatXML.sh 

Enter this text in that file and save:

#!/bin/sh
XMLLINT_INDENT=$'\t' xmllint --format --encode utf-8 -

Now you can format any XML by selecting TextWrangler menu: 

Text > Apply Text Filter > FormatXML