Skip to content

Instantly share code, notes, and snippets.

@lg3bass
lg3bass / UNIX>tar.gz
Created August 17, 2016 15:29
UNIX tar.gz a directory via ssh
//source: http://unix.stackexchange.com/questions/93139/can-i-zip-an-entire-folder-using-gzip
//In order to "zip" a directory, the correct command would be
tar -zcvf archive.tar.gz directory/
//This will tell tar to c (create) an archive from the files in directory (tar is recursive by default),
//compress it using the z (gzip) algorithm, store the output as a f (file) named archive.tar.gz,
//and v (verbosely) list all the files it adds to the archive.
//To decompress and unpack the archive into the current directory you would use
tar -zxvf archive.tar.gz
@lg3bass
lg3bass / MACOS>UNIX>ipconfig
Created March 29, 2016 13:40
Get the IP address of your mac from the command line.
//get the ip address
ifconfig | grep "inet " | grep -v 127.0.0.1 | awk '{print $2}'
@lg3bass
lg3bass / gist:deabbfae1ca8a69a21b1
Created March 23, 2016 03:15
OSX>UNIX>FFMPEG rotate video in metadata to display on phone.
//source: https://stackoverflow.com/questions/25031557/rotate-mp4-videos-without-re-encoding/27768317#27768317?newreg=6ed56ec178f84481a73a2072665bb8c6
ffmpeg -i input.mp4 -c copy -metadata:s:v:0 rotate=90 output.mp4
//tar.gz
//source: http://unix.stackexchange.com/questions/93139/can-i-zip-an-entire-folder-using-gzip
//This will tell tar to c (create) an archive from the files in directory (tar is recursive by default),
//compress it using the z (gzip) algorithm, store the output as a f (file) named archive.tar.gz,
//and v (verbosely) list all the files it adds to the archive.
//In order to "zip" a directory, the correct command would be
tar -zcvf archive.tar.gz directory/
@lg3bass
lg3bass / OSX > UNIX
Last active March 2, 2016 18:12
Save directory listing, RSYNC to external drive
// clear out a log
USRLSML-2HLDV7L:logs uwhitbo$ echo "" > php_error.log
RESULT:
-rw-r--r-- 5 uwhitbo admin 1 Mar 2 13:08 php_error.log
// save folder listing
//source: https://github.com/0nn0/terminal-mac-cheatsheet/wiki/Terminal-Cheatsheet-for-Mac-%28-basics-%29
ls -R > CURRENT_2015_2.txt
@lg3bass
lg3bass / gist:6863150f1cc45824ca77
Last active August 17, 2018 14:06
What version of stuff do I have?
# Check for Python
python --version
# Check for node.js on Linux
nodejs --version
# Check for node.js on Windows
node --version
//source: http://kripken.github.io/emscripten-site/docs/building_from_source/toolchain_what_is_needed.html#toolchain-test-which-dependencies-are-installed
@lg3bass
lg3bass / gist:d89bc2a4720900a94487
Last active August 29, 2015 14:27
MACOS>UNIX>FFMPEG>Get Video Dimensions
//SOURCE:
//http://stackoverflow.com/questions/7362130/getting-video-dimension-from-ffmpeg-i
ffmpeg -i 1_1_misconception1_adaptivepathway_redo3.mp4 2>&1 | perl -lane 'print $1 if /(\d+x\d+) \[/'
that outputs : 768x432
//prints out the directory
for FILENM in *; do ffmpeg -i $FILENM 2>&1 | perl -lane 'print "\n",$1 if /(\d+x\d+) \[/'; printf $FILENM; done;
@lg3bass
lg3bass / gist:93b9a24ce678bc1acf54
Last active December 23, 2020 18:05
MACOS>UNIX>GIT>Create Repository From Existing
///NEW (2020-12-23)
1. Create a new repo on github. Make sure to not create a readme, licence, or git ignore. New repo MUST BE EMPTY!!!!
2. If you added NOTHING you will see the "Quick Setup" screen.
3. In your local repo (the folder you want to create the project from) run these commands in order:
LG3-MBP:ADSR lg3$ git init
LG3-MBP:ADSR lg3$ git add .
LG3-MBP:ADSR lg3$ git commit -m "enter a comment. What are you committing"
LG3-MBP:ADSR lg3$ git branch -M main
-- REF: https://docs.github.com/en/free-pro-team@latest/github/importing-your-projects-to-github/adding-an-existing-project-to-github-using-the-command-line
@lg3bass
lg3bass / concatenate with ffmpeg
Last active August 29, 2015 14:25
MACOS>UNIX>FFMPEG>>Concatenate 2 videos together
//BOIL IT ALL DOWN TO 2 LOOPS
//|==++--++==||==++--++==||==++--++==||==++--++==||==++--++==||==++--++==||==++--++==||==++--++==||==++--++==|
//Loop through all the files and pad them
for FILENM in *; do ffmpeg -i $FILENM -filter:v 'pad=max(iw\,ih*(16/9))+mod(max(iw\,ih*(16/9))\,2):ow/(16/9)+mod(ow/(16/9)\,2):(ow-iw)/2:(oh-ih)/2' -aspect 16:9 -s hd720 -acodec copy -vcodec libx264 -preset slow -crf 18 ${FILENM/.mp4/}_pad.mp4; done;
//loop through all the files and add the posterframe. NOTE: posterTitle.mp4 must be one directory level up from the files you are working on.
for FILENM in *; do ffmpeg -i ../posterTitle.mp4 -i $FILENM -filter_complex "[0:0] [0:1] [1:0] [1:1] concat=n=2:v=1:a=1 [v] [a]" -map "[v]" -map "[a]" -vcodec h264 -pix_fmt yuv420p -an ${FILENM/.mp4/}_titled.mp4; done;
///////////////////////////////////
@lg3bass
lg3bass / MACOS_UNIX_CP
Last active June 23, 2017 19:19
MACOS>UNIX>cp,mv,mkdir
//copy directory into another directory
cp -R CSV/ WPS_SITES/ab_middleton_law_mysearchlab_9/CSV/
//mkdir
//--the -p flag will create the intermediate directories.
mkdir -p LM/STINKBUT/TEST
//show the size of the home directory