Skip to content

Instantly share code, notes, and snippets.

@patrickserrano
Last active September 24, 2020 17:25
Show Gist options
  • Save patrickserrano/8225613 to your computer and use it in GitHub Desktop.
Save patrickserrano/8225613 to your computer and use it in GitHub Desktop.
Scratch pad to keep useful terminal commands
// Keep mac awake until app is idle
caffeinate -i open -W -a iMovie.app
// Show hidden files (FALSE to hide)
defaults write com.apple.finder AppleShowAllFiles TRUE
// Create textfile of directory and all sub-directories (use .csv to maked a CSV)
ls -R /DIRECTORY > file-name.txt
// Find the PID running on port 3000
lsof -wni tcp:3000
//kill that process
kill -9 PID
// Compress Image using Imagemagick
convert -strip -interlace Plane -quality 85% source.jpg result.jpg
// Compress all subdirectories into their own .zip
for i in */; do zip -r "${i%/}.zip" "$i"; done
// Restart Wireless Networking (use en0 for Ethernet)
As Sudo:
ifconfig en1 down
ifconfig en1 up
// Convert ISO to DMG
hdiutil convert /path/imagefile.iso -format UDRW -o /path/convertedimage.dmg
// Restart OS X UI
sudo killall -HUP WindowServer
// Create 1GB Dummy File
mkfile -n 1g ~/Desktop/LargeTestFile
// save verbose cURL output to a file on your desktop
curl -vsL "URL" > ~/Desktop/out.txt 2>&1
// generate lowercase guid
uuidgen | awk '{print tolower($0)}'
// replace string in file and save output to new file
sed -n 's/FindthisWord/ReplaceWithThisWord/gpw output.txt' file.txt
// select data and output to json
sqlite-json ~/cq-oct.db "SELECT Count(LegacyDealerId), PrintTemplateCode,EmailTemplateCode,CampaignName,CampaignId,BrandCode,BrandName,RespondByDate,MonthDay,MailedDate,PersonalizedCode,HouseholdId,CustomerFirstName,CustomerLastName,Address1,Address2,City,State,Zip,LicensedEmailAddress,YourPrice,DocFee,SubjectLine,UnsubscribeURL,StoreURL,VehicleImage,LegacyDealerId,DealerName,DSender1FirstName,DSender1Email,DSender1Phone,DSender1Title,DStreetAddress,DCity,DState,DZip,DWebsite,MaintenanceSelected,MaintenanceOption,DMiscCopyParagraph,DMiscCopyBullet1,DMiscCopyBullet2,DMiscCopyBullet3,DMiscCopyBullet4,DMiscCopyLegal,DpsLegal,DpsLine,PmtMiscParagraph,PmtMiscLegal,GiftOptions,ConquestHeader,ConquestLegal,ConquestBody,V1Year,V1Make,V1Model,V1Trim,V1DiscountDealType,V1Discount,V1MSRP,V1Feature1,V1Feature2,V1Feature3,V1Feature4,V1DiscountLegalCopy,V1OptionCode,V2Year,V2Make,V2Model,V2Trim,V2DiscountDealType,V2Discount,V2MSRP,V2Feature1,V2Feature2,V2Feature3,V2Feature4,V2Feature5,V2DiscountLegalCopy,V2OptionCode,CustomVariable1,CustomVariable2,CustomVariable3,MailerOpenURL FROM data GROUP BY data.BrandCode" -o ~/Desktop/dealers-output.json
/Users/patrick/Desktop/dealers-output.json
// compress video to H.264
ffmpeg -i input.mp4 -vcodec libx264 -crf 28 output.mp4
// disable spotlight indexing
sudo mdutil -a -i off
// turn it back on:
sudo mdutil -a -i on
// split csv by distinct value in a single column. $3 represents the column #
awk -F '\t' 'NR == 1 { header=$0; next }
$3 != prev { close(handle); prev = $3; handle = "new_file1_" $3; print header >handle }
{ print >handle }' input_file.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment