Tuesday, June 26, 2018

Mac Terminal Themes

IR_Black
https://github.com/justincase/IR_Black-OSX
Peppermint
https://noahfrederick.com/log/lion-terminal-theme-peppermint

Sunday, February 4, 2018

Mac recording screen and audio

Record your computer screen with audio on a Mac
https://www.cnet.com/how-to/record-your-computers-screen-with-audio-on-a-mac/
Use QuickTime to Easily Extract Audio from Video Files in Mac
https://www.maketecheasier.com/quicktime-extract-audio-from-video/

Mac show/hide path

Once a Finder window launches, click on “View” on the top and then select “Show Path Bar.”

defaults write com.apple.finder _FXShowPosixPathInTitle -bool true; killall Finder

defaults write com.apple.finder _FXShowPosixPathInTitle -bool false; killall Finder

Backup iphone to external drive

Open terminal.

mkdir /Volumes/ExternalFileStorage/iTunesDeviceBackups/

cp ~/Library/Application\ Support/MobileSync/Backup/ Volumes/ExternalFileStorage/iTunesDeviceBackups/

cd ~/Library/Application\ Support/MobileSync/

rm -r Backup/

ln -s /Volumes/ExternalFileStorage/iTunesDeviceBackups/Backup/ ~/Library/Application\ Support/MobileSync/

Wednesday, January 17, 2018

Find files containing string

Use grep:
-r, --recursive Read all files under each directory, recursively, following symbolic links only if they are on the command line
-R, Read all files under each directory, recursively.  Follow all symbolic links, unlike -r.
-n, --line-number
-w, --word-regexp

   Select  only  those  lines  containing  matches  that  form  whole  words.
-l, --files-with-matches, print file name only
   Suppress normal output; print the name of each input file. The scanning will stop on the first match.
-i, --ignore-case, 
   Ignore case distinctions in both the PATTERN and the input files
-s, --no-messages
--include=GLOB
              Search only files whose base name matches GLOB (using wildcard matching)
--exclude=GLOB

              Skip files whose base name matches GLOB (using wildcard matching)
 --exclude-dir=DIR

grep -R --include="*.java" oraclehomeExistNodeList .

grep -r "string to be searched" /path/to/dir
grep -rnw '/path/to/somewhere/' -e 'pattern'

grep -insrw --include=Makefile "SBS_SCRIPTS" install/
grep --include=\*.{c,h} -rnw '/path/to/somewhere/' -e "pattern"
grep --exclude=\*.o -rnw '/path/to/somewhere/' -e "pattern"
grep --exclude-dir={dir1,dir2,*.dst} -rnw '/path/to/somewhere/' -e "pattern"

Along with these, --exclude, --include, --exclude-dir flags could be used for efficient searching.
For directories it's possible to exclude a particular directory(ies) through --exclude-dirparameter.


if the extension or name is known, and only in the child dir of current folder
grep -insr "SBS_SCRIPTS" **/*mk
grep -insr "SBS_SCRIPTS" **/Makefile
The magic here is by using globbing option (**) which helps you to scan all the files recursively with specific extension. If doesn't work, activate it by shopt -s globstar. You may also use **/*.* for all files (excluding hidden and without extension).

Use find:
-i - case insensitive search
-l - only output the filename where the match was found

-h - only output the line which matched (not the filename)

not a good use of xargs?
find . -name "Makefile" | xargs grep -i "SBS_SCRIPTS"
find . -type f | xargs grep 'text-to-find-here'

find . -type f -exec grep -l "text-to-find-here" {} \;

Friday, December 8, 2017

Use equations in blog

https://tex.stackexchange.com/questions/13865/how-to-use-latex-on-blogspot/13868#13868

Put the following after <head>

<script src='http://cdn.mathjax.org/mathjax/latest/MathJax.js' type='text/javascript'>
MathJax.Hub.Config({
extensions: [&quot;tex2jax.js&quot;,&quot;TeX/AMSmath.js&quot;,&quot;TeX/AMSsymbols.js&quot;],
jax: [&quot;input/TeX&quot;, &quot;output/HTML-CSS&quot;],
tex2jax: {
inlineMath: [ [&#39;$&#39;,&#39;$&#39;], [&quot;\\(&quot;,&quot;\\)&quot;] ],
displayMath: [ [&#39;$$&#39;,&#39;$$&#39;], [&quot;\\[&quot;,&quot;\\]&quot;] ],
},
&quot;HTML-CSS&quot;: { availableFonts: [&quot;TeX&quot;] }
});
</script>

No indent for equations:
after
jax: [...], 
put
displayAlign: "left",

Escape $ sign: http://docs.mathjax.org/en/latest/index.html
processEscapes: true