Saturday, November 29, 2014

How-to flash Nexus devices back to a particular Android version

Link and how-to to flash Nexus devices back to factory specs;  Includes direct links to download factory images for various versions:

https://developers.google.com/android/nexus/images


Saturday, November 8, 2014

Extract sets of compressed tarballs within each respective folder

$ for i in *.gz;  do mkdir `echo $i | cut -d '.' -f1`;  tar xvfz $i -C ./`echo $i | cut -d '.' -f1`; done

The above will:
1) Build a list of all .gz files within the current folder (assuming .tar.gz files)
2) If the tarball filename is tarballfile.tar.gz, create a folder called tarballfile/
3) Extract the contents of tarballfile.tar.gz into folder ./tarballfile/
4) Continue iterating through the other tarball files until the loop has completed.


Wednesday, October 1, 2014

How to set JAVA_HOME when installing Oracle JDK on a Mac running OSX Mavericks:

How to set JAVA_HOME when installing Oracle JDK on a Mac running OSX Mavericks

Sourced from: https://www.blogger.com/home?pli=1


The right place to download the JDK for Java 7 is Java SE Downloads.
All the other links provided above, as far as I can tell, either provide the JRE or Java 6 downloads (incidentally, if you want to run Eclipse or other IDEs, like IntelliJ IDEA, you will need the JDK, not the JRE).
Regarding IntelliJ IDEA - that will still ask you to install Java 6 as it apparently needs an older class loader or something: just follow the instructions when the dialog pop-up appears and it will install the JDK 6 in the right place.
Afterwards, you will need to do the sudo ln -snf mentioned in the answer above:
sudo ln -nsf /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents \
    /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK
(copied here as it was mentioned that "above" may eventually not make sense as answers are re-sorted).
I also set my JAVA_HOME to point to where jdk_1.7.0_xx.jdk was installed:
export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home"
Then add that to your PATH:
export PATH=$JAVA_HOME/bin:$PATH
The alternative is to fuzz around with Apple's insane maze of hyperlinks, but honestly life is too short to bother.
Thanks to Marco at:
Marco
853513



Link to main response:

Tuesday, August 12, 2014

Read a file, extract contents encapsulated in parentheses

Sourced from http://objectmix.com/awk/26995-retrieve-string-between-parentheses.html

$ cat some_file | gawk '{if (match($0,/\((.*)\)/,f)) print f[1]}' | cut -d ':' -f1 | sort | uniq

The above command will be helpful when reviewing stack trace output from command line to filter out and identify all the referenced .java files listed.

For example:

$ cat stacktrace_1.txt | gawk '{if (match($0,/\((.*)\)/,f)) print f[1]}' | cut -d ':' -f1 | sort | uniq
FilterFileSystem.java
Job.java
JobSubmissionFiles.java
JobSubmitter.java
Native Method
ProcessBuilder.java
RawLocalFileSystem.java
Shell.java
Subject.java
ToolRunner.java
UserGroupInformation.java

Friday, August 8, 2014

Extract a list of tarballs from the pwd into their own separate folders


  •  Extract all .tar.gz files residing in current dir into their own folders based upon the tarball’s filename.
  • Recommended naming convention for .tar.gz file is:  hostname-otherdetails.tar.gz (NOTE:  required details is the first hyphen which is used to separate the fields, using the first field as the target directory where the corresponding tarball will be extracted to
  • To change the parsing separating character, change the hyphen reference in the cut -d portion of the statement to another character, such as an underscore— For example,  cut -d ‘_’ -f1 



$ for i in *.tar.gz; do mkdir `echo $i | cut -d '-' -f1`; tar xvfz $i -C `echo $i | cut -d '-' -f1`; done


Collecting MR1 task logs from TTs in a single command


$tar cvfzh /tmp/`hostname`-job_201407311402-tasklogs.tar.gz /var/log/hadoop-0.20-mapreduce/userlogs/job_201407311402_0001/*

Reason why we include the -h option in tar:

The following location typically includes symlinks to the actual location of the task logs, which typically resides in the working space of the TT:
/var/log/hadoop-0.20-mapreduce/userlogs/job_201407311402_0001/ 

$ls -l
lrwxrwxrwx 1 mapred mapred  81 Aug  8 07:54 attempt_201407311402_0001_m_000000_0 -> /mapred/local/userlogs/job_201407311402_0001/attempt_201407311402_0001_m_000000_0


Thursday, July 17, 2014

Filter log file from common entries of no interest, along with blank lines



egrep -v "Trying to set|at "  hadoop-cmf-mapreduce1-JOBTRACKER-node.company.com.log.out | sed -e '/^\s*$/d' | less