User:Rossolson/Tips and Tricks

From DPWiki
Jump to navigation Jump to search

Some notes from my local crib sheet of tips and tricks

Stripping the extra MacOS files from your zip archive for EBookMaker processing.

zip -d Archive.zip __MACOSX/\* .DS_Store images/.DS_Store

Example command for resizing a directory full of images.

sips --resampleHeight 369 -c 369 540 *.jpeg --out ./resized/

Example command to add a suffix to a directory of files.

ls | cat -n | while read n f; do mv -n "$f" "$n.png"; done

Incrementing Bookmarklet

 javascript:(function()%7Bvar%20e,s;IB=1;function%20isDigit(c)%7Breturn('0'%3C=c&&c%3C='9')%7DL=location.href;LL=L.length;for(e=LL-1;e%3E=0;--e)if(isDigit(L.charAt(e)))%7Bfor(s=e-1;s%3E=0;--s)if(!isDigit(L.charAt(s)))break;break;%7D++s;if(e%3C0)return;oldNum=L.substring(s,e+1);newNum=''+(parseInt(oldNum,10)+IB);while(newNum.length%3ColdNum.length)newNum='0'+newNum;location.href=L.substring(0,s)+newNum+L.slice(e+1);%7D)();


Inject Viewport

 javascript:(function()%7BmetaTag=document.createElement('meta');metaTag.name='viewport';metaTag.content='width=device-width';document.head.appendChild(metaTag);%7D)();